nvim: add config files
This commit is contained in:
43
nvim/lua/config/lsp.lua
Normal file
43
nvim/lua/config/lsp.lua
Normal file
@@ -0,0 +1,43 @@
|
||||
function show_diagnostic()
|
||||
for _, winid in pairs(vim.api.nvim_tabpage_list_wins(0)) do
|
||||
if vim.api.nvim_win_get_config(winid).zindex then
|
||||
return
|
||||
end
|
||||
end
|
||||
-- THIS IS FOR BUILTIN LSP
|
||||
vim.diagnostic.open_float(0, {
|
||||
scope = "cursor",
|
||||
focusable = false,
|
||||
close_events = {
|
||||
"CursorMoved",
|
||||
"CursorMovedI",
|
||||
"BufHidden",
|
||||
"InsertCharPre",
|
||||
"WinLeave",
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("lsp", { clear = true }),
|
||||
callback = function (args)
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
buffer = args.buf,
|
||||
callback = function ()
|
||||
vim.lsp.buf.format { async = false, id = args.data.client_id }
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
pattern = '*',
|
||||
callback = show_diagnostic
|
||||
})
|
||||
end
|
||||
})
|
||||
|
||||
vim.lsp.enable('clangd')
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
vim.lsp.config('clangd', {
|
||||
capabilities = capabilities
|
||||
})
|
||||
Reference in New Issue
Block a user