2024-05-07 22:49:00 -04:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
2024-08-05 16:40:32 -04:00
|
|
|
pkgs,
|
|
|
|
self,
|
2024-05-09 17:14:55 -04:00
|
|
|
vimplugin-ts-error-translator-src,
|
2024-05-07 22:49:00 -04:00
|
|
|
...
|
|
|
|
}: let
|
2024-08-31 19:16:06 -04:00
|
|
|
inherit (lib) mkIf;
|
2024-05-07 22:49:00 -04:00
|
|
|
inherit (config.vars) neovimIde;
|
2024-05-09 17:14:55 -04:00
|
|
|
|
2024-08-07 14:47:32 -04:00
|
|
|
inherit (import "${self}/lib" {inherit pkgs;}) buildPlugin;
|
2024-05-07 22:49:00 -04:00
|
|
|
in
|
2024-08-31 19:16:06 -04:00
|
|
|
mkIf neovimIde {
|
2024-05-07 22:49:00 -04:00
|
|
|
programs = {
|
|
|
|
neovim = {
|
|
|
|
withNodeJs = true;
|
|
|
|
|
2024-08-31 19:16:06 -04:00
|
|
|
extraPackages = builtins.attrValues {
|
|
|
|
inherit
|
|
|
|
(pkgs)
|
|
|
|
nodejs_latest
|
|
|
|
vscode-langservers-extracted
|
|
|
|
;
|
2024-05-09 15:36:57 -04:00
|
|
|
|
2024-08-31 19:16:06 -04:00
|
|
|
inherit
|
|
|
|
(pkgs.nodePackages)
|
|
|
|
npm
|
|
|
|
neovim
|
|
|
|
;
|
|
|
|
};
|
2024-05-07 22:49:00 -04:00
|
|
|
|
|
|
|
extraLuaConfig =
|
2024-06-09 22:49:30 -04:00
|
|
|
# lua
|
2024-05-07 22:49:00 -04:00
|
|
|
''
|
2024-05-09 17:14:55 -04:00
|
|
|
vim.api.nvim_create_autocmd('FileType', {
|
2024-08-01 12:54:32 -04:00
|
|
|
pattern = { 'javascript', 'typescript', 'css', 'scss' },
|
|
|
|
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
|
2024-05-07 22:49:00 -04:00
|
|
|
});
|
|
|
|
|
2024-05-09 17:14:55 -04:00
|
|
|
vim.api.nvim_create_autocmd('FileType', {
|
2024-08-01 12:54:32 -04:00
|
|
|
pattern = 'html',
|
|
|
|
command = 'setlocal ts=2 sw=2 expandtab',
|
2024-05-07 22:49:00 -04:00
|
|
|
});
|
|
|
|
|
2024-05-09 17:14:55 -04:00
|
|
|
vim.api.nvim_create_autocmd('FileType', {
|
2024-08-01 12:54:32 -04:00
|
|
|
pattern = 'scss',
|
|
|
|
command = 'setlocal iskeyword+=@-@',
|
2024-05-07 22:49:00 -04:00
|
|
|
});
|
2024-05-09 15:36:57 -04:00
|
|
|
|
|
|
|
local lsp = require('lspconfig');
|
2024-05-09 17:14:55 -04:00
|
|
|
local tsserver = require('typescript-tools');
|
2024-05-09 15:36:57 -04:00
|
|
|
|
2024-07-28 02:54:34 -04:00
|
|
|
tsserver.setup({
|
|
|
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
|
|
|
|
2024-05-09 17:14:55 -04:00
|
|
|
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-07-28 02:54:34 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
lsp.eslint.setup({
|
|
|
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
2024-05-09 15:36:57 -04:00
|
|
|
|
|
|
|
-- auto-save
|
|
|
|
on_attach = function(client, bufnr)
|
|
|
|
vim.api.nvim_create_autocmd('BufWritePre', {
|
|
|
|
buffer = bufnr,
|
|
|
|
command = 'EslintFixAll',
|
|
|
|
});
|
|
|
|
end,
|
2024-08-01 12:54:32 -04:00
|
|
|
|
|
|
|
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',
|
|
|
|
},
|
2024-09-12 10:42:35 -04:00
|
|
|
options = {
|
|
|
|
flags = {'unstable_ts_config'},
|
|
|
|
},
|
2024-08-01 12:54:32 -04:00
|
|
|
},
|
2024-07-28 02:54:34 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
lsp.cssls.setup({
|
|
|
|
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
2024-05-09 15:36:57 -04:00
|
|
|
|
|
|
|
settings = {
|
|
|
|
css = {
|
|
|
|
validate = false,
|
|
|
|
},
|
|
|
|
less = {
|
|
|
|
validate = false,
|
|
|
|
},
|
|
|
|
scss = {
|
|
|
|
validate = false,
|
|
|
|
},
|
|
|
|
},
|
2024-07-28 02:54:34 -04:00
|
|
|
});
|
2024-05-07 22:49:00 -04:00
|
|
|
'';
|
|
|
|
|
|
|
|
plugins = [
|
2024-08-31 19:16:06 -04:00
|
|
|
pkgs.vimPlugins.typescript-tools-nvim
|
2024-05-15 18:55:07 -04:00
|
|
|
(buildPlugin "ts-error-translator" vimplugin-ts-error-translator-src)
|
2024-07-28 02:54:34 -04:00
|
|
|
|
|
|
|
{
|
2024-08-31 19:16:06 -04:00
|
|
|
plugin = pkgs.vimPlugins.package-info-nvim;
|
2024-07-28 02:54:34 -04:00
|
|
|
type = "lua";
|
|
|
|
config =
|
|
|
|
# lua
|
|
|
|
''
|
|
|
|
local packageInfo = require('package-info');
|
|
|
|
packageInfo.setup({
|
|
|
|
hide_up_to_date = true,
|
|
|
|
package_manager = 'npm',
|
|
|
|
});
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
|
|
|
|
pattern = { 'package.json' },
|
|
|
|
callback = function()
|
|
|
|
packageInfo.show({ force = true });
|
|
|
|
end,
|
|
|
|
});
|
|
|
|
'';
|
|
|
|
}
|
2024-05-07 22:49:00 -04:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|