[Feature] Make common_on_attach configurable (#1024)

This commit is contained in:
kylo252 2021-07-20 23:34:44 +02:00 committed by GitHub
parent 796148fb00
commit 840e07c7fc
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 3 deletions

View file

@ -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'

View file

@ -73,6 +73,7 @@ O = {
document_highlight = true,
popup_border = "single",
default_keybinds = true,
on_attach_callback = nil,
},
disabled_built_ins = {

View file

@ -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, _)

View file

@ -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

View file

@ -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