Nvim: modernize config + some tweaks in lsp

This commit is contained in:
Robert Kmieć
2022-05-31 22:09:46 +02:00
committed by Robert Kmiec
parent c8dcb66279
commit e1b0b4ae4d
7 changed files with 89 additions and 44 deletions

View File

@@ -9,7 +9,7 @@ require('gitsigns').setup {
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = true, -- Toggle with `:Gitsigns toggle_word_diff`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
keymaps = {
-- Default keymap options
noremap = true,

View File

@@ -15,7 +15,7 @@ vim.api.nvim_set_keymap('n', '<leader>e', '<cmd>lua vim.diagnostic.open_float()<
vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
vim.api.nvim_set_keymap('n', '<leader>E', '<cmd>lua vim.diagnostic.set_loclist()<CR>', opts)
vim.api.nvim_set_keymap("n", "<leader>q", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
vim.api.nvim_set_keymap("n", "<leader>q", "<cmd>lua vim.lsp.buf.format{ async = true }<CR>", opts)
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
@@ -102,9 +102,19 @@ nvim_lsp.groovyls.setup ({
clangd_extensions.setup({
server = {
on_attach = on_attach,
root_pattern = {
'.clangd',
'.clang-tidy',
'.clang-format',
'compile_commands.json',
'compile_flags.txt',
'configure.ac',
}
},
inlay_hints = {
max_len_align = true,
max_len_align_padding = 3,
right_align = true,
}
})
-- nvim_lsp.clangd.setup(
@@ -137,7 +147,7 @@ nvim_lsp.pylsp.setup({
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { "cmake", "rust_analyzer" }
local servers = { "cmake", "rust_analyzer", "bashls" }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup({
on_attach = on_attach,

View File

@@ -33,6 +33,8 @@ cmp.setup({
{ name = 'calc' },
{ name = 'cmp_matlab' },
{ name = 'cmp_git' },
}, {
{ name = 'buffer', keyword_length = 5, max_item_count = 10, priority = -5 },
@@ -40,6 +42,19 @@ cmp.setup({
--experimental = {
-- native_menu = false
--}
sorting = {
comparators = {
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.recently_used,
require("clangd_extensions.cmp_scores"),
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
},
})
cmp.setup.cmdline('/', {

View File

@@ -1,23 +1,7 @@
let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons).
let g:nvim_tree_highlight_opened_files = 1 "0 by default, will enable folder and file icon highlight for opened files/directories.
let g:nvim_tree_root_folder_modifier = ':~' "This is the default. See :help filename-modifiers for more options
let g:nvim_tree_add_trailing = 1 "0 by default, append a trailing slash to folder names
let g:nvim_tree_group_empty = 1 " 0 by default, compact folders that only contain a single folder into one node in the file tree
let g:nvim_tree_icon_padding = ' ' "one space by default, used for rendering the space between the icon and the filename. Use with caution, it could break rendering if you set an empty string depending on your font.
let g:nvim_tree_symlink_arrow = ' >> ' " defaults to ' ➛ '. used as a separator between symlinks' source and target.
let g:nvim_tree_respect_buf_cwd = 0 "0 by default, will change cwd of nvim-tree to that of new buffer's when opening nvim-tree.
let g:nvim_tree_create_in_closed_folder = 0 "1 by default, When creating files, sets the path of a file when cursor is on a closed folder to the parent folder when 0, and inside the folder when 1.
let g:nvim_tree_refresh_wait = 1000 " control how often the tree can be refreshed, 1000 means the tree can be refresh once per 1000ms.
" Dictionary of buffer option names mapped to a list of option values that
" indicates to the window picker that the buffer's window should not be
" selectable.
let g:nvim_tree_special_files = { 'README.md': 1, 'Makefile': 1, 'MAKEFILE': 1 } " List of filenames that gets highlighted with NvimTreeSpecialFile
let g:nvim_tree_show_icons = {
\ 'git': 1,
\ 'folders': 1,
\ 'files': 1,
\ 'folder_arrows': 0,
\ }
"If 0, do not show the icons for one of 'git' 'folder' and 'files'
"1 by default, notice that if 'files' is 1, it will only display
"if nvim-web-devicons is installed and on your runtimepath.
@@ -26,29 +10,6 @@ let g:nvim_tree_show_icons = {
" default will show icon by default if no icon is provided
" default shows no icon by default
let g:nvim_tree_icons = {
\ 'default': '',
\ 'symlink': '',
\ 'git': {
\ 'unstaged': "✗",
\ 'staged': "✓",
\ 'unmerged': "",
\ 'renamed': "➜",
\ 'untracked': "★",
\ 'deleted': "",
\ 'ignored': "◌"
\ },
\ 'folder': {
\ 'arrow_open': "",
\ 'arrow_closed': "",
\ 'default': "",
\ 'open': "",
\ 'empty': "",
\ 'empty_open': "",
\ 'symlink': "",
\ 'symlink_open': "",
\ }
\ }
nnoremap <leader>tt :NvimTreeToggle<CR>
"nnoremap <leader>r :NvimTreeRefresh<CR>
@@ -71,6 +32,8 @@ require'nvim-tree'.setup {
open_on_tab = false,
hijack_cursor = true,
update_cwd = false,
respect_buf_cwd = false,
create_in_closed_folder = false,
hijack_directories = {
enable = true,
auto_open = true,
@@ -136,7 +99,50 @@ require'nvim-tree'.setup {
renderer = {
indent_markers = {
enable = true -- this option shows indent markers when folders are open
},
icons = {
show = {
git = true,
folder = true,
file = true,
folder_arrow = false,
},
glyphs = {
default = '',
symlink = '',
git = {
unstaged = "✗",
staged = "✓",
unmerged = "",
renamed = "➜",
untracked = "★",
deleted = "",
ignored = "◌"
},
folder = {
arrow_open = "",
arrow_closed = "",
default = "",
open = "",
empty = "",
empty_open = "",
symlink = "",
symlink_open = "",
}
},
padding = ' ',
symlink_arrow = ' -> ',
},
group_empty = true,
add_trailing = true,
highlight_git = true,
highlight_opened_files = 'icon',
root_folder_modifier = ':~',
special_files = {
'README.md',
'Makefile',
'MAKEFILE'
},
},
}
EOF

View File

@@ -5,7 +5,7 @@ ts = require'nvim-treesitter.configs'
ts.setup {
highlight = {
enable = true,
additional_vim_regex_highlighting = true,
additional_vim_regex_highlighting = false,
},
ensure_installed = {
"bash",

View File

@@ -1 +1,11 @@
let g:cmake_build_options = [ "-j10" ]
let g:cmake_jump_on_error = 0 " We do not want to focus the console
augroup vim-cmake-group
autocmd User CMakeBuildFailed :cfirst
augroup END
augroup vim-cmake-group
autocmd! User CMakeBuildSucceeded CMakeClose
augroup END

View File

@@ -51,6 +51,7 @@ Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/cmp-calc'
Plug 'joshzcold/cmp-jenkinsfile'
Plug 'petertriho/cmp-git'
Plug 'mstanciu552/cmp-matlab'
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
Plug 'quangnguyen30192/cmp-nvim-ultisnips'
" }}}
@@ -198,6 +199,8 @@ set undofile
"let mapleader = "\\"
nmap <space> <leader>
tnoremap <ESC><ESC> <C-\><C-n>
inoremap jj <ESC>
inoremap jk <ESC>
"inoremap :w<CR> <Esc>:w<CR>
@@ -256,3 +259,4 @@ let g:blamer_relative_time = 0
" gui settings "
""""""""""""""""""
set guifont=Monoid\ Nerd\ Font:h8
let g:neovide_cursor_vfx_mode = "pixiedust"