Switch over to nix-lspconfig

This commit is contained in:
Bad 2022-08-17 22:02:19 +02:00
parent 7b37393bc5
commit a08b1d7277
10 changed files with 120 additions and 176 deletions

View file

@ -1 +1,2 @@
*.localhost localhost *.localhost localhost
*.notatld.localhost localhost

View file

@ -5,12 +5,12 @@ let
in in
{ {
imports = [ imports = [
./nvim-lsp.nix
./js.nix ./js.nix
./go.nix
./rust.nix ./rust.nix
./web_dev.nix ./nix.nix
./other_langs.nix
]; ];
options.mae.nvim = { options.mae.nvim = {
enable = mkEnableOption "enable neovim"; enable = mkEnableOption "enable neovim";
}; };
@ -38,22 +38,8 @@ in
set number set number
set autoindent set autoindent
set completeopt=menuone,noinsert,noselect
set shortmess+=c set shortmess+=c
''; set completeopt=menuone,noinsert,noselect
coc.pluginConfig = ''
nmap <silent> <F2> <Plug>(coc-rename)
nmap <silent> <F3> <Plug>(coc-codeaction-line)
" Remap <C-f> and <C-b> for scroll float windows/popups.
if has('nvim-0.4.0') || has('patch-8.2.0750')
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif
''; '';
}; };
}; };

View file

@ -1,17 +0,0 @@
{ lib, pkgs, config, ... }:
let
cfg = config.mae.nvim.go;
in
with lib;
{
options.mae.nvim.go = {
enable = mkEnableOption "Enable go support in nvim";
};
config.programs.neovim = mkIf cfg.enable {
coc.enable = true;
plugins = with pkgs.vimPlugins; [
pkgs.go-fold-if-err-nil
coc-go
];
};
}

View file

@ -1,26 +1,41 @@
{ lib, pkgs, config, ... }: { lib, pkgs, config, ... }:
let let
typescript-lsp = pkgs.nodePackages.typescript-language-server;
tsserver-path = "${pkgs.nodePackages.typescript}/lib/node_modules/typescript/lib";
cfg = config.mae.nvim; cfg = config.mae.nvim;
in in
with lib; with lib;
{ {
options.mae.nvim.js = { options.mae.nvim.js = {
tsserver.enable = mkEnableOption "Enable js/ts support in nvim with tsserver"; tsserver.enable = mkEnableOption "Enable js/ts support in nvim with tsserver";
deno.enable = mkEnableOption "Enable deno support in nvim";
}; };
config = mkIf cfg.js.tsserver.enable { config = mkMerge [
programs.neovim = { (mkIf cfg.js.deno.enable
coc.enable = true;
plugins = with pkgs.vimPlugins; [
coc-tsserver
{ {
plugin = vim-jsdoc; mae.nvim.lsp.servers.denols = {
config = '' enable = true;
let g:jsdoc_formatter = "tsdoc" script = ''
let g:typescript_indent_disable = 1 {
''; cmd = { "${pkgs.deno}/bin/deno", "lsp" },
single_file_support = false,
} }
'';
};
}
)
(mkIf
cfg.js.tsserver.enable
{
mae.nvim.lsp.servers.tsserver = {
enable = true;
script = ''
{
cmd = { "${typescript-lsp}/bin/typescript-language-server", "--stdio", "--tsserver-path", "${tsserver-path}" }
}
'';
};
})
]; ];
};
};
} }

View file

@ -0,0 +1,21 @@
{ lib, pkgs, config, ... }:
let
cfg = config.mae.nvim;
in
with lib;
{
options.mae.nvim.nix.enable = mkEnableOption "Enable nix support in nvim";
config = mkIf cfg.nix.enable {
programs.neovim = {
plugins = with pkgs.vimPlugins; [
vim-nix
];
};
mae.nvim.lsp.servers.rnix = {
enable = true;
script = '' {
cmd = { "${pkgs.rnix-lsp}/bin/rnix-lsp" }
}'';
};
};
}

View file

@ -0,0 +1,49 @@
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.mae.nvim;
lspLangConfigType = types.submodule {
options = {
enable = mkEnableOption "Enable named lsp lang config";
script = mkOption {
type = types.lines;
default = "{}";
};
};
};
mkLspLangConfig = name: cfg: ''
require'lspconfig'["${name}"].setup(require'coq'.lsp_ensure_capabilities(${cfg.script}))
'';
mkLspLangConfigs = cfgs: lib.strings.concatStringsSep "\n" ((lib.attrsets.mapAttrsToList mkLspLangConfig cfgs));
in
{
options.mae.nvim.lsp = {
enable = mkEnableOption "Enable lsp support in nvim with nvim-lspconfig and cmp-nvim";
servers = mkOption {
type = types.attrsOf lspLangConfigType;
default = [ ];
};
};
config = mkIf cfg.lsp.enable {
programs.neovim = {
plugins = with pkgs.vimPlugins; [
{
plugin = coq_nvim;
config = ''
vim.g.coq_settings = {
xdg = true,
auto_start = true
}
'';
type = "lua";
}
{
plugin = nvim-lspconfig;
config = mkLspLangConfigs cfg.lsp.servers;
type = "lua";
}
];
};
};
}

View file

@ -1,68 +0,0 @@
{ lib, pkgs, config, ... }:
let
cfg = config.mae.nvim;
in
with lib;
{
imports = [
# Lua
({ ... }: {
options.mae.nvim.lua.enable = mkEnableOption "Enable lua support in nvim";
config.programs.neovim = mkIf cfg.lua.enable
{
coc.enable = true;
coc.settings.languageserver.lua = mkIf cfg.lua.enable {
command = "${pkgs.sumneko-lua-language-server}/bin/lua-language-server";
rootPatterns = [ ".git" ];
filetypes = [
"lua"
];
};
};
})
# Nix
({ ... }: {
options.mae.nvim.nix.enable = mkEnableOption "Enable nix support in nvim";
config.programs.neovim = mkIf cfg.nix.enable
{
plugins = with pkgs.vimPlugins; [
vim-nix
];
coc.enable = true;
coc.settings.languageserver.nix = mkIf cfg.nix.enable {
"command" = "${pkgs.rnix-lsp}/bin/rnix-lsp";
"filetypes" = [
"nix"
];
};
};
})
# Clangd
({ ... }: {
options.mae.nvim.clangd.enable = mkEnableOption "Enable clangd support in nvim";
config.programs.neovim = mkIf cfg.clangd.enable
{
plugins = with pkgs.vimPlugins; [
coc-clangd
];
coc.enable = true;
coc.settings = {
"clangd.checkUpdates" = false;
# Use whatever clangd is in path for dependency reasons I think I don't remember at this point
"clangd.path" = "clangd";
};
};
})
# Python
({ ... }: {
options.mae.nvim.python.enable = mkEnableOption "Enable python support in nvim";
config.programs.neovim = mkIf cfg.python.enable
{
coc.enable = true;
plugins = with pkgs.vimPlugins; [
coc-pyright
];
};
})
];
}

View file

@ -1,23 +1,19 @@
{ lib, pkgs, config, ... }: { lib, pkgs, config, ... }:
let let
cfg = config.mae.nvim.rust; cfg = config.mae.nvim;
in in
with lib; with lib;
{ {
options.mae.nvim.rust = { options.mae.nvim.rust.enable = lib.mkEnableOption "Enable rust language support in neovim";
enable = mkEnableOption "Enable rust support in nvim";
}; config = mkIf cfg.rust.enable {
config.programs.neovim = mkIf cfg.enable { mae.nvim.lsp.servers.rust_analyzer = {
coc.enable = true; enable = true;
plugins = with pkgs.vimPlugins; [ script = ''
coc-rust-analyzer {
]; cmd = { "${pkgs.rust-analyzer}/bin/rust-analyzer" }
coc.settings = { }
"rust-analyzer.server.path" = "${pkgs.rust-analyzer-nightly}/bin/rust-analyzer"; '';
"rust-analyzer.updates.prompt" = false;
"rust-analyzer.updates.checkOnStartup" = false;
"rust-analyzer.cargo.loadOutDirsFromCheck" = true;
"rust-analyzer.procMacro.enable" = true;
}; };
}; };
} }

View file

@ -1,41 +0,0 @@
{ lib, pkgs, config, ... }:
let
cfg = config.mae.nvim;
in
with lib;
{
options.mae.nvim.web = {
enable = mkEnableOption "Enable webdev support in nvim";
};
options.mae.nvim.js = {
enable = mkEnableOption "Enable js/ts support in nvim";
};
config = mkMerge [
(mkIf cfg.js.enable {
programs.neovim = {
coc.enable = true;
plugins = with pkgs.vimPlugins; [
coc-tsserver
{
plugin = vim-jsdoc;
config = ''
let g:jsdoc_formatter = "tsdoc"
let g:typescript_indent_disable = 1
'';
}
];
};
})
(mkIf cfg.web.enable {
mae.nvim.js.enable = true;
programs.neovim = {
coc.enable = true;
plugins = with pkgs.vimPlugins; [
coc-emmet
coc-html
];
};
})
];
}

View file

@ -2,10 +2,12 @@
{ {
mae.nvim = { mae.nvim = {
enable = true; enable = true;
# js.tsserver.enable = true; lsp.enable = true;
js.tsserver.enable = true;
js.deno.enable = true;
nix.enable = true; nix.enable = true;
rust.enable = true; rust.enable = true;
clangd.enable = true; #clangd.enable = true;
python.enable = true; #python.enable = true;
}; };
} }