aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lua/lsp.lua
diff options
context:
space:
mode:
authorAlec Goncharow <alec@goncharow.dev>2024-01-09 14:28:13 -0500
committerAlec Goncharow <alec@goncharow.dev>2024-01-09 14:28:13 -0500
commit36b5ac02b91ffc4d6901c5031b0f73b57e334f70 (patch)
treec6488da4e48d376da28579ce40a57321cc15cadb /.config/nvim/lua/lsp.lua
parent67d40a9139547bb61fe3aacb54491b6e40a3cab8 (diff)
yak shaving
much to do about nothing, outlines from lspsage, some matching, some tpope plugins, flailing sql things might be too bloated but let's try it
Diffstat (limited to '.config/nvim/lua/lsp.lua')
-rw-r--r--.config/nvim/lua/lsp.lua73
1 files changed, 60 insertions, 13 deletions
diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua
index 1cbfb5e..632c355 100644
--- a/.config/nvim/lua/lsp.lua
+++ b/.config/nvim/lua/lsp.lua
@@ -1,5 +1,5 @@
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
-local opts = { noremap=true, silent=true }
+local opts = { noremap = true, silent = true }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
@@ -11,18 +11,17 @@ vim.lsp.set_log_level("debug")
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
- vim.api.nvim_buf_set_option(bufnr, "formatexpr", "v:lua.vim.lsp.formatexpr()")
- vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
- vim.api.nvim_buf_set_option(bufnr, "tagfunc", "v:lua.vim.lsp.tagfunc")
+ vim.api.nvim_buf_set_option(bufnr, "formatexpr", "v:lua.vim.lsp.formatexpr()")
+ vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
+ vim.api.nvim_buf_set_option(bufnr, "tagfunc", "v:lua.vim.lsp.tagfunc")
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
- local bufopts = { noremap=true, silent=true, buffer=bufnr }
+ local bufopts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
- vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function()
@@ -40,9 +39,9 @@ end
local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Setup rust_analyzer via rust-tools.nvim
require("rust-tools").setup({
- server = {
- capabilities = capabilities,
- on_attach = on_attach,
+ server = {
+ capabilities = capabilities,
+ on_attach = on_attach,
settings = {
['rust-analyzer'] = {
cargo = {
@@ -50,7 +49,7 @@ require("rust-tools").setup({
}
}
}
- }
+ }
})
-- https://github.com/ray-x/go.nvim#lsp-cmp-support
@@ -80,7 +79,7 @@ lspconfig['dotls'].setup({
})
-lspconfig.yamlls.setup{
+lspconfig.yamlls.setup {
settings = {
yaml = {
-- FIX mapKeyOrder warning
@@ -89,11 +88,59 @@ lspconfig.yamlls.setup{
}
}
+lspconfig.lua_ls.setup {
+ on_attach = on_attach,
+ capabilities = capabilities,
+ on_init = function(client)
+ local path = client.workspace_folders[1].name
+ if not vim.loop.fs_stat(path .. '/.luarc.json') and not vim.loop.fs_stat(path .. '/.luarc.jsonc') then
+ client.config.settings = vim.tbl_deep_extend('force', client.config.settings, {
+ Lua = {
+ runtime = {
+ -- Tell the language server which version of Lua you're using
+ -- (most likely LuaJIT in the case of Neovim)
+ version = 'LuaJIT'
+ },
+ -- Make the server aware of Neovim runtime files
+ workspace = {
+ checkThirdParty = false,
+ library = {
+ vim.env.VIMRUNTIME
+ -- "${3rd}/luv/library"
+ -- "${3rd}/busted/library",
+ }
+ -- or pull in all of 'runtimepath'. NOTE: this is a lot slower
+ -- library = vim.api.nvim_get_runtime_file("", true)
+ }
+ }
+ })
+
+ client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
+ end
+ return true
+ end
+}
+
+lspconfig.sqls.setup {
+ on_attach = function(client, bufnr)
+ require('sqls').on_attach(client, bufnr)
+ end,
+ sqls = {
+ connections = {
+ {
+ driver = 'sqlite3',
+ dataSourceName = '/home/algo/test.sqlite3',
+ },
+ },
+ },
+}
+
-- close quickfix menu after selecting choice
vim.api.nvim_create_autocmd(
"FileType", {
- pattern={"qf"},
- command=[[nnoremap <buffer> <CR> <CR>:cclose<CR>]]})
+ pattern = { "qf" },
+ command = [[nnoremap <buffer> <CR> <CR>:cclose<CR>]]
+ })
vim.api.nvim_create_autocmd('BufWritePre', {
pattern = '*.go',