Mason no worky and I shouldve known, but I am big dumb so

This commit is contained in:
Tyler Kelley 2024-05-15 23:59:01 -05:00
parent 111cd7e317
commit e98fcf127b
3 changed files with 16 additions and 169 deletions

View File

@ -1,124 +1,8 @@
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
-- import mason_lspconfig plugin require'lspconfig'.pyright.setup{}
local mason_lspconfig = require("mason-lspconfig") require'lspconfig'.nil_ls.setup{}
require'lspconfig'.marksman.setup{}
-- import cmp-nvim-lsp plugin require'lspconfig'.rust_analyzer.setup{}
local cmp_nvim_lsp = require("cmp_nvim_lsp") require'lspconfig'.yamlls.setup{}
require'lspconfig'.bashls.setup{}
local keymap = vim.keymap -- for conciseness
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf, silent = true }
-- set keybinds
opts.desc = "Show LSP references"
keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references
opts.desc = "Go to declaration"
keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration
opts.desc = "Show LSP definitions"
keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions
opts.desc = "Show LSP implementations"
keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations
opts.desc = "Show LSP type definitions"
keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions
opts.desc = "See available code actions"
keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection
opts.desc = "Smart rename"
keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename
opts.desc = "Show buffer diagnostics"
keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file
opts.desc = "Show line diagnostics"
keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line
opts.desc = "Go to previous diagnostic"
keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer
opts.desc = "Go to next diagnostic"
keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer
opts.desc = "Show documentation for what is under cursor"
keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor
opts.desc = "Restart LSP"
keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary
end,
})
-- used to enable autocompletion (assign to every lsp server config)
local capabilities = cmp_nvim_lsp.default_capabilities()
-- Change the Diagnostic symbols in the sign column (gutter)
-- (not in youtube nvim video)
local signs = { Error = "", Warn = "", Hint = "󰠠 ", Info = "" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end
mason_lspconfig.setup_handlers({
-- default handler for installed servers
function(server_name)
lspconfig[server_name].setup({
capabilities = capabilities,
})
end,
["svelte"] = function()
-- configure svelte server
lspconfig["svelte"].setup({
capabilities = capabilities,
on_attach = function(client, bufnr)
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = { "*.js", "*.ts" },
callback = function(ctx)
-- Here use ctx.match instead of ctx.file
client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.match })
end,
})
end,
})
end,
["graphql"] = function()
-- configure graphql language server
lspconfig["graphql"].setup({
capabilities = capabilities,
filetypes = { "graphql", "gql", "svelte", "typescriptreact", "javascriptreact" },
})
end,
["emmet_ls"] = function()
-- configure emmet language server
lspconfig["emmet_ls"].setup({
capabilities = capabilities,
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
})
end,
["lua_ls"] = function()
-- configure lua server (with special settings)
lspconfig["lua_ls"].setup({
capabilities = capabilities,
settings = {
Lua = {
-- make the language server recognize "vim" global
diagnostics = {
globals = { "vim" },
},
completion = {
callSnippet = "Replace",
},
},
},
})
end,
})

View File

@ -1,43 +0,0 @@
local mason = require("mason")
-- import mason-lspconfig
local mason_lspconfig = require("mason-lspconfig")
-- enable mason and configure icons
mason.setup({
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
})
mason_lspconfig.setup({
-- list of servers for mason to install
ensure_installed = {
"bashls",
"docker",
"docker_compose_language_service",
"gopls",
"jsonls",
"markdown_oxide",
"taplo",
"tailwindcss",
"yamlls",
"rnix",
"rust_analyzer",
"sqlls",
"tsserver",
"html",
"cssls",
"tailwindcss",
"svelte",
"lua_ls",
"graphql",
"emmet_ls",
"prismals",
"pyright",
},
})

View File

@ -182,7 +182,16 @@ in
withNodeJs = true; withNodeJs = true;
extraPackages = with pkgs; [ extraPackages = with pkgs; [
lua-language-server lua-language-server
go gopls
xclip
wl-clipboard
luajitPackages.lua-lsp
nil
rust-analyzer
nodePackages.bash-language-server
yaml-language-server
pyright
marksman
]; ];
plugins = with pkgs.vimPlugins; [ plugins = with pkgs.vimPlugins; [
alpha-nvim alpha-nvim
@ -217,8 +226,6 @@ in
nvim-tree-lua nvim-tree-lua
telescope-fzf-native-nvim telescope-fzf-native-nvim
vim-tmux-navigator vim-tmux-navigator
mason-nvim
mason-lspconfig-nvim
]; ];
extraLuaConfig = '' extraLuaConfig = ''
${builtins.readFile ../../config/nvim/options.lua} ${builtins.readFile ../../config/nvim/options.lua}
@ -230,7 +237,6 @@ in
${builtins.readFile ../../config/nvim/plugins/cmp.lua} ${builtins.readFile ../../config/nvim/plugins/cmp.lua}
${builtins.readFile ../../config/nvim/plugins/lsp.lua} ${builtins.readFile ../../config/nvim/plugins/lsp.lua}
${builtins.readFile ../../config/nvim/plugins/nvim-tree.lua} ${builtins.readFile ../../config/nvim/plugins/nvim-tree.lua}
${builtins.readFile ../../config/nvim/plugins/mason.lua}
${builtins.readFile ../../config/nvim/plugins/telescope.lua} ${builtins.readFile ../../config/nvim/plugins/telescope.lua}
${builtins.readFile ../../config/nvim/plugins/todo-comments.lua} ${builtins.readFile ../../config/nvim/plugins/todo-comments.lua}
${builtins.readFile ../../config/nvim/plugins/treesitter.lua} ${builtins.readFile ../../config/nvim/plugins/treesitter.lua}