feat(nvim): setup ts-error-translator.nvim
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-05-09 17:14:55 -04:00
parent 772374b0fd
commit 9b749922ea
6 changed files with 53 additions and 10 deletions

View file

@ -24,7 +24,7 @@ in {
lua lua
*/ */
'' ''
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd('FileType', {
pattern = 'sh', pattern = 'sh',
command = 'setlocal ts=4 sw=4 sts=0 expandtab', command = 'setlocal ts=4 sw=4 sts=0 expandtab',
}); });

View file

@ -14,10 +14,10 @@ in
*/ */
'' ''
vim.filetype.add({ vim.filetype.add({
pattern = { [".*/hypr/.*%.conf"] = "hyprlang" }, pattern = { ['.*/hypr/.*%.conf'] = 'hyprlang' },
}); });
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd('FileType', {
pattern = 'hyprlang', pattern = 'hyprlang',
command = 'setlocal ts=4 sw=4 sts=0 expandtab', command = 'setlocal ts=4 sw=4 sts=0 expandtab',
}); });

View file

@ -31,7 +31,7 @@ in
lua lua
*/ */
'' ''
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd('FileType', {
pattern = 'java', pattern = 'java',
command = 'setlocal ts=4 sw=4 sts=0 expandtab', command = 'setlocal ts=4 sw=4 sts=0 expandtab',
}); });

View file

@ -3,10 +3,17 @@
pkgs, pkgs,
lib, lib,
stylelint-lsp, stylelint-lsp,
vimplugin-ts-error-translator-src,
... ...
}: let }: let
inherit (config.vars) neovimIde; inherit (config.vars) neovimIde;
inherit (pkgs) vimPlugins; inherit (pkgs) vimPlugins;
buildPlugin = pname: src:
pkgs.vimUtils.buildVimPlugin {
inherit pname src;
version = src.shortRev;
};
in in
lib.mkIf neovimIde { lib.mkIf neovimIde {
programs = { programs = {
@ -27,26 +34,34 @@ in
lua lua
*/ */
'' ''
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd('FileType', {
pattern = { 'javascript', 'typescript', 'css', 'scss' }, pattern = { 'javascript', 'typescript', 'css', 'scss' },
command = 'setlocal ts=4 sw=4 sts=0 expandtab', command = 'setlocal ts=4 sw=4 sts=0 expandtab',
}); });
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd('FileType', {
pattern = 'html', pattern = 'html',
command = 'setlocal ts=2 sw=2 expandtab', command = 'setlocal ts=2 sw=2 expandtab',
}); });
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd('FileType', {
pattern = 'scss', pattern = 'scss',
command = 'setlocal iskeyword+=@-@', command = 'setlocal iskeyword+=@-@',
}); });
local lsp = require('lspconfig'); local lsp = require('lspconfig');
local coq = require('coq'); local coq = require('coq');
local tsserver = require("typescript-tools"); local tsserver = require('typescript-tools');
tsserver.setup(coq.lsp_ensure_capabilities({})); 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({ lsp.eslint.setup(coq.lsp_ensure_capabilities({
-- auto-save -- auto-save
@ -72,7 +87,7 @@ in
}, },
})); }));
require('lspconfig').stylelint_lsp.setup(coq.lsp_ensure_capabilities({ lsp.stylelint_lsp.setup(coq.lsp_ensure_capabilities({
settings = { settings = {
stylelintplus = {}, stylelintplus = {},
}, },
@ -81,6 +96,10 @@ in
plugins = [ plugins = [
vimPlugins.typescript-tools-nvim vimPlugins.typescript-tools-nvim
{
plugin = buildPlugin "ts-error-translator" vimplugin-ts-error-translator-src;
}
]; ];
}; };
}; };

View file

@ -1730,6 +1730,7 @@
"touch-gestures-src": "touch-gestures-src", "touch-gestures-src": "touch-gestures-src",
"trash-d-src": "trash-d-src", "trash-d-src": "trash-d-src",
"vimplugin-easytables-src": "vimplugin-easytables-src", "vimplugin-easytables-src": "vimplugin-easytables-src",
"vimplugin-ts-error-translator-src": "vimplugin-ts-error-translator-src",
"wpaperd": "wpaperd", "wpaperd": "wpaperd",
"xresources-theme-src": "xresources-theme-src" "xresources-theme-src": "xresources-theme-src"
} }
@ -2056,6 +2057,22 @@
"type": "github" "type": "github"
} }
}, },
"vimplugin-ts-error-translator-src": {
"flake": false,
"locked": {
"lastModified": 1712269172,
"narHash": "sha256-NJ0qfKvkwZ/0GolAeATlQLyQ7nGN6Z6q3uRqI+73wPk=",
"owner": "dmmulroy",
"repo": "ts-error-translator.nvim",
"rev": "11ae55b28bde02663b5f983f59b0e3fd9c4e845b",
"type": "github"
},
"original": {
"owner": "dmmulroy",
"repo": "ts-error-translator.nvim",
"type": "github"
}
},
"wpaperd": { "wpaperd": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [

View file

@ -354,6 +354,13 @@
repo = "easytables.nvim"; repo = "easytables.nvim";
flake = false; flake = false;
}; };
vimplugin-ts-error-translator-src = {
type = "github";
owner = "dmmulroy";
repo = "ts-error-translator.nvim";
flake = false;
};
# #
# Nix tools # Nix tools