1
0
Fork 0
mirror of https://github.com/pnx/dotfiles synced 2026-06-16 03:14:55 +02:00

Update nvim config

This commit is contained in:
Henrik Hautakoski 2023-11-22 14:19:13 +01:00
parent d7a1770460
commit 461e0cc49a
27 changed files with 426 additions and 2999 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,20 +0,0 @@
" Keybinds
let mapleader=","
:nmap <c-s> :w<CR>
:imap <c-s> <Esc>:w<CR>a
:nmap <c-v> :Vex<CR>
:noremap <Home> 0w
:inoremap <Home> <ESC>0wi
" -- NERDTree
nnoremap <C-n> :NERDTreeFocus<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
" -- Insert date
:noremap <C-D> a<C-R>=strftime('%F')<CR><ESC>
:xmap <C-D> di<Space><C-R>=strftime('%F')<CR><Esc>

View file

@ -1,17 +0,0 @@
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: There's always complete item selected by default, you may want to enable
" no select by `"suggest.noselect": true` in your configuration file.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction

View file

@ -1,76 +0,0 @@
:highlight clear
if version > 580
hi clear
if exists("syntax_on")
syntax reset
endif
endif
let colors_name='kodex'
" Color table
:hi! Black ctermfg=0
:hi! Red ctermfg=1
:hi! Green ctermfg=2
:hi! Yellow ctermfg=3
:hi! Blue ctermfg=4
:hi! Purple ctermfg=5
:hi! Cyan ctermfg=6
:hi! White ctermfg=7
:hi Normal ctermfg=White
:hi Comment ctermfg=red
:hi Special ctermfg=white
:hi String ctermfg=blue
:hi Function ctermfg=yellow
:hi Structure ctermfg=yellow
:hi Statement ctermfg=yellow
:hi Identifier ctermfg=green cterm=none
:hi Operator ctermfg=yellow
:hi Constant ctermfg=darkred
:hi Define ctermfg=yellow
:hi Type ctermfg=yellow
:hi PreProc ctermfg=yellow
:hi Error cterm=underline ctermfg=red ctermbg=none
:hi MatchParen ctermfg=cyan ctermbg=none
:hi Directory ctermfg=blue cterm=bold
" php
:hi link phpVarSelector Identifier
" StatusLine
:hi StatusLine ctermbg=red
" Cursor
:hi CursorLine cterm=NONE ctermfg=NONE ctermbg=NONE
" Line numbers
:hi LineNr guifg=grey50 ctermfg=grey
function! ResetCursorLineNrColor()
hi CursorLineNR guifg=grey50 ctermfg=grey cterm=bold
endfunction
if exists("g:kodex#color_cursor_line_insert")
function! CursorLineNrColorInsert()
let mode = v:insertmode
" Insert mode: blue
if mode == "i"
hi CursorLineNr ctermfg=yellow
" Replace mode: red
elseif mode == "r"
hi CursorLineNr ctermfg=red
else
hi CursorLineNr ctermfg=green
endif
endfunction
autocmd InsertEnter * call CursorLineNrColorInsert()
autocmd InsertLeave * call ResetCursorLineNrColor()
endif
:call ResetCursorLineNrColor()

View file

@ -1,6 +0,0 @@
function! GitStatus()
let l:branchname = system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
return strlen(l:branchname) > 0?'branch:'.l:branchname.' ':''
endfunction

2
nvim/init.lua Normal file
View file

@ -0,0 +1,2 @@
require("config")
require("plugins")

View file

@ -1,44 +0,0 @@
:language en_US
:set encoding=UTF-8
:runtime plugins.vim
:runtime tab.vim
:runtime git.vim
:runtime binds.vim
:runtime terminal.vim
:runtime coc.vim
:runtime nerdtree.vim
:syntax on
:set number
:set numberwidth=4
:set cursorline
:set showmode
:set guicursor=a:ver100,c-ci-cr:hor80-blinkon100-blinkwait300
" -- Color scheme
let g:kodex#color_cursor_line_insert=1
:colorscheme kodex
let g:lightline={
\ "colorscheme": "one"
\ }
" STATUS LINE ------------------------------------------------------------ {{{
" Clear status line when vimrc is reloaded.
set statusline=
" Status line left side.
"set statusline+=\ %{GitStatus()}\ %y\ %f:%l
" Use a divider to separate the left side from the right side.
"set statusline+=%=
" Status line right side.
"set statusline+=L\ %l:%c\ \%m\
" Show the status on the second to last line.
set laststatus=2
" }}}

4
nvim/install.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
git clone --depth 1 https://github.com/wbthomason/packer.nvim \
~/.local/share/nvim/site/pack/packer/start/packer.nvim

21
nvim/lazy-lock.json Normal file
View file

@ -0,0 +1,21 @@
{
"LuaSnip": { "branch": "master", "commit": "46c91e814732c1630b8a8b50d04acbf54b8320fa" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
"cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "3d8912ebeb56e5ae08ef0906e3a54de1c66b92f1" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"kanagawa.nvim": { "branch": "master", "commit": "c19b9023842697ec92caf72cd3599f7dd7be4456" },
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
"lspkind-nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" },
"lualine-lsp-progress": { "branch": "master", "commit": "56842d097245a08d77912edf5f2a69ba29f275d7" },
"lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "6eb8cae80f2e4322ec82cd9f8fa423f6d1eb02c3" },
"mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" },
"nvim-cmp": { "branch": "main", "commit": "0b751f6beef40fd47375eaf53d3057e0bfa317e4" },
"nvim-lspconfig": { "branch": "master", "commit": "90a28fd7637b66e055af62387ecee06f7cbd3173" },
"nvim-treesitter": { "branch": "master", "commit": "075a64addc33390028ea124a1046a43497f05cd1" },
"nvim-web-devicons": { "branch": "master", "commit": "3fafeea5f339223e888fd15eb4032260849cb038" },
"playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" },
"plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" },
"telescope.nvim": { "branch": "master", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" }
}

22
nvim/lua/config/base.lua Normal file
View file

@ -0,0 +1,22 @@
--
-- General Settings
--
vim.opt.showmode = false -- disable mode in the command line, because i use lualine
--vim.opt.guicursor = "a:ver100,c-ci-cr:hor80-blinkon100-blinkwait300"
--vim.opt.scrolloff = 30
--vim.opt.sidescrolloff = 8
--
-- Editor settings
--
vim.opt.cursorline = true -- highlight line where cursor is.
-- line numbers
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.numberwidth = 6
-- indent
vim.opt.smartindent = true

View file

@ -0,0 +1,31 @@
local autocmd = vim.api.nvim_create_autocmd
local augroup = vim.api.nvim_create_augroup
local set = vim.opt
set.tabstop = 4
set.softtabstop = 4
set.shiftwidth = 4
set.autoindent = true
augroup('indent', { clear = true })
-- Hardtabs for make
autocmd('Filetype', {
group = 'indent',
pattern = { 'make' },
command = 'setlocal ts=4 sts=0 sw=4 noexpandtab'
})
-- Softtab (2) for yaml
autocmd('Filetype', {
group = 'indent',
pattern = { 'yaml' },
command = 'setlocal ts=2 sts=2 sw=2 expandtab'
})
-- Hardtabs for c/cpp
autocmd('Filetype', {
group = 'indent',
pattern = { 'c', 'cpp' },
command = 'setlocal ts=8 sts=0 sw=8 noexpandtab'
})

3
nvim/lua/config/init.lua Normal file
View file

@ -0,0 +1,3 @@
require("config.base")
require("config.keybinds")
require("config.indent")

View file

@ -0,0 +1,39 @@
-- Basic ones
vim.g.mapleader = " "
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
vim.keymap.set("i", "<C-z>", vim.cmd.undo)
vim.keymap.set("i", "<C-y>", vim.cmd.redo)
-- Ctrl+s saves the current buffer in normal/insert mode.
vim.keymap.set("n", "<C-s>", vim.cmd.w)
vim.keymap.set("i", "<C-s>", vim.cmd.w)
-- Disable arrow keys (force me to use hjkl)
vim.keymap.set("n", "<Up>", "", { noremap=true })
vim.keymap.set("n", "<Down>", "", { noremap=true })
vim.keymap.set("n", "<Left>", "", { noremap=true })
vim.keymap.set("n", "<Right>", "", { noremap=true })
vim.keymap.set("i", "<Up>", "", { noremap=true })
vim.keymap.set("i", "<Down>", "", { noremap=true })
vim.keymap.set("i", "<Left>", "", { noremap=true })
vim.keymap.set("i", "<Right>", "", { noremap=true })
vim.keymap.set("v", "<Up>", "", { noremap=true })
vim.keymap.set("v", "<Down>", "", { noremap=true })
vim.keymap.set("v", "<Left>", "", { noremap=true })
vim.keymap.set("v", "<Right>", "", { noremap=true })
-- Move Text
--vim.keymap.set("n", "<S-a>", ":m+1<CR>")
--vim.keymap.set("v", "<S-d>", ":m-2<CR>")
--vim.keymap.set("v", "<S-a>", ":m+1<CR>")
--vim.keymap.set("n", "<S-d>", ":m-2<CR>")
-- Indent
-- Make Shift-Tab undo indent.
vim.keymap.set("i", "<S-Tab>", "<C-d>")

64
nvim/lua/plugins/cmp.lua Normal file
View file

@ -0,0 +1,64 @@
return {
'hrsh7th/nvim-cmp',
dependencies = {
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-nvim-lsp-signature-help',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'L3MON4D3/LuaSnip',
'onsails/lspkind-nvim',
},
config = function()
local cmp = require('cmp')
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
cmp.setup({
preselect = false,
view = {
entries = { name = 'custom', selection_order = 'near_cursor' },
},
mapping = {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, { "i", "s" }),
['<CR>'] = cmp.mapping.confirm({ select = false }),
},
formatting = {
format = function(entry, vim_item)
if vim.tbl_contains({ 'path' }, entry.source.name) then
local icon, hl_group = require('nvim-web-devicons').get_icon(entry:get_completion_item().label)
if icon then
vim_item.kind = icon
vim_item.kind_hl_group = hl_group
return vim_item
end
end
return require('lspkind').cmp_format({ with_text = true })(entry, vim_item)
end
},
sources = {
{ name = 'nvim_lsp', max_item_count = 10 },
{ name = 'nvim_lsp_signature_help' },
{ name = 'buffer' },
{ name = 'path' },
},
})
end
}

View file

@ -0,0 +1,9 @@
return {
"rebelot/kanagawa.nvim",
lazy = false,
priority = 1000,
config = function()
require("kanagawa").load("wave")
end
}

View file

@ -0,0 +1,12 @@
return {
'lewis6991/gitsigns.nvim',
lazy = false,
opts = {
signs = {
add = { text = '+' },
delete = { text = '-' },
change = { text = '~' },
untracked = { text = '+'}
},
},
}

41
nvim/lua/plugins/init.lua Normal file
View file

@ -0,0 +1,41 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
-- Highlight
--{ import = "plugins.kodex" },
{ import = "plugins.colortheme-kanagawa" },
-- Status line
{ import = "plugins.lualine" },
-- Fuzzy finder
{ import = "plugins.telescope" },
-- Keybind helper
-- { import = "plugins.which-key" },
-- Treesitter
{ import = "plugins.treesitter" },
-- Complete
-- { import = "plugins.cmp" },
-- LSP
{ import = "plugins.lsp" },
-- Git changes in gutter
--{ import = "plugins.gitsigns" },
})

View file

@ -0,0 +1,8 @@
return {
dir = "~/code/misc/kodex.nvim",
lazy = false,
priority = 1000,
config = function()
vim.cmd(":colorscheme kodex-arctic")
end
}

40
nvim/lua/plugins/lsp.lua Normal file
View file

@ -0,0 +1,40 @@
return {
'neovim/nvim-lspconfig',
dependencies = {
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
require('plugins.cmp')
},
config = function()
-- Setup Mason to automatically install LSP servers
require('mason').setup()
require('mason-lspconfig').setup({ automatic_installation = true })
-- local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
-- PHP
require('lspconfig').intelephense.setup({
commands = {
IntelephenseIndex = {
function() vim.lsp.buf.execute_command({ command = 'intelephense.index.workspace' }) end,
},
},
on_attach = function(client, bufnr)
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
end,
-- capabilities = capabilities
})
-- Tailwind CSS
--require('lspconfig').tailwindcss.setup({ capabilities = capabilities })
-- Config
-- Sign configuration
vim.fn.sign_define('DiagnosticSignError', { text = '', texthl = 'DiagnosticSignError' })
vim.fn.sign_define('DiagnosticSignWarn', { text = '', texthl = 'DiagnosticSignWarn' })
vim.fn.sign_define('DiagnosticSignInfo', { text = '', texthl = 'DiagnosticSignInfo' })
vim.fn.sign_define('DiagnosticSignHint', { text = '', texthl = 'DiagnosticSignHint' })
end
}

View file

@ -0,0 +1,26 @@
return {
'nvim-lualine/lualine.nvim',
event = "VeryLazy",
dependencies = {
'arkav/lualine-lsp-progress',
'kyazdani42/nvim-web-devicons',
},
opts = {
options = {
component_separators = '',
globalstatus = true,
},
sections = {
lualine_x = {
{
require("lazy.status").updates,
cond = require("lazy.status").has_updates,
color = { fg = "#ff9e64" },
}
},
lualine_y = {
'encoding', 'fileformat', 'filetype'
}
},
}
}

View file

@ -0,0 +1,30 @@
return {
'nvim-telescope/telescope.nvim',
tag = '0.1.4',
dependencies = {
'nvim-lua/plenary.nvim',
'kyazdani42/nvim-web-devicons'
},
keys = {
{ '<leader>f', function() require('telescope.builtin').find_files() end },
{ '<leader>F', function() require('telescope.builtin').git_files() end },
},
config = function()
require('telescope').setup({
defaults = {
path_display = { truncate = 1 },
prompt_prefix = ' ',
selection_caret = ' ',
file_ignore_patterns = {
".git/",
"node_modules/"
},
},
pickers = {
find_files = {
hidden = true
},
},
})
end
}

View file

@ -0,0 +1,60 @@
return {
'nvim-treesitter/nvim-treesitter',
build = function()
require('nvim-treesitter.install').update({ with_sync = true })
end,
dependencies = {
'nvim-treesitter/playground'
},
opts = {
-- A list of parser names
ensure_installed = {
"c",
"cpp",
"ninja",
"cmake",
"lua",
"vim",
"vimdoc",
"query",
"php",
"go",
"javascript",
"typescript",
"css",
"scss",
"html",
"vue",
"json",
"yaml",
"toml",
"xml",
"glsl",
"hlsl"
},
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
highlight = {
enable = true,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
indent = {
enable = true
}
}
}

View file

@ -0,0 +1,14 @@
return {
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
}

View file

@ -1,7 +0,0 @@
call plug#begin()
Plug 'itchyny/lightline.vim'
Plug 'ryanoasis/vim-devicons'
Plug 'preservim/nerdtree'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()

View file

@ -1,12 +0,0 @@
" --- Tab Settings
set tabstop=4 softtabstop=4 shiftwidth=4 expandtab autoindent
" Set hardtabs for make
:autocmd FileType make setlocal ts=4 sts=0 sw=4 noexpandtab
" Set 2 softtab for yaml files
:autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" Set hardtabs for cpp
:autocmd FileType cpp setlocal ts=8 sts=0 sw=8 noexpandtab

View file

@ -1,5 +0,0 @@
" Use a blinking upright bar cursor in Insert mode, a blinking block in normal
" if &term == 'xterm-256color' || &term == 'screen-256color'
" let &t_SI = "\<Esc>[5 q"
" let &t_EI = "\<Esc>[5 q"
"endif