Switch over to nix-lspconfig
This commit is contained in:
parent
7b37393bc5
commit
a08b1d7277
10 changed files with 120 additions and 176 deletions
|
@ -1 +1,2 @@
|
|||
*.localhost localhost
|
||||
*.notatld.localhost localhost
|
||||
|
|
|
@ -5,12 +5,12 @@ let
|
|||
in
|
||||
{
|
||||
imports = [
|
||||
./nvim-lsp.nix
|
||||
./js.nix
|
||||
./go.nix
|
||||
./rust.nix
|
||||
./web_dev.nix
|
||||
./other_langs.nix
|
||||
./nix.nix
|
||||
];
|
||||
|
||||
options.mae.nvim = {
|
||||
enable = mkEnableOption "enable neovim";
|
||||
};
|
||||
|
@ -38,22 +38,8 @@ in
|
|||
set number
|
||||
set autoindent
|
||||
|
||||
set completeopt=menuone,noinsert,noselect
|
||||
set shortmess+=c
|
||||
'';
|
||||
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
|
||||
set completeopt=menuone,noinsert,noselect
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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
|
||||
];
|
||||
};
|
||||
}
|
|
@ -1,26 +1,41 @@
|
|||
{ lib, pkgs, config, ... }:
|
||||
let
|
||||
typescript-lsp = pkgs.nodePackages.typescript-language-server;
|
||||
tsserver-path = "${pkgs.nodePackages.typescript}/lib/node_modules/typescript/lib";
|
||||
cfg = config.mae.nvim;
|
||||
in
|
||||
with lib;
|
||||
{
|
||||
options.mae.nvim.js = {
|
||||
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 {
|
||||
programs.neovim = {
|
||||
coc.enable = true;
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
coc-tsserver
|
||||
config = mkMerge [
|
||||
(mkIf cfg.js.deno.enable
|
||||
{
|
||||
plugin = vim-jsdoc;
|
||||
config = ''
|
||||
let g:jsdoc_formatter = "tsdoc"
|
||||
let g:typescript_indent_disable = 1
|
||||
'';
|
||||
mae.nvim.lsp.servers.denols = {
|
||||
enable = true;
|
||||
script = ''
|
||||
{
|
||||
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}" }
|
||||
}
|
||||
'';
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
21
users/modules/neovim/nix.nix
Normal file
21
users/modules/neovim/nix.nix
Normal 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" }
|
||||
}'';
|
||||
};
|
||||
};
|
||||
}
|
49
users/modules/neovim/nvim-lsp.nix
Normal file
49
users/modules/neovim/nvim-lsp.nix
Normal 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";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
|
@ -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
|
||||
];
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
|
@ -1,23 +1,19 @@
|
|||
{ lib, pkgs, config, ... }:
|
||||
let
|
||||
cfg = config.mae.nvim.rust;
|
||||
cfg = config.mae.nvim;
|
||||
in
|
||||
with lib;
|
||||
{
|
||||
options.mae.nvim.rust = {
|
||||
enable = mkEnableOption "Enable rust support in nvim";
|
||||
};
|
||||
config.programs.neovim = mkIf cfg.enable {
|
||||
coc.enable = true;
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
coc-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;
|
||||
options.mae.nvim.rust.enable = lib.mkEnableOption "Enable rust language support in neovim";
|
||||
|
||||
config = mkIf cfg.rust.enable {
|
||||
mae.nvim.lsp.servers.rust_analyzer = {
|
||||
enable = true;
|
||||
script = ''
|
||||
{
|
||||
cmd = { "${pkgs.rust-analyzer}/bin/rust-analyzer" }
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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
|
||||
];
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
|
@ -2,10 +2,12 @@
|
|||
{
|
||||
mae.nvim = {
|
||||
enable = true;
|
||||
# js.tsserver.enable = true;
|
||||
lsp.enable = true;
|
||||
js.tsserver.enable = true;
|
||||
js.deno.enable = true;
|
||||
nix.enable = true;
|
||||
rust.enable = true;
|
||||
clangd.enable = true;
|
||||
python.enable = true;
|
||||
#clangd.enable = true;
|
||||
#python.enable = true;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue