add a bunch of language specific configs

This commit is contained in:
Daylin Morgan 2024-06-12 10:25:28 -05:00
parent d9065b65f2
commit b8b1fec194
Signed by: daylin
GPG key ID: 950D13E9719334AD
6 changed files with 265 additions and 0 deletions

View file

@ -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
{ "<leader>td", "<cmd>lua require('dap-go').debug_test()<CR>", 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,
},
}

View file

@ -0,0 +1,16 @@
return {
require("util").setup_lang({ treesitter = { "nix" } }),
{
"neovim/nvim-lspconfig",
opts = {
servers = {
nixd = {
mason = false,
},
-- nil_ls = {
-- mason = false,
-- },
},
},
},
}

View file

@ -0,0 +1,7 @@
return {
"nvim-treesitter/nvim-treesitter",
dependencies = {
{ "nushell/tree-sitter-nu" },
},
build = ":TSUpdate",
}

View file

@ -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,
},
},
},
},
}

View file

@ -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", "<leader>cR", function()
vim.cmd.RustLsp("codeAction")
end, { desc = "Code Action", buffer = bufnr })
vim.keymap.set("n", "<leader>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,
},
},
},
}

View file

@ -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,
},
},
},
},
}