system/modules/home-manager/programs/editors/neovim.nix

180 lines
4.8 KiB
Nix
Raw Normal View History

2024-04-16 02:51:46 +03:00
{ config, pkgs, lib, ... }:
let
cfg = config.local.programs.editors.neovim;
# TODO: add more configs
myneovim = pkgs.myneovim.override {
viAlias = true;
vimAlias = true;
enableDevIcons = true;
enableTabby = true;
enableOrgMode = true;
extraConfig = ''
aug extra_ftdetect
au!
au BufNewFile,BufRead *.d2 setfiletype d2
au BufNewFile,BufRead *.ncl setfiletype nickel
au BufNewFile,BufRead *.psql setfiletype psql
aug END
'';
plugins = with pkgs.myneovim.nix2lua; (lib.mkMerge [
{
nvimTree.settings = {
renderer = {
group_empty = true;
full_name = true;
};
tab.sync = {
open = true;
close = true;
};
};
telescope.settings = {
extensions.live_grep_args = {
auto_quoting = true;
mappings.i = {
"<C-K>" = join "." [
(mkCall "require" [ "telescope-live-grep-args.actions" ])
(mkCall "quote_prompt" [ ])
];
};
};
};
lspSaga.settings = {
border_style = "rounded";
symbol_in_winbar.enable = false;
code_action_lightbulb.enable = false;
code_action_keys = { quit = "<Esc>"; };
definition_action_keys = { quit = "<Esc>"; };
rename_action_quit = "<C-c>";
};
lspConfig.servers = {
nickel_ls = { };
tsserver = { };
eslint = { };
volar = {
init_options = {
typescript.tsdk = "./node_modules/typescript/lib";
};
};
denols = {
root_dir = mkCall "root_pattern" [ "deno.json" "deno.jsonc" ];
};
pylsp = { };
};
lualine.settings = {
options.ignore_focus = [ "NvimTree" ];
sections = {
lualine_a = [
[ "filename" (mkNamedField "path" 1) ]
];
lualine_b = [ "branch" "diff" "diagnostics" ];
lualine_c = [ "lsp_progress" ];
lualine_x = [ "filesize" "filetype" ];
lualine_y = [ "progress" ];
lualine_z = [ "location" "mode" ];
};
};
}
(lib.mkIf cfg.orgmode.enable {
orgmode.settings = {
org_agenda_files = [ "~/orgs/**/*" ];
org_default_notes_file = "~/orgs/refile.org";
win_split_mode = "tabnew";
org_hide_leading_stars = true;
};
})
(lib.mkIf cfg.ltex.enable {
lspConfig.servers.ltex = {
language = "en-US";
languageToolHttpServerUri = "http://localhost:8081";
};
})
(lib.mkIf cfg.nix.enable {
lspConfig.servers.nil_ls = { };
})
(lib.mkIf cfg.rust.enable {
lspConfig.servers.rust_analyzer = {
settings.rust-analyzer = {
"server.path" = "rust-analyzer";
"updates.prompt" = false;
"updates.checkOnStartup" = false;
"checkOnSave.enable" = true;
"checkOnSave.command" = "clippy";
"cargo.autoreload" = true;
};
};
})
(lib.mkIf (cfg.typescript.enable || cfg.vue.enable) {
lspConfig.servers = {
tsserver = { };
eslint = { };
};
})
(lib.mkIf cfg.vue.enable {
lspConfig.servers.volar = {
init_options = {
typescript.tsdk = "./node_modules/typescript/lib";
};
};
})
(lib.mkIf cfg.deno.enable {
lspConfig.servers.denols = {
root_dir = mkCall "root_pattern" [ "deno.json" "deno.jsonc" ];
};
})
(lib.mkIf cfg.python.enable {
lspConfig.servers.pylsp = { };
})
(lib.mkIf cfg.nickel.enable {
lspConfig.servers.nickel_ls = { };
})
]);
};
in
{
options.local.programs.editors.neovim = with lib; {
enable = mkEnableOption "neovim";
defaultEditor = mkOption {
description = "set neovim as default editor";
type = types.bool;
default = false;
};
ltex.enable = mkEnableOption "ltex language server";
orgmode.enable = mkEnableOption "orgmode";
nix.enable = mkEnableOption "nix";
2024-04-16 02:51:46 +03:00
rust.enable = mkEnableOption "rust";
typescript.enable = mkEnableOption "typescript";
vue.enable = mkEnableOption "vue";
deno.enable = mkEnableOption "deno";
python.enable = mkEnableOption "python";
nickel.enable = mkEnableOption "nickel";
};
config = lib.mkIf cfg.enable (lib.mkMerge [
{
home.packages = [ myneovim ];
}
(lib.mkIf cfg.ltex.enable {
home.packages = [ pkgs.ltex-ls ];
})
(lib.mkIf cfg.defaultEditor {
home.sessionVariables.EDITOR = "nvim";
})
]);
}