diff --git a/.vim/nvim.lua b/.vim/nvim.lua index 42deba4..3f09002 100644 --- a/.vim/nvim.lua +++ b/.vim/nvim.lua @@ -9,6 +9,22 @@ end nvim_lsp.rust_analyzer.setup({ on_attach=on_attach }) nvim_lsp.gopls.setup({ on_attach=on_attach }) nvim_lsp.pyright.setup({ on_attach=on_attach }) +nvim_lsp.clangd.setup({ on_attach=on_attach }) + +nvim_lsp.efm.setup { + init_options = {documentFormatting = true}, + settings = { + rootMarkers = {".git/"}, + languages = { + lua = { + { formatCommand = "lua-format -i", formatStdin = true } + }, + python = { + { formatCommand = 'black --quiet -', formatStdin = true } + } + } + } +} -- Enable diagnostics vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( diff --git a/.vimrc b/.vimrc index f160c86..0ad1687 100644 --- a/.vimrc +++ b/.vimrc @@ -304,6 +304,10 @@ set updatetime=500 " Show diagnostic popup on cursor hold autocmd CursorHold * lua vim.lsp.diagnostic.show_line_diagnostics({show_header = false, focusable = false}) +" Autoformat on save +autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 1000) +autocmd BufWritePre *.py lua vim.lsp.buf.formatting_sync(nil, 1000) + " Goto previous/next diagnostic warning/error nnoremap g[ lua vim.lsp.diagnostic.goto_prev() nnoremap g] lua vim.lsp.diagnostic.goto_next()