|
|
@ -51,39 +51,38 @@ local lspconfig = require('lspconfig')
|
|
|
|
|
|
|
|
|
|
|
|
vim.o.updatetime = 250
|
|
|
|
vim.o.updatetime = 250
|
|
|
|
|
|
|
|
|
|
|
|
local on_attach = function(_, bufnr)
|
|
|
|
-- local on_attach = function(client, bufnr)
|
|
|
|
-- key mappings
|
|
|
|
-- -- key mappings
|
|
|
|
local opts = {
|
|
|
|
-- local opts = {
|
|
|
|
buffer = bufnr,
|
|
|
|
-- buffer = bufnr,
|
|
|
|
noremap = true,
|
|
|
|
-- noremap = true,
|
|
|
|
focusable = false,
|
|
|
|
-- focusable = false,
|
|
|
|
border = 'rounded',
|
|
|
|
-- border = 'rounded',
|
|
|
|
source = 'always',
|
|
|
|
-- source = 'always',
|
|
|
|
prefix = ' ',
|
|
|
|
-- prefix = ' ',
|
|
|
|
scope = 'cursor',
|
|
|
|
-- scope = 'cursor',
|
|
|
|
close_events = { "BufLeave","CursorMoved","InsertEnter","FocusLost" },
|
|
|
|
-- close_events = { "BufLeave","CursorMoved","InsertEnter","FocusLost" },
|
|
|
|
}
|
|
|
|
-- }
|
|
|
|
-- error viewing
|
|
|
|
-- -- error viewing
|
|
|
|
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
|
|
|
|
-- vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
|
|
|
|
vim.keymap.set('n', '<leader>[d', vim.diagnostic.goto_prev, opts)
|
|
|
|
-- vim.keymap.set('n', '<leader>[d', vim.diagnostic.goto_prev, opts)
|
|
|
|
vim.keymap.set('n', '<leader>]d', vim.diagnostic.goto_next, opts)
|
|
|
|
-- vim.keymap.set('n', '<leader>]d', vim.diagnostic.goto_next, opts)
|
|
|
|
-- def viewing/rename
|
|
|
|
-- -- def viewing/rename
|
|
|
|
vim.keymap.set('n', '<leader>gD', vim.lsp.buf.declaration, opts)
|
|
|
|
-- vim.keymap.set('n', '<leader>gD', vim.lsp.buf.declaration, opts)
|
|
|
|
vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts)
|
|
|
|
-- vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts)
|
|
|
|
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
|
|
|
-- vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
|
|
|
vim.keymap.set('n', '<leader>H', vim.lsp.buf.hover, opts)
|
|
|
|
-- vim.keymap.set('n', '<leader>H', vim.lsp.buf.hover, opts)
|
|
|
|
-- auto hover for error viewing
|
|
|
|
-- -- auto hover for error viewing
|
|
|
|
vim.api.nvim_create_autocmd("CursorHold", {
|
|
|
|
-- vim.api.nvim_create_autocmd("CursorHold", {
|
|
|
|
callback = function()
|
|
|
|
-- callback = function()
|
|
|
|
vim.diagnostic.open_float(nil, opts)
|
|
|
|
-- vim.diagnostic.open_float(nil, opts)
|
|
|
|
end
|
|
|
|
-- end
|
|
|
|
})
|
|
|
|
-- })
|
|
|
|
end
|
|
|
|
-- end
|
|
|
|
|
|
|
|
|
|
|
|
-- Go
|
|
|
|
-- Go
|
|
|
|
lspconfig.gopls.setup{
|
|
|
|
lspconfig.gopls.setup{
|
|
|
|
cmd = {"gopls", "serve"},
|
|
|
|
cmd = {"gopls", "serve"},
|
|
|
|
on_attach = on_attach,
|
|
|
|
|
|
|
|
filetypes = {"go", "gomod"},
|
|
|
|
filetypes = {"go", "gomod"},
|
|
|
|
settings = {
|
|
|
|
settings = {
|
|
|
|
gopls = {
|
|
|
|
gopls = {
|
|
|
@ -96,13 +95,10 @@ lspconfig.gopls.setup{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-- C/C++
|
|
|
|
-- C/C++
|
|
|
|
lspconfig.clangd.setup{
|
|
|
|
lspconfig.clangd.setup{}
|
|
|
|
on_attach = on_attach,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Lua
|
|
|
|
-- Lua
|
|
|
|
lspconfig.lua_ls.setup{
|
|
|
|
lspconfig.lua_ls.setup{
|
|
|
|
on_attach = on_attach,
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
settings = {
|
|
|
|
Lua = {
|
|
|
|
Lua = {
|
|
|
|
diagnostics = {globals = {'vim', 'opts'}},
|
|
|
|
diagnostics = {globals = {'vim', 'opts'}},
|
|
|
@ -114,19 +110,13 @@ lspconfig.lua_ls.setup{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-- Rust
|
|
|
|
-- Rust
|
|
|
|
lspconfig.rust_analyzer.setup{
|
|
|
|
lspconfig.rust_analyzer.setup{}
|
|
|
|
on_attach = on_attach,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Python
|
|
|
|
-- Python
|
|
|
|
lspconfig.pylsp.setup{
|
|
|
|
lspconfig.pylsp.setup{}
|
|
|
|
on_attach = on_attach,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- TypeScript
|
|
|
|
-- TypeScript
|
|
|
|
lspconfig.tsserver.setup{
|
|
|
|
lspconfig.tsserver.setup{}
|
|
|
|
on_attach = on_attach,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Fix virtual text going off screen
|
|
|
|
-- Fix virtual text going off screen
|
|
|
|
vim.diagnostic.config({
|
|
|
|
vim.diagnostic.config({
|
|
|
@ -138,8 +128,34 @@ vim.diagnostic.config({
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- vim.api.nvim_create_autocmd('LspAttach', {
|
|
|
|
vim.api.nvim_create_autocmd('LspAttach', {
|
|
|
|
-- callback = function(ev)
|
|
|
|
callback = function(ev)
|
|
|
|
|
|
|
|
-- key mappings
|
|
|
|
|
|
|
|
local opts = {
|
|
|
|
|
|
|
|
buffer = ev.buf,
|
|
|
|
|
|
|
|
noremap = true,
|
|
|
|
|
|
|
|
focusable = false,
|
|
|
|
|
|
|
|
border = 'rounded',
|
|
|
|
|
|
|
|
source = 'always',
|
|
|
|
|
|
|
|
prefix = ' ',
|
|
|
|
|
|
|
|
scope = 'cursor',
|
|
|
|
|
|
|
|
close_events = { "BufLeave","CursorMoved","InsertEnter","FocusLost" },
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
-- error viewing
|
|
|
|
|
|
|
|
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
|
|
|
|
|
|
|
|
vim.keymap.set('n', '<leader>[d', vim.diagnostic.goto_prev, opts)
|
|
|
|
|
|
|
|
vim.keymap.set('n', '<leader>]d', vim.diagnostic.goto_next, opts)
|
|
|
|
|
|
|
|
-- def viewing/rename
|
|
|
|
|
|
|
|
vim.keymap.set('n', '<leader>gD', vim.lsp.buf.declaration, opts)
|
|
|
|
|
|
|
|
vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts)
|
|
|
|
|
|
|
|
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
|
|
|
|
|
|
|
vim.keymap.set('n', '<leader>H', vim.lsp.buf.hover, opts)
|
|
|
|
|
|
|
|
-- auto hover for error viewing
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd("CursorHold", {
|
|
|
|
|
|
|
|
callback = function()
|
|
|
|
|
|
|
|
vim.diagnostic.open_float(nil, opts)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
})
|
|
|
|
-- local opts = { buffer = ev.buf }
|
|
|
|
-- local opts = { buffer = ev.buf }
|
|
|
|
-- -- error viewing
|
|
|
|
-- -- error viewing
|
|
|
|
-- vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
|
|
|
|
-- vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
|
|
|
@ -150,7 +166,5 @@ vim.diagnostic.config({
|
|
|
|
-- vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts)
|
|
|
|
-- vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts)
|
|
|
|
-- vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
|
|
|
-- vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
|
|
|
-- vim.keymap.set('n', '<leader>H', vim.lsp.buf.hover, opts)
|
|
|
|
-- vim.keymap.set('n', '<leader>H', vim.lsp.buf.hover, opts)
|
|
|
|
-- end,
|
|
|
|
end,
|
|
|
|
-- })
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|