more refactoring of lspconfig
This commit is contained in:
parent
db11ddc6c5
commit
f25db8737d
@ -1,4 +1,4 @@
|
|||||||
local lspKeys = function(bufnr)
|
local lspKeys = function(client, bufnr)
|
||||||
local tele_builtins = require('telescope.builtin')
|
local tele_builtins = require('telescope.builtin')
|
||||||
local options = { noremap = true, silent = false, buffer = bufnr }
|
local options = { noremap = true, silent = false, buffer = bufnr }
|
||||||
vim.keymap.set('n', '<space>,', vim.diagnostic.goto_prev,
|
vim.keymap.set('n', '<space>,', vim.diagnostic.goto_prev,
|
||||||
@ -35,19 +35,6 @@ local lspKeys = function(bufnr)
|
|||||||
vim.tbl_extend('error', options, { desc = 'Diagnostics' }))
|
vim.tbl_extend('error', options, { desc = 'Diagnostics' }))
|
||||||
vim.keymap.set('n', '<A-o>', '<cmd>ClangdSwitchSourceHeader<CR>',
|
vim.keymap.set('n', '<A-o>', '<cmd>ClangdSwitchSourceHeader<CR>',
|
||||||
vim.tbl_extend('error', options, { desc = 'Switch Source/Header' }))
|
vim.tbl_extend('error', options, { desc = 'Switch Source/Header' }))
|
||||||
end
|
|
||||||
|
|
||||||
local on_attach = function(client, bufnr)
|
|
||||||
local function buf_set_option(...)
|
|
||||||
vim.api.nvim_buf_set_option(bufnr, ...)
|
|
||||||
end
|
|
||||||
|
|
||||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
||||||
vim.api.nvim_buf_set_option(0, 'formatexpr', 'v:lua.vim.lsp.formatexpr()')
|
|
||||||
|
|
||||||
lspKeys(bufnr)
|
|
||||||
|
|
||||||
-- vim.cmd([[autocmd CursorHold <buffer> lua OpenDiagFloat()]])
|
|
||||||
|
|
||||||
-- Set some keybinds conditional on server capabilities
|
-- Set some keybinds conditional on server capabilities
|
||||||
if client.server_capabilities.documentFormattingProvider then
|
if client.server_capabilities.documentFormattingProvider then
|
||||||
@ -62,9 +49,10 @@ local on_attach = function(client, bufnr)
|
|||||||
end,
|
end,
|
||||||
{ noremap = true, silent = false, desc = 'Format visual', buffer = bufnr })
|
{ noremap = true, silent = false, desc = 'Format visual', buffer = bufnr })
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local document_highlight = function(bufnr)
|
||||||
-- Set autocommands conditional on server_capabilities
|
-- Set autocommands conditional on server_capabilities
|
||||||
if client.server_capabilities.documentHighlightProvider then
|
|
||||||
local group = vim.api.nvim_create_augroup('lsp_document_highlight', { clear = false })
|
local group = vim.api.nvim_create_augroup('lsp_document_highlight', { clear = false })
|
||||||
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
|
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
|
||||||
callback = function()
|
callback = function()
|
||||||
@ -94,6 +82,20 @@ local on_attach = function(client, bufnr)
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local on_attach = function(client, bufnr)
|
||||||
|
local function buf_set_option(...)
|
||||||
|
vim.api.nvim_buf_set_option(bufnr, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
vim.api.nvim_buf_set_option(0, 'formatexpr', 'v:lua.vim.lsp.formatexpr()')
|
||||||
|
|
||||||
|
lspKeys(client, bufnr)
|
||||||
|
|
||||||
|
if client.server_capabilities.documentHighlightProvider then
|
||||||
|
document_highlight(bufnr)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user