testing regular lsp attach

main
KeeganForelight 2 years ago
parent 06aeca8dfd
commit 34ed925a02

@ -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,19 +128,43 @@ vim.diagnostic.config({
}) })
-- vim.api.nvim_create_autocmd('LspAttach', { vim.api.nvim_create_autocmd('LspAttach', {
-- callback = function(ev) callback = function(ev)
-- local opts = { buffer = ev.buf } -- key mappings
-- -- error viewing local opts = {
-- vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts) buffer = ev.buf,
-- vim.keymap.set('n', '<leader>[d', vim.diagnostic.goto_prev, opts) noremap = true,
-- vim.keymap.set('n', '<leader>]d', vim.diagnostic.goto_next, opts) focusable = false,
-- -- def viewing/rename border = 'rounded',
-- vim.keymap.set('n', '<leader>gD', vim.lsp.buf.declaration, opts) source = 'always',
-- vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, opts) prefix = ' ',
-- vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts) scope = 'cursor',
-- vim.keymap.set('n', '<leader>H', vim.lsp.buf.hover, opts) close_events = { "BufLeave","CursorMoved","InsertEnter","FocusLost" },
-- end, }
-- }) -- 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 }
-- -- 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)
end,
})

Loading…
Cancel
Save