summary refs log tree commit diff
path: root/.vim/lua
diff options
context:
space:
mode:
Diffstat (limited to '.vim/lua')
-rw-r--r--.vim/lua/lsp.lua31
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,
 }