mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-20 18:45:08 +02:00
[Feature] Make common_on_attach configurable (#1024)
This commit is contained in:
parent
796148fb00
commit
840e07c7fc
5 changed files with 40 additions and 3 deletions
10
README.md
10
README.md
|
@ -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'
|
||||
|
|
|
@ -73,6 +73,7 @@ O = {
|
|||
document_highlight = true,
|
||||
popup_border = "single",
|
||||
default_keybinds = true,
|
||||
on_attach_callback = nil,
|
||||
},
|
||||
|
||||
disabled_built_ins = {
|
||||
|
|
|
@ -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, _)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue