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
local on_attach = function(_, bufnr)
-- key mappings
local opts = {
buffer = bufnr,
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
})
end
-- local on_attach = function(client, bufnr)
-- -- key mappings
-- local opts = {
-- buffer = bufnr,
-- 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
-- })
-- end
-- Go
lspconfig.gopls.setup{
cmd = {"gopls", "serve"},
on_attach = on_attach,
filetypes = {"go", "gomod"},
settings = {
gopls = {
@ -96,13 +95,10 @@ lspconfig.gopls.setup{
}
-- C/C++
lspconfig.clangd.setup{
on_attach = on_attach,
}
lspconfig.clangd.setup{}
-- Lua
lspconfig.lua_ls.setup{
on_attach = on_attach,
settings = {
Lua = {
diagnostics = {globals = {'vim', 'opts'}},
@ -114,19 +110,13 @@ lspconfig.lua_ls.setup{
}
-- Rust
lspconfig.rust_analyzer.setup{
on_attach = on_attach,
}
lspconfig.rust_analyzer.setup{}
-- Python
lspconfig.pylsp.setup{
on_attach = on_attach,
}
lspconfig.pylsp.setup{}
-- TypeScript
lspconfig.tsserver.setup{
on_attach = on_attach,
}
lspconfig.tsserver.setup{}
-- Fix virtual text going off screen
vim.diagnostic.config({
@ -138,19 +128,43 @@ vim.diagnostic.config({
})
-- vim.api.nvim_create_autocmd('LspAttach', {
-- callback = function(ev)
-- 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,
-- })
vim.api.nvim_create_autocmd('LspAttach', {
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 }
-- -- 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