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',
|
||||
});
|
||||
|
||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
||||
|
||||
require('lspconfig').bashls.setup({
|
||||
capabilities = default_capabilities,
|
||||
vim.lsp.enable('bashls');
|
||||
vim.lsp.config('bashls', {
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
|
||||
settings = {
|
||||
bashIde = {
|
||||
|
|
|
@ -7,32 +7,10 @@
|
|||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
programs = {
|
||||
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 = [
|
||||
{
|
||||
plugin = pkgs.vimPlugins.clangd_extensions-nvim;
|
||||
|
@ -41,22 +19,31 @@ in {
|
|||
# lua
|
||||
''
|
||||
--
|
||||
local lsp = require('lspconfig');
|
||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
||||
|
||||
|
||||
lsp.cmake.setup({
|
||||
loadDevShell({
|
||||
name = 'c-lang',
|
||||
pattern = { 'cpp', 'c' },
|
||||
pre_shell_callback = function()
|
||||
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
||||
end,
|
||||
language_servers = {
|
||||
cmake = function()
|
||||
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['cmake'], {
|
||||
capabilities = default_capabilities,
|
||||
autostart = false,
|
||||
});
|
||||
}));
|
||||
end,
|
||||
|
||||
lsp.clangd.setup({
|
||||
clangd = function()
|
||||
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['clangd'], {
|
||||
capabilities = default_capabilities,
|
||||
autostart = false,
|
||||
|
||||
on_attach = function(_, bufnr)
|
||||
require('clangd_extensions').setup();
|
||||
end,
|
||||
}));
|
||||
end,
|
||||
},
|
||||
});
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ self: {
|
|||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
programs = {
|
||||
|
@ -60,23 +59,17 @@ in {
|
|||
|
||||
exe = 'Microsoft.CodeAnalysis.LanguageServer',
|
||||
});
|
||||
|
||||
vim.cmd[[e]]; -- reload to attach on current file
|
||||
end;
|
||||
|
||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
||||
loadDevShell({
|
||||
name = 'csharp',
|
||||
pattern = { 'cs' },
|
||||
|
||||
callback = function()
|
||||
pre_shell_callback = function()
|
||||
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,
|
||||
post_shell_callback = startRoslyn,
|
||||
});
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ self: {
|
|||
inherit (lib) attrValues fileContents mkBefore mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
||||
in {
|
||||
imports = [
|
||||
./bash
|
||||
|
@ -37,9 +38,51 @@ in {
|
|||
# lua
|
||||
''
|
||||
--
|
||||
local nix_develop = require('nix-develop');
|
||||
|
||||
-- Init object to keep track of loaded 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
|
||||
vim.api.nvim_create_user_command(
|
||||
'Format',
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
programs = {
|
||||
|
@ -15,28 +14,19 @@ in {
|
|||
# lua
|
||||
''
|
||||
--
|
||||
local lsp = require('lspconfig');
|
||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
||||
|
||||
lsp.gopls.setup({
|
||||
capabilities = default_capabilities,
|
||||
autostart = false,
|
||||
});
|
||||
|
||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
||||
loadDevShell({
|
||||
name = 'golang',
|
||||
pattern = { 'go', 'gomod', 'gowork', 'gotmpl' },
|
||||
|
||||
callback = function()
|
||||
pre_shell_callback = function()
|
||||
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,
|
||||
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;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
programs = {
|
||||
|
@ -15,33 +14,24 @@ in {
|
|||
# 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();
|
||||
|
||||
lsp.jsonls.setup({
|
||||
loadDevShell({
|
||||
name = 'json',
|
||||
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,
|
||||
autostart = false,
|
||||
});
|
||||
}));
|
||||
end,
|
||||
|
||||
lsp.yamlls.setup({
|
||||
yamlls = function()
|
||||
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['yamlls'], {
|
||||
capabilities = default_capabilities,
|
||||
autostart = false,
|
||||
|
||||
settings = {
|
||||
yaml = {
|
||||
|
@ -56,6 +46,9 @@ in {
|
|||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
end,
|
||||
},
|
||||
});
|
||||
'';
|
||||
};
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
programs = {
|
||||
|
@ -15,28 +14,19 @@ in {
|
|||
# lua
|
||||
''
|
||||
--
|
||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
||||
loadDevShell({
|
||||
name = 'kotlin',
|
||||
pattern = { 'kotlin' },
|
||||
|
||||
callback = function()
|
||||
pre_shell_callback = function()
|
||||
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,
|
||||
});
|
||||
|
||||
local lsp = require('lspconfig');
|
||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
||||
|
||||
lsp.kotlin_language_server.setup({
|
||||
capabilities = default_capabilities,
|
||||
autostart = false,
|
||||
language_servers = {
|
||||
rust_analyzer = function()
|
||||
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['kotlin_language_server'], {
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
}));
|
||||
end,
|
||||
},
|
||||
});
|
||||
'';
|
||||
};
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
|
||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
programs = {
|
||||
|
@ -21,24 +19,14 @@ in {
|
|||
# lua
|
||||
''
|
||||
--
|
||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
||||
|
||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
||||
pattern = 'lua',
|
||||
|
||||
callback = function()
|
||||
loadDevShell({
|
||||
name = 'lua',
|
||||
pattern = { 'lua' },
|
||||
pre_shell_callback = function()
|
||||
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,
|
||||
});
|
||||
|
||||
language_servers = {
|
||||
lua_ls = function()
|
||||
require('lazydev').setup({
|
||||
library = {
|
||||
-- Load luvit types when the `vim.uv` word is found
|
||||
|
@ -46,9 +34,11 @@ in {
|
|||
},
|
||||
});
|
||||
|
||||
require('lspconfig').lua_ls.setup({
|
||||
capabilities = default_capabilities,
|
||||
autostart = false,
|
||||
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['lua_ls'], {
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
}));
|
||||
end,
|
||||
},
|
||||
});
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ self: {
|
|||
inherit (lib) concatStringsSep mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
||||
isServer = osConfig.roles.server.sshd.enable or false;
|
||||
isDesktop = osConfig.roles.desktop.enable or false;
|
||||
|
||||
|
@ -28,27 +27,16 @@ in {
|
|||
# lua
|
||||
''
|
||||
--
|
||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
||||
loadDevShell({
|
||||
name = 'markdown',
|
||||
pattern = { 'markdown', 'tex' },
|
||||
|
||||
callback = function()
|
||||
pre_shell_callback = function()
|
||||
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,
|
||||
});
|
||||
|
||||
local lsp = require('lspconfig');
|
||||
|
||||
lsp.texlab.setup({
|
||||
language_servers = {
|
||||
texlab = function()
|
||||
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['texlab'], {
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
autostart = false,
|
||||
|
||||
settings = {
|
||||
texlab = {
|
||||
|
@ -60,6 +48,9 @@ in {
|
|||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
end,
|
||||
},
|
||||
});
|
||||
'';
|
||||
|
||||
|
|
|
@ -75,7 +75,8 @@ in {
|
|||
# lua
|
||||
''
|
||||
--
|
||||
require('lspconfig').nixd.setup({
|
||||
vim.lsp.enable('nixd');
|
||||
vim.lsp.config('nixd', {
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
|
||||
filetypes = { 'nix', 'in.nix' },
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
programs = {
|
||||
|
@ -15,38 +14,31 @@ in {
|
|||
# lua
|
||||
''
|
||||
--
|
||||
local lsp = require('lspconfig');
|
||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
||||
|
||||
lsp.basedpyright.setup({
|
||||
loadDevShell({
|
||||
name = 'python',
|
||||
pattern = { 'python' },
|
||||
pre_shell_callback = function()
|
||||
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
||||
end,
|
||||
language_servers = {
|
||||
basedpyright = function()
|
||||
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['basedpyright'], {
|
||||
capabilities = default_capabilities,
|
||||
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' },
|
||||
|
||||
callback = function()
|
||||
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,
|
||||
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;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
programs = {
|
||||
|
@ -15,30 +14,24 @@ in {
|
|||
# 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 default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
||||
|
||||
lsp.qmlls.setup({
|
||||
loadDevShell({
|
||||
name = 'qml',
|
||||
pattern = { 'qml' },
|
||||
pre_shell_callback = function()
|
||||
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,
|
||||
autostart = false,
|
||||
}));
|
||||
end,
|
||||
},
|
||||
});
|
||||
'';
|
||||
};
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
programs = {
|
||||
|
@ -15,25 +14,19 @@ in {
|
|||
# lua
|
||||
''
|
||||
--
|
||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
||||
loadDevShell({
|
||||
name = 'rust',
|
||||
pattern = { 'rust' },
|
||||
|
||||
callback = function()
|
||||
pre_shell_callback = function()
|
||||
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,
|
||||
});
|
||||
|
||||
require('lspconfig').rust_analyzer.setup({
|
||||
language_servers = {
|
||||
rust_analyzer = function()
|
||||
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['rust_analyzer'], {
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
autostart = false,
|
||||
}));
|
||||
end,
|
||||
},
|
||||
});
|
||||
'';
|
||||
};
|
||||
|
|
|
@ -10,7 +10,6 @@ self: {
|
|||
inherit (lib) mkIf;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
programs = {
|
||||
|
@ -21,76 +20,22 @@ in {
|
|||
# lua
|
||||
''
|
||||
--
|
||||
local lsp = require('lspconfig');
|
||||
local tsserver = require('typescript-tools');
|
||||
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
||||
|
||||
local loadDevShell = function()
|
||||
if (devShells['web'] == nil) then
|
||||
devShells['web'] = 1;
|
||||
local eslintConfig = function()
|
||||
local config = vim.lsp.config['eslint'];
|
||||
config.before_init = nil;
|
||||
|
||||
require('nix-develop').nix_develop_extend({'${flakeEnv}#web'}, function()
|
||||
vim.cmd[[LspStart]];
|
||||
end);
|
||||
end
|
||||
end;
|
||||
|
||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
||||
pattern = {
|
||||
'javascript',
|
||||
'javascriptreact',
|
||||
'javascript.jsx',
|
||||
'typescript',
|
||||
'typescriptreact',
|
||||
'typescript.tsx',
|
||||
'css',
|
||||
'scss',
|
||||
},
|
||||
|
||||
callback = function()
|
||||
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
||||
|
||||
loadDevShell();
|
||||
end,
|
||||
});
|
||||
|
||||
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
|
||||
pattern = 'html',
|
||||
|
||||
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({
|
||||
vim.lsp.start(vim.tbl_deep_extend('force', config, {
|
||||
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.lsp.config['eslint'].on_attach(client, bufnr);
|
||||
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
buffer = bufnr,
|
||||
command = 'EslintFixAll',
|
||||
command = 'LspEslintFixAll',
|
||||
});
|
||||
end,
|
||||
|
||||
|
@ -128,11 +73,16 @@ in {
|
|||
mode = 'location',
|
||||
},
|
||||
},
|
||||
});
|
||||
}));
|
||||
end;
|
||||
|
||||
lsp.cssls.setup({
|
||||
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,
|
||||
autostart = false,
|
||||
|
||||
settings = {
|
||||
css = {
|
||||
|
@ -145,13 +95,12 @@ in {
|
|||
validate = false,
|
||||
},
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
lsp.somesass_ls.setup({
|
||||
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['somesass_ls'], {
|
||||
capabilities = default_capabilities,
|
||||
autostart = false,
|
||||
});
|
||||
lsp.somesass_ls.manager.config.settings = {
|
||||
|
||||
settings = {
|
||||
somesass = {
|
||||
scss = {
|
||||
completion = {
|
||||
|
@ -160,11 +109,14 @@ in {
|
|||
},
|
||||
},
|
||||
};
|
||||
}));
|
||||
end;
|
||||
|
||||
local htmlConfig = function()
|
||||
local html_caps = default_capabilities;
|
||||
html_caps.textDocument.completion.completionItem.snippetSupport = true;
|
||||
|
||||
lsp.html.setup({
|
||||
vim.lsp.start(vim.tbl_deep_extend('force', vim.lsp.config['html'], {
|
||||
capabilities = html_caps,
|
||||
autostart = false,
|
||||
|
||||
|
@ -182,11 +134,49 @@ in {
|
|||
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 = {
|
||||
'javascript',
|
||||
'javascriptreact',
|
||||
'javascript.jsx',
|
||||
'typescript',
|
||||
'typescriptreact',
|
||||
'typescript.tsx',
|
||||
'css',
|
||||
'scss',
|
||||
'html',
|
||||
},
|
||||
pre_shell_callback = function()
|
||||
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
||||
end,
|
||||
language_servers = {
|
||||
cssls = cssConfig,
|
||||
eslint = eslintConfig,
|
||||
html = htmlConfig,
|
||||
ts_ls = typescriptConfig,
|
||||
},
|
||||
});
|
||||
'';
|
||||
|
||||
plugins = [
|
||||
pkgs.vimPlugins.typescript-tools-nvim
|
||||
(buildPlugin "ts-error-translator" vimplugin-ts-error-translator-src)
|
||||
|
||||
{
|
||||
|
|
|
@ -15,6 +15,8 @@ mkShell {
|
|||
|
||||
nodePackages.npm
|
||||
|
||||
nodePackages.typescript-language-server
|
||||
|
||||
some-sass-language-server
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue