2024-04-15 01:46:15 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
dsl,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
{
|
2023-10-08 15:14:50 +00:00
|
|
|
|
|
|
|
# Terraform optional because non-free
|
2023-11-06 01:40:18 +00:00
|
|
|
options.terraform = lib.mkEnableOption "Whether to enable Terraform LSP";
|
|
|
|
options.github = lib.mkEnableOption "Whether to enable GitHub features";
|
2024-04-15 01:46:15 +00:00
|
|
|
options.kubernetes = lib.mkEnableOption "Whether to enable Kubernetes features";
|
2023-10-08 15:14:50 +00:00
|
|
|
|
2024-02-11 02:04:37 +00:00
|
|
|
config = {
|
|
|
|
plugins = [
|
|
|
|
pkgs.vimPlugins.nvim-lspconfig
|
|
|
|
pkgs.vimPlugins.conform-nvim
|
|
|
|
pkgs.vimPlugins.fidget-nvim
|
|
|
|
pkgs.vimPlugins.nvim-lint
|
|
|
|
];
|
|
|
|
|
|
|
|
setup.fidget = { };
|
|
|
|
|
|
|
|
use.lspconfig.lua_ls.setup = dsl.callWith {
|
2024-04-15 01:46:15 +00:00
|
|
|
settings = {
|
|
|
|
Lua = {
|
|
|
|
diagnostics = {
|
|
|
|
globals = [
|
|
|
|
"vim"
|
|
|
|
"hs"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()";
|
2024-02-11 02:04:37 +00:00
|
|
|
cmd = [ "${pkgs.lua-language-server}/bin/lua-language-server" ];
|
|
|
|
};
|
2023-10-08 15:14:50 +00:00
|
|
|
|
2024-04-25 17:25:15 +00:00
|
|
|
use.lspconfig.nixd.setup = dsl.callWith {
|
|
|
|
cmd = [ "${pkgs.nixd}/bin/nixd" ];
|
2024-04-15 01:46:15 +00:00
|
|
|
capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()";
|
2024-02-11 02:04:37 +00:00
|
|
|
};
|
2023-10-08 15:14:50 +00:00
|
|
|
|
2024-02-11 02:04:37 +00:00
|
|
|
use.lspconfig.pyright.setup = dsl.callWith {
|
2024-04-15 01:46:15 +00:00
|
|
|
cmd = [
|
|
|
|
"${pkgs.pyright}/bin/pyright-langserver"
|
|
|
|
"--stdio"
|
|
|
|
];
|
2024-02-11 02:04:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
use.lspconfig.terraformls.setup = dsl.callWith {
|
2024-04-15 01:46:15 +00:00
|
|
|
cmd =
|
|
|
|
if config.terraform then
|
|
|
|
[
|
|
|
|
"${pkgs.terraform-ls}/bin/terraform-ls"
|
|
|
|
"serve"
|
|
|
|
]
|
|
|
|
else
|
|
|
|
[ "echo" ];
|
2024-02-11 02:04:37 +00:00
|
|
|
};
|
2023-10-08 15:14:50 +00:00
|
|
|
|
2024-02-11 02:04:37 +00:00
|
|
|
use.lspconfig.rust_analyzer.setup = dsl.callWith {
|
|
|
|
cmd = [ "${pkgs.rust-analyzer}/bin/rust-analyzer" ];
|
|
|
|
settings = {
|
2024-02-11 21:20:23 +00:00
|
|
|
"['rust-analyzer']" = {
|
2024-04-15 01:46:15 +00:00
|
|
|
check = {
|
|
|
|
command = "clippy";
|
|
|
|
};
|
|
|
|
files = {
|
|
|
|
excludeDirs = [ ".direnv" ];
|
|
|
|
};
|
2024-02-11 21:20:23 +00:00
|
|
|
};
|
2023-10-08 15:14:50 +00:00
|
|
|
};
|
2024-02-11 02:04:37 +00:00
|
|
|
};
|
2023-10-08 15:14:50 +00:00
|
|
|
|
2024-02-11 02:04:37 +00:00
|
|
|
setup.conform = {
|
|
|
|
format_on_save = {
|
|
|
|
# These options will be passed to conform.format()
|
2024-02-12 03:28:05 +00:00
|
|
|
timeout_ms = 1500;
|
2024-02-11 02:04:37 +00:00
|
|
|
lsp_fallback = true;
|
|
|
|
};
|
|
|
|
formatters_by_ft = {
|
|
|
|
lua = [ "stylua" ];
|
|
|
|
python = [ "black" ];
|
|
|
|
fish = [ "fish_indent" ];
|
|
|
|
nix = [ "nixfmt" ];
|
|
|
|
rust = [ "rustfmt" ];
|
|
|
|
sh = [ "shfmt" ];
|
|
|
|
terraform = if config.terraform then [ "terraform_fmt" ] else [ ];
|
|
|
|
hcl = if config.terraform then [ "terraform_fmt" ] else [ ];
|
|
|
|
};
|
|
|
|
formatters = {
|
|
|
|
lua.command = "${pkgs.stylua}/bin/stylua";
|
|
|
|
black.command = "${pkgs.black}/bin/black";
|
|
|
|
fish_indent.command = "${pkgs.fish}/bin/fish_indent";
|
2024-04-09 21:54:22 +00:00
|
|
|
nixfmt.command = "${pkgs.nixfmt-rfc-style}/bin/nixfmt";
|
2024-04-15 01:46:15 +00:00
|
|
|
rustfmt.command = "${pkgs.rustfmt}/bin/rustfmt";
|
2024-02-11 02:04:37 +00:00
|
|
|
shfmt = {
|
|
|
|
command = "${pkgs.shfmt}/bin/shfmt";
|
2024-04-15 01:46:15 +00:00
|
|
|
prepend_args = [
|
|
|
|
"-i"
|
|
|
|
"4"
|
|
|
|
"-ci"
|
|
|
|
];
|
2023-11-05 13:12:07 +00:00
|
|
|
};
|
2024-04-15 01:46:15 +00:00
|
|
|
terraform_fmt.command = if config.terraform then "${pkgs.terraform}/bin/terraform" else "";
|
2023-11-05 13:12:07 +00:00
|
|
|
};
|
2024-02-11 02:04:37 +00:00
|
|
|
};
|
2023-11-04 17:49:23 +00:00
|
|
|
|
2024-02-11 02:04:37 +00:00
|
|
|
use.lint = {
|
|
|
|
linters_by_ft = dsl.toTable {
|
|
|
|
python = [ "ruff" ];
|
|
|
|
sh = [ "shellcheck" ];
|
|
|
|
};
|
2023-10-08 15:14:50 +00:00
|
|
|
};
|
2022-11-28 02:11:41 +00:00
|
|
|
|
2024-02-11 02:04:37 +00:00
|
|
|
vim.api.nvim_create_autocmd = dsl.callWith [
|
2024-04-15 01:46:15 +00:00
|
|
|
(dsl.toTable [
|
|
|
|
"BufEnter"
|
|
|
|
"BufWritePost"
|
|
|
|
])
|
2024-02-11 02:04:37 +00:00
|
|
|
(dsl.rawLua "{ callback = function() require('lint').try_lint() end }")
|
|
|
|
];
|
|
|
|
|
|
|
|
lua = ''
|
|
|
|
${builtins.readFile ./lsp.lua}
|
|
|
|
|
|
|
|
local ruff = require('lint').linters.ruff; ruff.cmd = "${pkgs.ruff}/bin/ruff"
|
|
|
|
local shellcheck = require('lint').linters.shellcheck; shellcheck.cmd = "${pkgs.shellcheck}/bin/shellcheck"
|
|
|
|
|
|
|
|
-- Prevent infinite log size (change this when debugging)
|
|
|
|
vim.lsp.set_log_level("off")
|
|
|
|
'';
|
|
|
|
};
|
2022-11-28 02:11:41 +00:00
|
|
|
}
|