parent
e4c9f45ab2
commit
3e2cac125b
15 changed files with 342 additions and 395 deletions
homeManagerModules/neovim/langs
|
@ -42,10 +42,9 @@ in {
|
||||||
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
||||||
});
|
});
|
||||||
|
|
||||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
vim.lsp.enable('bashls');
|
||||||
|
vim.lsp.config('bashls', {
|
||||||
require('lspconfig').bashls.setup({
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||||
capabilities = default_capabilities,
|
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
bashIde = {
|
bashIde = {
|
||||||
|
|
|
@ -7,32 +7,10 @@
|
||||||
inherit (lib) mkIf;
|
inherit (lib) mkIf;
|
||||||
|
|
||||||
cfg = config.programs.neovim;
|
cfg = config.programs.neovim;
|
||||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs = {
|
programs = {
|
||||||
neovim = {
|
neovim = {
|
||||||
extraLuaConfig =
|
|
||||||
# lua
|
|
||||||
''
|
|
||||||
--
|
|
||||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
|
||||||
pattern = { 'cpp', 'c' },
|
|
||||||
|
|
||||||
callback = function()
|
|
||||||
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
|
||||||
|
|
||||||
if (devShells['c-lang'] == nil) then
|
|
||||||
devShells['c-lang'] = 1;
|
|
||||||
|
|
||||||
require('nix-develop').nix_develop_extend({'${flakeEnv}#c-lang'}, function()
|
|
||||||
vim.cmd[[LspStart]];
|
|
||||||
end);
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
});
|
|
||||||
'';
|
|
||||||
|
|
||||||
plugins = [
|
plugins = [
|
||||||
{
|
{
|
||||||
plugin = pkgs.vimPlugins.clangd_extensions-nvim;
|
plugin = pkgs.vimPlugins.clangd_extensions-nvim;
|
||||||
|
@ -41,22 +19,31 @@ in {
|
||||||
# lua
|
# lua
|
||||||
''
|
''
|
||||||
--
|
--
|
||||||
local lsp = require('lspconfig');
|
|
||||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
||||||
|
|
||||||
|
loadDevShell({
|
||||||
lsp.cmake.setup({
|
name = 'c-lang',
|
||||||
capabilities = default_capabilities,
|
pattern = { 'cpp', 'c' },
|
||||||
autostart = false,
|
pre_shell_callback = function()
|
||||||
});
|
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
||||||
|
|
||||||
lsp.clangd.setup({
|
|
||||||
capabilities = default_capabilities,
|
|
||||||
autostart = false,
|
|
||||||
|
|
||||||
on_attach = function(_, bufnr)
|
|
||||||
require('clangd_extensions').setup();
|
|
||||||
end,
|
end,
|
||||||
|
language_servers = {
|
||||||
|
cmake = function()
|
||||||
|
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['cmake'], {
|
||||||
|
capabilities = default_capabilities,
|
||||||
|
}));
|
||||||
|
end,
|
||||||
|
|
||||||
|
clangd = function()
|
||||||
|
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['clangd'], {
|
||||||
|
capabilities = default_capabilities,
|
||||||
|
|
||||||
|
on_attach = function(_, bufnr)
|
||||||
|
require('clangd_extensions').setup();
|
||||||
|
end,
|
||||||
|
}));
|
||||||
|
end,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ self: {
|
||||||
inherit (lib) mkIf;
|
inherit (lib) mkIf;
|
||||||
|
|
||||||
cfg = config.programs.neovim;
|
cfg = config.programs.neovim;
|
||||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs = {
|
programs = {
|
||||||
|
@ -60,23 +59,17 @@ in {
|
||||||
|
|
||||||
exe = 'Microsoft.CodeAnalysis.LanguageServer',
|
exe = 'Microsoft.CodeAnalysis.LanguageServer',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
vim.cmd[[e]]; -- reload to attach on current file
|
||||||
end;
|
end;
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
loadDevShell({
|
||||||
|
name = 'csharp',
|
||||||
pattern = { 'cs' },
|
pattern = { 'cs' },
|
||||||
|
pre_shell_callback = function()
|
||||||
callback = function()
|
|
||||||
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
||||||
|
|
||||||
if (devShells['csharp'] == nil) then
|
|
||||||
devShells['csharp'] = 1;
|
|
||||||
|
|
||||||
require('nix-develop').nix_develop_extend({'${flakeEnv}#csharp'}, function()
|
|
||||||
startRoslyn();
|
|
||||||
vim.cmd[[e]]; -- reload to attach on current file
|
|
||||||
end);
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
|
post_shell_callback = startRoslyn,
|
||||||
});
|
});
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ self: {
|
||||||
inherit (lib) attrValues fileContents mkBefore mkIf;
|
inherit (lib) attrValues fileContents mkBefore mkIf;
|
||||||
|
|
||||||
cfg = config.programs.neovim;
|
cfg = config.programs.neovim;
|
||||||
|
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./bash
|
./bash
|
||||||
|
@ -37,9 +38,51 @@ in {
|
||||||
# lua
|
# lua
|
||||||
''
|
''
|
||||||
--
|
--
|
||||||
|
local nix_develop = require('nix-develop');
|
||||||
|
|
||||||
-- Init object to keep track of loaded devShells
|
-- Init object to keep track of loaded devShells
|
||||||
local devShells = {};
|
local devShells = {};
|
||||||
|
|
||||||
|
--- @param name string
|
||||||
|
--- @param pattern string|string[]
|
||||||
|
--- @param pre_shell_callback function
|
||||||
|
--- @param language_servers function?
|
||||||
|
--- @param post_shell_callback function?
|
||||||
|
local loadDevShell = function(args)
|
||||||
|
local name = args.name;
|
||||||
|
local pattern = args.pattern;
|
||||||
|
local pre_shell_callback = args.pre_shell_callback;
|
||||||
|
|
||||||
|
local post_shell_callback = args.post_shell_callback or function()
|
||||||
|
local filetype = vim.api.nvim_buf_get_option(0, 'filetype')
|
||||||
|
|
||||||
|
for name, func in pairs(args.language_servers) do
|
||||||
|
if vim.tbl_contains(vim.lsp.config[name].filetypes, filetype) then
|
||||||
|
func();
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
||||||
|
pattern = pattern,
|
||||||
|
|
||||||
|
callback = function()
|
||||||
|
pre_shell_callback();
|
||||||
|
|
||||||
|
if (devShells[name] == nil) then
|
||||||
|
devShells[name] = 1;
|
||||||
|
|
||||||
|
nix_develop.nix_develop_extend(
|
||||||
|
{'${flakeEnv}#' .. name},
|
||||||
|
post_shell_callback
|
||||||
|
);
|
||||||
|
else
|
||||||
|
post_shell_callback();
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
});
|
||||||
|
end;
|
||||||
|
|
||||||
-- Add formatting cmd
|
-- Add formatting cmd
|
||||||
vim.api.nvim_create_user_command(
|
vim.api.nvim_create_user_command(
|
||||||
'Format',
|
'Format',
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
inherit (lib) mkIf;
|
inherit (lib) mkIf;
|
||||||
|
|
||||||
cfg = config.programs.neovim;
|
cfg = config.programs.neovim;
|
||||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs = {
|
programs = {
|
||||||
|
@ -15,28 +14,19 @@ in {
|
||||||
# lua
|
# lua
|
||||||
''
|
''
|
||||||
--
|
--
|
||||||
local lsp = require('lspconfig');
|
loadDevShell({
|
||||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
name = 'golang',
|
||||||
|
|
||||||
lsp.gopls.setup({
|
|
||||||
capabilities = default_capabilities,
|
|
||||||
autostart = false,
|
|
||||||
});
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
|
||||||
pattern = { 'go', 'gomod', 'gowork', 'gotmpl' },
|
pattern = { 'go', 'gomod', 'gowork', 'gotmpl' },
|
||||||
|
pre_shell_callback = function()
|
||||||
callback = function()
|
|
||||||
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
||||||
|
|
||||||
if (devShells['golang'] == nil) then
|
|
||||||
devShells['golang'] = 1;
|
|
||||||
|
|
||||||
require('nix-develop').nix_develop_extend({'${flakeEnv}#golang'}, function()
|
|
||||||
vim.cmd[[LspStart]];
|
|
||||||
end);
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
|
language_servers = {
|
||||||
|
gopls = function()
|
||||||
|
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['gopls'], {
|
||||||
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||||
|
}));
|
||||||
|
end,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
inherit (lib) mkIf;
|
inherit (lib) mkIf;
|
||||||
|
|
||||||
cfg = config.programs.neovim;
|
cfg = config.programs.neovim;
|
||||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs = {
|
programs = {
|
||||||
|
@ -15,46 +14,40 @@ in {
|
||||||
# lua
|
# lua
|
||||||
''
|
''
|
||||||
--
|
--
|
||||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
|
||||||
pattern = { 'json', 'yaml', '.clang-.*' },
|
|
||||||
|
|
||||||
callback = function()
|
|
||||||
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
|
||||||
|
|
||||||
if (devShells['json'] == nil) then
|
|
||||||
devShells['json'] = 1;
|
|
||||||
|
|
||||||
require('nix-develop').nix_develop_extend({'${flakeEnv}#json'}, function()
|
|
||||||
vim.cmd[[LspStart]];
|
|
||||||
end);
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
});
|
|
||||||
|
|
||||||
local lsp = require('lspconfig');
|
|
||||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
||||||
|
|
||||||
lsp.jsonls.setup({
|
loadDevShell({
|
||||||
capabilities = default_capabilities,
|
name = 'json',
|
||||||
autostart = false,
|
pattern = { 'json', 'yaml', '.clang-.*' },
|
||||||
});
|
pre_shell_callback = function()
|
||||||
|
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
||||||
|
end,
|
||||||
|
language_servers = {
|
||||||
|
jsonls = function()
|
||||||
|
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['jsonls'], {
|
||||||
|
capabilities = default_capabilities,
|
||||||
|
}));
|
||||||
|
end,
|
||||||
|
|
||||||
lsp.yamlls.setup({
|
yamlls = function()
|
||||||
capabilities = default_capabilities,
|
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['yamlls'], {
|
||||||
autostart = false,
|
capabilities = default_capabilities,
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
yaml = {
|
yaml = {
|
||||||
format = {
|
format = {
|
||||||
enable = true,
|
enable = true,
|
||||||
singleQuote = true,
|
singleQuote = true,
|
||||||
},
|
},
|
||||||
schemas = {
|
schemas = {
|
||||||
[
|
[
|
||||||
"https://json.schemastore.org/github-workflow.json"
|
"https://json.schemastore.org/github-workflow.json"
|
||||||
] = "/.github/workflows/*",
|
] = "/.github/workflows/*",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
inherit (lib) mkIf;
|
inherit (lib) mkIf;
|
||||||
|
|
||||||
cfg = config.programs.neovim;
|
cfg = config.programs.neovim;
|
||||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs = {
|
programs = {
|
||||||
|
@ -15,28 +14,19 @@ in {
|
||||||
# lua
|
# lua
|
||||||
''
|
''
|
||||||
--
|
--
|
||||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
loadDevShell({
|
||||||
|
name = 'kotlin',
|
||||||
pattern = { 'kotlin' },
|
pattern = { 'kotlin' },
|
||||||
|
pre_shell_callback = function()
|
||||||
callback = function()
|
|
||||||
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
||||||
|
|
||||||
if (devShells['kotlin'] == nil) then
|
|
||||||
devShells['kotlin'] = 1;
|
|
||||||
|
|
||||||
require('nix-develop').nix_develop_extend({'${flakeEnv}#kotlin'}, function()
|
|
||||||
vim.cmd[[LspStart]];
|
|
||||||
end);
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
});
|
language_servers = {
|
||||||
|
rust_analyzer = function()
|
||||||
local lsp = require('lspconfig');
|
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['kotlin_language_server'], {
|
||||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||||
|
}));
|
||||||
lsp.kotlin_language_server.setup({
|
end,
|
||||||
capabilities = default_capabilities,
|
},
|
||||||
autostart = false,
|
|
||||||
});
|
});
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
inherit (lib) mkIf;
|
inherit (lib) mkIf;
|
||||||
|
|
||||||
cfg = config.programs.neovim;
|
cfg = config.programs.neovim;
|
||||||
|
|
||||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs = {
|
programs = {
|
||||||
|
@ -21,35 +19,27 @@ in {
|
||||||
# lua
|
# lua
|
||||||
''
|
''
|
||||||
--
|
--
|
||||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
loadDevShell({
|
||||||
|
name = 'lua',
|
||||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
pattern = { 'lua' },
|
||||||
pattern = 'lua',
|
pre_shell_callback = function()
|
||||||
|
|
||||||
callback = function()
|
|
||||||
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
||||||
|
|
||||||
if (devShells['lua'] == nil) then
|
|
||||||
devShells['lua'] = 1;
|
|
||||||
|
|
||||||
require('nix-develop').nix_develop_extend({'${flakeEnv}#lua'}, function()
|
|
||||||
vim.cmd[[LspStart]];
|
|
||||||
end);
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
});
|
language_servers = {
|
||||||
|
lua_ls = function()
|
||||||
|
require('lazydev').setup({
|
||||||
|
library = {
|
||||||
|
-- Load luvit types when the `vim.uv` word is found
|
||||||
|
{ path = '${pkgs.vimPlugins.luvit-meta}/library', words = { 'vim%.uv' } },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
require('lazydev').setup({
|
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['lua_ls'], {
|
||||||
library = {
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||||
-- Load luvit types when the `vim.uv` word is found
|
}));
|
||||||
{ path = '${pkgs.vimPlugins.luvit-meta}/library', words = { 'vim%.uv' } },
|
end,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
require('lspconfig').lua_ls.setup({
|
|
||||||
capabilities = default_capabilities,
|
|
||||||
autostart = false,
|
|
||||||
});
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
@ -12,7 +12,6 @@ self: {
|
||||||
inherit (lib) concatStringsSep mkIf;
|
inherit (lib) concatStringsSep mkIf;
|
||||||
|
|
||||||
cfg = config.programs.neovim;
|
cfg = config.programs.neovim;
|
||||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
|
||||||
isServer = osConfig.roles.server.sshd.enable or false;
|
isServer = osConfig.roles.server.sshd.enable or false;
|
||||||
isDesktop = osConfig.roles.desktop.enable or false;
|
isDesktop = osConfig.roles.desktop.enable or false;
|
||||||
|
|
||||||
|
@ -28,37 +27,29 @@ in {
|
||||||
# lua
|
# lua
|
||||||
''
|
''
|
||||||
--
|
--
|
||||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
loadDevShell({
|
||||||
|
name = 'markdown',
|
||||||
pattern = { 'markdown', 'tex' },
|
pattern = { 'markdown', 'tex' },
|
||||||
|
pre_shell_callback = function()
|
||||||
callback = function()
|
|
||||||
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
||||||
|
|
||||||
if (devShells['markdown'] == nil) then
|
|
||||||
devShells['markdown'] = 1;
|
|
||||||
|
|
||||||
require('nix-develop').nix_develop_extend({'${flakeEnv}#markdown'}, function()
|
|
||||||
vim.cmd[[LspStart]];
|
|
||||||
end);
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
});
|
language_servers = {
|
||||||
|
texlab = function()
|
||||||
|
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['texlab'], {
|
||||||
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||||
|
|
||||||
local lsp = require('lspconfig');
|
settings = {
|
||||||
|
texlab = {
|
||||||
lsp.texlab.setup({
|
formatterLineLength = 100,
|
||||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
latexFormatter = 'latexindent',
|
||||||
autostart = false,
|
latexindent = {
|
||||||
|
modifyLineBreaks = false,
|
||||||
settings = {
|
["local"] = '.indentconfig.yaml';
|
||||||
texlab = {
|
},
|
||||||
formatterLineLength = 100,
|
},
|
||||||
latexFormatter = 'latexindent',
|
},
|
||||||
latexindent = {
|
}));
|
||||||
modifyLineBreaks = false,
|
end,
|
||||||
["local"] = '.indentconfig.yaml';
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -75,7 +75,8 @@ in {
|
||||||
# lua
|
# lua
|
||||||
''
|
''
|
||||||
--
|
--
|
||||||
require('lspconfig').nixd.setup({
|
vim.lsp.enable('nixd');
|
||||||
|
vim.lsp.config('nixd', {
|
||||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||||
|
|
||||||
filetypes = { 'nix', 'in.nix' },
|
filetypes = { 'nix', 'in.nix' },
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
inherit (lib) mkIf;
|
inherit (lib) mkIf;
|
||||||
|
|
||||||
cfg = config.programs.neovim;
|
cfg = config.programs.neovim;
|
||||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs = {
|
programs = {
|
||||||
|
@ -15,38 +14,31 @@ in {
|
||||||
# lua
|
# lua
|
||||||
''
|
''
|
||||||
--
|
--
|
||||||
local lsp = require('lspconfig');
|
|
||||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
||||||
|
|
||||||
lsp.basedpyright.setup({
|
loadDevShell({
|
||||||
capabilities = default_capabilities,
|
name = 'python',
|
||||||
autostart = false,
|
|
||||||
settings = {
|
|
||||||
python = {
|
|
||||||
pythonPath = vim.fn.exepath("python"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
lsp.ruff.setup({
|
|
||||||
capabilities = default_capabilities,
|
|
||||||
autostart = false,
|
|
||||||
});
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
|
||||||
pattern = { 'python' },
|
pattern = { 'python' },
|
||||||
|
pre_shell_callback = function()
|
||||||
callback = function()
|
|
||||||
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
||||||
|
|
||||||
if (devShells['python'] == nil) then
|
|
||||||
devShells['python'] = 1;
|
|
||||||
|
|
||||||
require('nix-develop').nix_develop_extend({'${flakeEnv}#python'}, function()
|
|
||||||
vim.cmd[[LspStart]];
|
|
||||||
end);
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
|
language_servers = {
|
||||||
|
basedpyright = function()
|
||||||
|
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['basedpyright'], {
|
||||||
|
capabilities = default_capabilities,
|
||||||
|
settings = {
|
||||||
|
python = {
|
||||||
|
pythonPath = vim.fn.exepath("python"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
end,
|
||||||
|
ruff = function()
|
||||||
|
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['ruff'], {
|
||||||
|
capabilities = default_capabilities,
|
||||||
|
}));
|
||||||
|
end,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
inherit (lib) mkIf;
|
inherit (lib) mkIf;
|
||||||
|
|
||||||
cfg = config.programs.neovim;
|
cfg = config.programs.neovim;
|
||||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs = {
|
programs = {
|
||||||
|
@ -15,30 +14,24 @@ in {
|
||||||
# lua
|
# lua
|
||||||
''
|
''
|
||||||
--
|
--
|
||||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
|
||||||
pattern = { 'qml' },
|
|
||||||
|
|
||||||
callback = function()
|
|
||||||
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
|
||||||
|
|
||||||
if (devShells['qml'] == nil) then
|
|
||||||
devShells['qml'] = 1;
|
|
||||||
|
|
||||||
require('nix-develop').nix_develop_extend({'${flakeEnv}#qml'}, function()
|
|
||||||
vim.cmd[[LspStart]];
|
|
||||||
end);
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
});
|
|
||||||
|
|
||||||
local lsp = require('lspconfig');
|
local lsp = require('lspconfig');
|
||||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
||||||
|
|
||||||
lsp.qmlls.setup({
|
loadDevShell({
|
||||||
cmd = { 'qmlls', '-E' },
|
name = 'qml',
|
||||||
root_dir = lsp.util.root_pattern('*.qml', '.git'),
|
pattern = { 'qml' },
|
||||||
capabilities = default_capabilities,
|
pre_shell_callback = function()
|
||||||
autostart = false,
|
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
||||||
|
end,
|
||||||
|
language_servers = {
|
||||||
|
qmlls = function()
|
||||||
|
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['qmlls'], {
|
||||||
|
cmd = { 'qmlls', '-E' },
|
||||||
|
root_dir = lsp.util.root_pattern('*.qml', '.git'),
|
||||||
|
capabilities = default_capabilities,
|
||||||
|
}));
|
||||||
|
end,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
inherit (lib) mkIf;
|
inherit (lib) mkIf;
|
||||||
|
|
||||||
cfg = config.programs.neovim;
|
cfg = config.programs.neovim;
|
||||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs = {
|
programs = {
|
||||||
|
@ -15,25 +14,19 @@ in {
|
||||||
# lua
|
# lua
|
||||||
''
|
''
|
||||||
--
|
--
|
||||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
loadDevShell({
|
||||||
|
name = 'rust',
|
||||||
pattern = { 'rust' },
|
pattern = { 'rust' },
|
||||||
|
pre_shell_callback = function()
|
||||||
callback = function()
|
|
||||||
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
||||||
|
|
||||||
if (devShells['rust'] == nil) then
|
|
||||||
devShells['rust'] = 1;
|
|
||||||
|
|
||||||
require('nix-develop').nix_develop_extend({'${flakeEnv}#rust'}, function()
|
|
||||||
vim.cmd[[LspStart]];
|
|
||||||
end);
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
});
|
language_servers = {
|
||||||
|
rust_analyzer = function()
|
||||||
require('lspconfig').rust_analyzer.setup({
|
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['rust_analyzer'], {
|
||||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||||
autostart = false,
|
}));
|
||||||
|
end,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,7 +10,6 @@ self: {
|
||||||
inherit (lib) mkIf;
|
inherit (lib) mkIf;
|
||||||
|
|
||||||
cfg = config.programs.neovim;
|
cfg = config.programs.neovim;
|
||||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs = {
|
programs = {
|
||||||
|
@ -21,21 +20,139 @@ in {
|
||||||
# lua
|
# lua
|
||||||
''
|
''
|
||||||
--
|
--
|
||||||
local lsp = require('lspconfig');
|
|
||||||
local tsserver = require('typescript-tools');
|
|
||||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
||||||
|
|
||||||
local loadDevShell = function()
|
local eslintConfig = function()
|
||||||
if (devShells['web'] == nil) then
|
local config = vim.lsp.config['eslint'];
|
||||||
devShells['web'] = 1;
|
config.before_init = nil;
|
||||||
|
|
||||||
require('nix-develop').nix_develop_extend({'${flakeEnv}#web'}, function()
|
vim.lsp.start(vim.tbl_deep_extend('force', config, {
|
||||||
vim.cmd[[LspStart]];
|
capabilities = default_capabilities,
|
||||||
end);
|
|
||||||
end
|
-- auto-save
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
vim.lsp.config['eslint'].on_attach(client, bufnr);
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||||
|
buffer = bufnr,
|
||||||
|
command = 'LspEslintFixAll',
|
||||||
|
});
|
||||||
|
end,
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
validate = 'on',
|
||||||
|
packageManager = 'npm',
|
||||||
|
useESLintClass = true,
|
||||||
|
useFlatConfig = true,
|
||||||
|
experimental = {
|
||||||
|
useFlatConfig = true,
|
||||||
|
},
|
||||||
|
codeAction = {
|
||||||
|
disableRuleComment = {
|
||||||
|
enable = true,
|
||||||
|
location = 'separateLine'
|
||||||
|
},
|
||||||
|
showDocumentation = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
codeActionOnSave = {
|
||||||
|
mode = 'all',
|
||||||
|
rules = {},
|
||||||
|
},
|
||||||
|
format = true,
|
||||||
|
quiet = false,
|
||||||
|
onIgnoredFiles = 'off',
|
||||||
|
rulesCustomizations = {},
|
||||||
|
run = 'onType',
|
||||||
|
problems = {
|
||||||
|
shortenToSingleLine = false,
|
||||||
|
},
|
||||||
|
nodePath = "",
|
||||||
|
workingDirectory = {
|
||||||
|
mode = 'location',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
||||||
|
pattern = 'scss',
|
||||||
|
command = 'setlocal iskeyword+=@-@',
|
||||||
|
});
|
||||||
|
local cssConfig = function()
|
||||||
|
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['cssls'], {
|
||||||
|
capabilities = default_capabilities,
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
css = {
|
||||||
|
validate = false,
|
||||||
|
},
|
||||||
|
less = {
|
||||||
|
validate = false,
|
||||||
|
},
|
||||||
|
scss = {
|
||||||
|
validate = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['somesass_ls'], {
|
||||||
|
capabilities = default_capabilities,
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
somesass = {
|
||||||
|
scss = {
|
||||||
|
completion = {
|
||||||
|
suggestFromUseOnly = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
end;
|
||||||
|
|
||||||
|
local htmlConfig = function()
|
||||||
|
local html_caps = default_capabilities;
|
||||||
|
html_caps.textDocument.completion.completionItem.snippetSupport = true;
|
||||||
|
|
||||||
|
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['html'], {
|
||||||
|
capabilities = html_caps,
|
||||||
|
autostart = false,
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
configurationSection = { "html", "css", "javascript" },
|
||||||
|
embeddedLanguages = {
|
||||||
|
css = true,
|
||||||
|
javascript = true,
|
||||||
|
},
|
||||||
|
provideFormatter = true,
|
||||||
|
tabSize = 4,
|
||||||
|
insertSpaces = true,
|
||||||
|
indentEmptyLines = false,
|
||||||
|
wrapAttributes = 'auto',
|
||||||
|
wrapAttributesIndentSize = 4,
|
||||||
|
endWithNewline = true,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
end;
|
||||||
|
|
||||||
|
local typescriptConfig = function()
|
||||||
|
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['ts_ls'], {
|
||||||
|
capabilities = default_capabilities,
|
||||||
|
|
||||||
|
handlers = {
|
||||||
|
-- format error code with better error message
|
||||||
|
['textDocument/publishDiagnostics'] = function(err, result, ctx, config)
|
||||||
|
require('ts-error-translator').translate_diagnostics(err, result, ctx, config)
|
||||||
|
vim.lsp.diagnostic.on_publish_diagnostics(err, result, ctx, config)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
end;
|
||||||
|
|
||||||
|
loadDevShell({
|
||||||
|
name = 'web',
|
||||||
pattern = {
|
pattern = {
|
||||||
'javascript',
|
'javascript',
|
||||||
'javascriptreact',
|
'javascriptreact',
|
||||||
|
@ -45,148 +162,21 @@ in {
|
||||||
'typescript.tsx',
|
'typescript.tsx',
|
||||||
'css',
|
'css',
|
||||||
'scss',
|
'scss',
|
||||||
|
'html',
|
||||||
},
|
},
|
||||||
|
pre_shell_callback = function()
|
||||||
callback = function()
|
|
||||||
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
||||||
|
|
||||||
loadDevShell();
|
|
||||||
end,
|
end,
|
||||||
});
|
language_servers = {
|
||||||
|
cssls = cssConfig,
|
||||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
eslint = eslintConfig,
|
||||||
pattern = 'html',
|
html = htmlConfig,
|
||||||
|
ts_ls = typescriptConfig,
|
||||||
callback = function()
|
|
||||||
vim.cmd[[setlocal ts=4 sw=4 sts expandtab]];
|
|
||||||
|
|
||||||
loadDevShell();
|
|
||||||
end,
|
|
||||||
});
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
|
||||||
pattern = 'scss',
|
|
||||||
command = 'setlocal iskeyword+=@-@',
|
|
||||||
});
|
|
||||||
|
|
||||||
tsserver.setup({
|
|
||||||
capabilities = default_capabilities,
|
|
||||||
autostart = false,
|
|
||||||
|
|
||||||
handlers = {
|
|
||||||
-- format error code with better error message
|
|
||||||
['textDocument/publishDiagnostics'] = function(err, result, ctx, config)
|
|
||||||
require('ts-error-translator').translate_diagnostics(err, result, ctx, config)
|
|
||||||
vim.lsp.diagnostic.on_publish_diagnostics(err, result, ctx, config)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
lsp.eslint.setup({
|
|
||||||
capabilities = default_capabilities,
|
|
||||||
autostart = false,
|
|
||||||
|
|
||||||
-- auto-save
|
|
||||||
on_attach = function(client, bufnr)
|
|
||||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
|
||||||
buffer = bufnr,
|
|
||||||
command = 'EslintFixAll',
|
|
||||||
});
|
|
||||||
end,
|
|
||||||
|
|
||||||
settings = {
|
|
||||||
validate = 'on',
|
|
||||||
packageManager = 'npm',
|
|
||||||
useESLintClass = true,
|
|
||||||
useFlatConfig = true,
|
|
||||||
experimental = {
|
|
||||||
useFlatConfig = true,
|
|
||||||
},
|
|
||||||
codeAction = {
|
|
||||||
disableRuleComment = {
|
|
||||||
enable = true,
|
|
||||||
location = 'separateLine'
|
|
||||||
},
|
|
||||||
showDocumentation = {
|
|
||||||
enable = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
codeActionOnSave = {
|
|
||||||
mode = 'all',
|
|
||||||
rules = {},
|
|
||||||
},
|
|
||||||
format = true,
|
|
||||||
quiet = false,
|
|
||||||
onIgnoredFiles = 'off',
|
|
||||||
rulesCustomizations = {},
|
|
||||||
run = 'onType',
|
|
||||||
problems = {
|
|
||||||
shortenToSingleLine = false,
|
|
||||||
},
|
|
||||||
nodePath = "",
|
|
||||||
workingDirectory = {
|
|
||||||
mode = 'location',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
lsp.cssls.setup({
|
|
||||||
capabilities = default_capabilities,
|
|
||||||
autostart = false,
|
|
||||||
|
|
||||||
settings = {
|
|
||||||
css = {
|
|
||||||
validate = false,
|
|
||||||
},
|
|
||||||
less = {
|
|
||||||
validate = false,
|
|
||||||
},
|
|
||||||
scss = {
|
|
||||||
validate = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
lsp.somesass_ls.setup({
|
|
||||||
capabilities = default_capabilities,
|
|
||||||
autostart = false,
|
|
||||||
});
|
|
||||||
lsp.somesass_ls.manager.config.settings = {
|
|
||||||
somesass = {
|
|
||||||
scss = {
|
|
||||||
completion = {
|
|
||||||
suggestFromUseOnly = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
local html_caps = default_capabilities;
|
|
||||||
html_caps.textDocument.completion.completionItem.snippetSupport = true;
|
|
||||||
|
|
||||||
lsp.html.setup({
|
|
||||||
capabilities = html_caps,
|
|
||||||
autostart = false,
|
|
||||||
|
|
||||||
settings = {
|
|
||||||
configurationSection = { "html", "css", "javascript" },
|
|
||||||
embeddedLanguages = {
|
|
||||||
css = true,
|
|
||||||
javascript = true,
|
|
||||||
},
|
|
||||||
provideFormatter = true,
|
|
||||||
tabSize = 4,
|
|
||||||
insertSpaces = true,
|
|
||||||
indentEmptyLines = false,
|
|
||||||
wrapAttributes = 'auto',
|
|
||||||
wrapAttributesIndentSize = 4,
|
|
||||||
endWithNewline = true,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
'';
|
'';
|
||||||
|
|
||||||
plugins = [
|
plugins = [
|
||||||
pkgs.vimPlugins.typescript-tools-nvim
|
|
||||||
(buildPlugin "ts-error-translator" vimplugin-ts-error-translator-src)
|
(buildPlugin "ts-error-translator" vimplugin-ts-error-translator-src)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,8 @@ mkShell {
|
||||||
|
|
||||||
nodePackages.npm
|
nodePackages.npm
|
||||||
|
|
||||||
|
nodePackages.typescript-language-server
|
||||||
|
|
||||||
some-sass-language-server
|
some-sass-language-server
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue