nixos-configs/common/home/neovim/langs/web.nix
matt1432 fc98b6020d
All checks were successful
Discord / discord commits (push) Has been skipped
feat: remove stylelint and neofetch
2024-07-09 14:17:03 -04:00

89 lines
2.6 KiB
Nix

{
config,
pkgs,
lib,
vimplugin-ts-error-translator-src,
...
}: let
inherit (config.vars) neovimIde;
inherit (pkgs) vimPlugins;
inherit (import ../../../../lib.nix {inherit pkgs;}) buildPlugin;
in
lib.mkIf neovimIde {
programs = {
neovim = {
withNodeJs = true;
extraPackages = [
pkgs.nodejs_latest
pkgs.nodePackages.npm
pkgs.nodePackages.neovim
pkgs.vscode-langservers-extracted
];
extraLuaConfig =
# lua
''
vim.api.nvim_create_autocmd('FileType', {
pattern = { 'javascript', 'typescript', 'css', 'scss' },
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
});
vim.api.nvim_create_autocmd('FileType', {
pattern = 'html',
command = 'setlocal ts=2 sw=2 expandtab',
});
vim.api.nvim_create_autocmd('FileType', {
pattern = 'scss',
command = 'setlocal iskeyword+=@-@',
});
local lsp = require('lspconfig');
local coq = require('coq');
local tsserver = require('typescript-tools');
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,
},
}));
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,
},
},
}));
'';
plugins = [
vimPlugins.typescript-tools-nvim
(buildPlugin "ts-error-translator" vimplugin-ts-error-translator-src)
];
};
};
}