add a bunch of language specific configs
This commit is contained in:
parent
d9065b65f2
commit
b8b1fec194
6 changed files with 265 additions and 0 deletions
93
home/private_dot_config/nvim/lua/plugins/language/go.lua
Normal file
93
home/private_dot_config/nvim/lua/plugins/language/go.lua
Normal 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,
|
||||
},
|
||||
}
|
16
home/private_dot_config/nvim/lua/plugins/language/nix.lua
Normal file
16
home/private_dot_config/nvim/lua/plugins/language/nix.lua
Normal file
|
@ -0,0 +1,16 @@
|
|||
return {
|
||||
require("util").setup_lang({ treesitter = { "nix" } }),
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = {
|
||||
servers = {
|
||||
nixd = {
|
||||
mason = false,
|
||||
},
|
||||
-- nil_ls = {
|
||||
-- mason = false,
|
||||
-- },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
7
home/private_dot_config/nvim/lua/plugins/language/nu.lua
Normal file
7
home/private_dot_config/nvim/lua/plugins/language/nu.lua
Normal file
|
@ -0,0 +1,7 @@
|
|||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
dependencies = {
|
||||
{ "nushell/tree-sitter-nu" },
|
||||
},
|
||||
build = ":TSUpdate",
|
||||
}
|
30
home/private_dot_config/nvim/lua/plugins/language/roc.lua
Normal file
30
home/private_dot_config/nvim/lua/plugins/language/roc.lua
Normal 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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
99
home/private_dot_config/nvim/lua/plugins/language/rust.lua
Normal file
99
home/private_dot_config/nvim/lua/plugins/language/rust.lua
Normal 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,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
20
home/private_dot_config/nvim/lua/plugins/language/zig.lua
Normal file
20
home/private_dot_config/nvim/lua/plugins/language/zig.lua
Normal 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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
Loading…
Reference in a new issue