diff options
| author | kylo252 <[email protected]> | 2021-07-20 23:34:44 +0200 | 
|---|---|---|
| committer | GitHub <[email protected]> | 2021-07-21 02:04:44 +0430 | 
| commit | 840e07c7fc742415796027e32df19f315ddcf912 (patch) | |
| tree | 583c0f4c4f2dae36eb0dcba0c95be8c1d373152b | |
| parent | 796148fb008622bda8b4a0d365efde00b7b30a5a (diff) | |
[Feature] Make common_on_attach configurable (#1024)
| -rw-r--r-- | README.md | 10 | ||||
| -rw-r--r-- | lua/default-config.lua | 1 | ||||
| -rw-r--r-- | lua/lsp/init.lua | 10 | ||||
| -rw-r--r-- | utils/installer/lv-config.example-no-ts.lua | 11 | ||||
| -rw-r--r-- | utils/installer/lv-config.example.lua | 11 | 
5 files changed, 40 insertions, 3 deletions
| @@ -108,6 +108,16 @@ O.treesitter.ensure_installed = "all"  O.treesitter.ignore_install = {"haskell"}  O.treesitter.highlight.enabled = true +-- you can set a custom on_attach function that will be used for all the language servers +-- See <https://github.com/neovim/nvim-lspconfig#keybindings-and-completion> +-- O.lsp.on_attach_callback = function(client, bufnr) +--   local function buf_set_option(...) +--     vim.api.nvim_buf_set_option(bufnr, ...) +--   end +--   --Enable completion triggered by <c-x><c-o> +--   buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") +-- end +  -- lua  O.lang.lua.autoformat = false  O.lang.lua.formatter = 'lua-format' diff --git a/lua/default-config.lua b/lua/default-config.lua index a04db869..aaba1829 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -73,6 +73,7 @@ O = {      document_highlight = true,      popup_border = "single",      default_keybinds = true, +    on_attach_callback = nil,    },    disabled_built_ins = { diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 7e6982b5..7884f763 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -111,7 +111,10 @@ autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]]  -- Java  -- autocmd FileType java nnoremap ca <Cmd>lua require('jdtls').code_action()<CR> -local function documentHighlight(client, _) +local function lsp_highlight_document(client) +  if O.lsp.document_highlight == false then +    return -- we don't need further +  end    -- Set autocommands conditional on server_capabilities    if client.resolved_capabilities.document_highlight then      vim.api.nvim_exec( @@ -197,9 +200,10 @@ function lsp_config.PeekImplementation()  end  function lsp_config.common_on_attach(client, bufnr) -  if O.lsp.document_highlight then -    documentHighlight(client, bufnr) +  if O.lsp.on_attach_callback then +    O.lsp.on_attach_callback(client, bufnr)    end +  lsp_highlight_document(client)  end  function lsp_config.tsserver_on_attach(client, _) diff --git a/utils/installer/lv-config.example-no-ts.lua b/utils/installer/lv-config.example-no-ts.lua index d52c61bc..4016582c 100644 --- a/utils/installer/lv-config.example-no-ts.lua +++ b/utils/installer/lv-config.example-no-ts.lua @@ -50,6 +50,17 @@ O.treesitter.ensure_installed = {}  O.treesitter.ignore_install = { "haskell" }  O.treesitter.highlight.enabled = true +-- generic LSP settings +-- you can set a custom on_attach function that will be used for all the language servers +-- See <https://github.com/neovim/nvim-lspconfig#keybindings-and-completion> +-- O.lsp.on_attach_callback = function(client, bufnr) +--   local function buf_set_option(...) +--     vim.api.nvim_buf_set_option(bufnr, ...) +--   end +--   --Enable completion triggered by <c-x><c-o> +--   buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") +-- end +  -- python  O.lang.python.diagnostics.virtual_text = true  O.lang.python.analysis.use_library_code_types = true diff --git a/utils/installer/lv-config.example.lua b/utils/installer/lv-config.example.lua index 0e1a4a26..5754b160 100644 --- a/utils/installer/lv-config.example.lua +++ b/utils/installer/lv-config.example.lua @@ -50,6 +50,17 @@ O.treesitter.ensure_installed = "maintained"  O.treesitter.ignore_install = { "haskell" }  O.treesitter.highlight.enabled = true +-- generic LSP settings +-- you can set a custom on_attach function that will be used for all the language servers +-- See <https://github.com/neovim/nvim-lspconfig#keybindings-and-completion> +-- O.lsp.on_attach_callback = function(client, bufnr) +--   local function buf_set_option(...) +--     vim.api.nvim_buf_set_option(bufnr, ...) +--   end +--   --Enable completion triggered by <c-x><c-o> +--   buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") +-- end +  -- python  O.lang.python.diagnostics.virtual_text = true  O.lang.python.analysis.use_library_code_types = true | 
