diff --git a/home/private_dot_config/nvim/lua/plugins/language/go.lua b/home/private_dot_config/nvim/lua/plugins/language/go.lua new file mode 100644 index 0000000..f168fa5 --- /dev/null +++ b/home/private_dot_config/nvim/lua/plugins/language/go.lua @@ -0,0 +1,93 @@ +-- adapted from https://www.lazyvim.org/extras/lang/go + +return { + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + vim.list_extend(opts.ensure_installed, { + "go", + "gomod", + "gowork", + "gosum", + }) + end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + gopls = { + keys = { + -- Workaround for the lack of a DAP strategy in neotest-go: https://github.com/nvim-neotest/neotest-go/issues/12 + { "td", "lua require('dap-go').debug_test()", desc = "Debug Nearest (Go)" }, + }, + settings = { + gopls = { + gofumpt = true, + codelenses = { + gc_details = false, + generate = true, + regenerate_cgo = true, + run_govulncheck = true, + test = true, + tidy = true, + upgrade_dependency = true, + vendor = true, + }, + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, + analyses = { + fieldalignment = true, + nilness = true, + unusedparams = true, + unusedwrite = true, + useany = true, + }, + usePlaceholders = true, + completeUnimported = true, + staticcheck = true, + directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" }, + semanticTokens = true, + }, + }, + }, + }, + setup = { + gopls = function(_, opts) + -- workaround for gopls not supporting semanticTokensProvider + -- https://github.com/golang/go/issues/54531#issuecomment-1464982242 + LazyVim.lsp.on_attach(function(client, _) + if client.name == "gopls" then + if not client.server_capabilities.semanticTokensProvider then + local semantic = client.config.capabilities.textDocument.semanticTokens + client.server_capabilities.semanticTokensProvider = { + full = true, + legend = { + tokenTypes = semantic.tokenTypes, + tokenModifiers = semantic.tokenModifiers, + }, + range = true, + } + end + end + end) + -- end workaround + end, + }, + }, + }, + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "goimports", "gofumpt", "gomodifytags", "impl", "delve" }) + end, + }, +} diff --git a/home/private_dot_config/nvim/lua/plugins/language/nix.lua b/home/private_dot_config/nvim/lua/plugins/language/nix.lua new file mode 100644 index 0000000..2611c59 --- /dev/null +++ b/home/private_dot_config/nvim/lua/plugins/language/nix.lua @@ -0,0 +1,16 @@ +return { + require("util").setup_lang({ treesitter = { "nix" } }), + { + "neovim/nvim-lspconfig", + opts = { + servers = { + nixd = { + mason = false, + }, + -- nil_ls = { + -- mason = false, + -- }, + }, + }, + }, +} diff --git a/home/private_dot_config/nvim/lua/plugins/language/nu.lua b/home/private_dot_config/nvim/lua/plugins/language/nu.lua new file mode 100644 index 0000000..4eeaffa --- /dev/null +++ b/home/private_dot_config/nvim/lua/plugins/language/nu.lua @@ -0,0 +1,7 @@ +return { + "nvim-treesitter/nvim-treesitter", + dependencies = { + { "nushell/tree-sitter-nu" }, + }, + build = ":TSUpdate", +} diff --git a/home/private_dot_config/nvim/lua/plugins/language/roc.lua b/home/private_dot_config/nvim/lua/plugins/language/roc.lua new file mode 100644 index 0000000..41e4bb6 --- /dev/null +++ b/home/private_dot_config/nvim/lua/plugins/language/roc.lua @@ -0,0 +1,30 @@ +-- make .roc files have the correct filetype +vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { + pattern = { "*.roc" }, + command = "set filetype=roc", +}) + +-- -- add roc tree-sitter +-- local parsers = require("nvim-treesitter.parsers").get_parser_configs() +-- +-- parsers.roc = { +-- install_info = { +-- url = "https://github.com/faldor20/tree-sitter-roc", +-- files = { "src/parser.c", "src/scanner.c" }, +-- }, +-- } + +return { + { "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = { "roc" } } + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + roc_ls = { + mason = false, + }, + }, + }, + }, +} diff --git a/home/private_dot_config/nvim/lua/plugins/language/rust.lua b/home/private_dot_config/nvim/lua/plugins/language/rust.lua new file mode 100644 index 0000000..6c22d9d --- /dev/null +++ b/home/private_dot_config/nvim/lua/plugins/language/rust.lua @@ -0,0 +1,99 @@ +-- adapted from https://www.lazyvim.org/extras/lang/rust +return { + { + "hrsh7th/nvim-cmp", + opts = function(_, opts) + opts.sources = opts.sources or {} + table.insert(opts.sources, { name = "crates" }) + end, + }, + { + "Saecki/crates.nvim", + event = { "BufRead Cargo.toml" }, + opts = { + completions = { + cmp = { enabled = true }, + }, + }, + }, + { + + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "ron", "rust", "toml" }) + end, + }, + { + "mrcjkb/rustaceanvim", + version = "^4", -- Recommended + ft = { "rust" }, + opts = { + server = { + on_attach = function(_, bufnr) + vim.keymap.set("n", "cR", function() + vim.cmd.RustLsp("codeAction") + end, { desc = "Code Action", buffer = bufnr }) + vim.keymap.set("n", "dr", function() + vim.cmd.RustLsp("debuggables") + end, { desc = "Rust debuggables", buffer = bufnr }) + end, + default_settings = { + -- rust-analyzer language server configuration + ["rust-analyzer"] = { + cargo = { + allFeatures = true, + loadOutDirsFromCheck = true, + runBuildScripts = true, + }, + -- Add clippy lints for Rust. + checkOnSave = { + allFeatures = true, + command = "clippy", + extraArgs = { "--no-deps" }, + }, + procMacro = { + enable = true, + ignored = { + ["async-trait"] = { "async_trait" }, + ["napi-derive"] = { "napi" }, + ["async-recursion"] = { "async_recursion" }, + }, + }, + }, + }, + }, + }, + config = function(_, opts) + vim.g.rustaceanvim = vim.tbl_deep_extend("keep", vim.g.rustaceanvim or {}, opts or {}) + end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + rust_analyzer = {}, + taplo = { + keys = { + { + "K", + function() + if vim.fn.expand("%:t") == "Cargo.toml" and require("crates").popup_available() then + require("crates").show_popup() + else + vim.lsp.buf.hover() + end + end, + desc = "Show Crate Documentation", + }, + }, + }, + }, + setup = { + rust_analyzer = function() + return true + end, + }, + }, + }, +} diff --git a/home/private_dot_config/nvim/lua/plugins/language/zig.lua b/home/private_dot_config/nvim/lua/plugins/language/zig.lua new file mode 100644 index 0000000..c10d9d7 --- /dev/null +++ b/home/private_dot_config/nvim/lua/plugins/language/zig.lua @@ -0,0 +1,20 @@ +-- adapted from https://www.lazyvim.org/extras/lang/rust +return { + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "zig" }) + end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + zls = { + mason = false, + }, + }, + }, + }, +}