2024-05-07 22:49:00 -04:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
2024-05-09 15:36:57 -04:00
|
|
|
stylelint-lsp,
|
2024-05-09 17:14:55 -04:00
|
|
|
vimplugin-ts-error-translator-src,
|
2024-05-07 22:49:00 -04:00
|
|
|
...
|
|
|
|
}: let
|
|
|
|
inherit (config.vars) neovimIde;
|
|
|
|
inherit (pkgs) vimPlugins;
|
2024-05-09 17:14:55 -04:00
|
|
|
|
|
|
|
buildPlugin = pname: src:
|
|
|
|
pkgs.vimUtils.buildVimPlugin {
|
|
|
|
inherit pname src;
|
|
|
|
version = src.shortRev;
|
|
|
|
};
|
2024-05-07 22:49:00 -04:00
|
|
|
in
|
|
|
|
lib.mkIf neovimIde {
|
|
|
|
programs = {
|
|
|
|
neovim = {
|
|
|
|
withNodeJs = true;
|
|
|
|
|
2024-05-09 15:36:57 -04:00
|
|
|
extraPackages = [
|
|
|
|
pkgs.nodejs_latest
|
|
|
|
pkgs.nodePackages.npm
|
|
|
|
pkgs.nodePackages.neovim
|
|
|
|
|
|
|
|
stylelint-lsp.packages.${pkgs.system}.default
|
|
|
|
pkgs.vscode-langservers-extracted
|
2024-05-07 22:49:00 -04:00
|
|
|
];
|
|
|
|
|
|
|
|
extraLuaConfig =
|
|
|
|
/*
|
|
|
|
lua
|
|
|
|
*/
|
|
|
|
''
|
2024-05-09 17:14:55 -04:00
|
|
|
vim.api.nvim_create_autocmd('FileType', {
|
2024-05-09 15:36:57 -04:00
|
|
|
pattern = { 'javascript', 'typescript', 'css', 'scss' },
|
2024-05-07 22:49:00 -04:00
|
|
|
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
|
|
|
});
|
|
|
|
|
2024-05-09 17:14:55 -04:00
|
|
|
vim.api.nvim_create_autocmd('FileType', {
|
2024-05-07 22:49:00 -04:00
|
|
|
pattern = 'html',
|
|
|
|
command = 'setlocal ts=2 sw=2 expandtab',
|
|
|
|
});
|
|
|
|
|
2024-05-09 17:14:55 -04:00
|
|
|
vim.api.nvim_create_autocmd('FileType', {
|
2024-05-07 22:49:00 -04:00
|
|
|
pattern = 'scss',
|
2024-05-09 15:36:57 -04:00
|
|
|
command = 'setlocal iskeyword+=@-@',
|
2024-05-07 22:49:00 -04:00
|
|
|
});
|
2024-05-09 15:36:57 -04:00
|
|
|
|
|
|
|
local lsp = require('lspconfig');
|
|
|
|
local coq = require('coq');
|
2024-05-09 17:14:55 -04:00
|
|
|
local tsserver = require('typescript-tools');
|
2024-05-09 15:36:57 -04:00
|
|
|
|
2024-05-09 17:14:55 -04:00
|
|
|
tsserver.setup(coq.lsp_ensure_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,
|
|
|
|
},
|
|
|
|
}));
|
2024-05-09 15:36:57 -04:00
|
|
|
|
|
|
|
lsp.eslint.setup(coq.lsp_ensure_capabilities({
|
|
|
|
-- auto-save
|
|
|
|
on_attach = function(client, bufnr)
|
|
|
|
vim.api.nvim_create_autocmd('BufWritePre', {
|
|
|
|
buffer = bufnr,
|
|
|
|
command = 'EslintFixAll',
|
|
|
|
});
|
|
|
|
end,
|
|
|
|
}));
|
|
|
|
|
|
|
|
lsp.cssls.setup(coq.lsp_ensure_capabilities({
|
|
|
|
settings = {
|
|
|
|
css = {
|
|
|
|
validate = false,
|
|
|
|
},
|
|
|
|
less = {
|
|
|
|
validate = false,
|
|
|
|
},
|
|
|
|
scss = {
|
|
|
|
validate = false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
2024-05-09 17:14:55 -04:00
|
|
|
lsp.stylelint_lsp.setup(coq.lsp_ensure_capabilities({
|
2024-05-09 15:36:57 -04:00
|
|
|
settings = {
|
|
|
|
stylelintplus = {},
|
|
|
|
},
|
|
|
|
}));
|
2024-05-07 22:49:00 -04:00
|
|
|
'';
|
|
|
|
|
|
|
|
plugins = [
|
2024-05-09 15:36:57 -04:00
|
|
|
vimPlugins.typescript-tools-nvim
|
2024-05-09 17:14:55 -04:00
|
|
|
|
|
|
|
{
|
|
|
|
plugin = buildPlugin "ts-error-translator" vimplugin-ts-error-translator-src;
|
|
|
|
}
|
2024-05-07 22:49:00 -04:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|