diff options
| author | Robert Günzler <r@gnzler.io> | 2021-11-08 02:53:20 +0100 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2021-11-08 02:53:20 +0100 |
| commit | a53229ca07a32fff9e4f01678d03392d90629c49 (patch) | |
| tree | d66707a11b2c3d224446179494ac687d31cbb7f9 /.vim | |
| parent | f41815dcd3c90eea41f5d5e9f28c3e78023b6306 (diff) | |
vim/lsp: enable ccls and don't format upstream repos
Diffstat (limited to '.vim')
| -rw-r--r-- | .vim/lua/lsp.lua | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/.vim/lua/lsp.lua b/.vim/lua/lsp.lua index 1b189d4..91e2e2e 100644 --- a/.vim/lua/lsp.lua +++ b/.vim/lua/lsp.lua @@ -56,7 +56,7 @@ local my_attach = function(client, bufnr) augroup { lsp_user = { - {'BufWritePre' , '*' , 'lua vim.lsp.buf.formatting_seq_sync(nil, 1000)'}, + {'BufWritePre' , '*' , 'lua require("lsp").format(vim.fn.expand("<afile>:p"))'}, {'BufWritePre' , '*.go' , 'lua vim.lsp.buf.code_action({ only = {"source.organizeImports"} })'}, -- {'CursorHold' , '*' , 'lua vim.lsp.diagnostic.show_line_diagnostics()'}, } @@ -140,11 +140,18 @@ local setup = function() {name='LspDiagnosticsSignHint', text='🞶'} }) - -- lsp.ccls.setup { - -- on_attach = my_attach, - -- on_exit = my_exit, - -- capabilities = caps, - -- } + lsp.ccls.setup { + on_attach = my_attach, + on_exit = my_exit, + capabilities = caps, + root_dir = lsp.util.root_pattern('.ccls','meson.build', 'Makefile','.git'), + init_options = { + compilationDatabaseDirectory = "build", + completion = { + filterAndSort = false, + } + } + } lsp.gopls.setup { on_attach = my_attach, @@ -204,12 +211,20 @@ local setup = function() on_attach = my_attach, on_exit = my_exit, capabilities = caps, - root_dir = lsp.util.root_pattern('.zk/'), + root_dir = lsp.util.root_pattern('.zk'), } end return { my_attach = my_attach, - setup = setup + setup = setup, + format = function(afile) + local doit = true + doit = doit and not string.match(afile, "^/home/robert/devel/upstream") + if doit then + print('Formatting using LSP:', afile) + vim.lsp.buf.formatting_seq_sync(nil, 1000) + end + end, } |