Neovim: Add typescript LSP
This commit is contained in:
parent
8c6e4e9ca5
commit
f73fbed43a
3 changed files with 38 additions and 1 deletions
|
@ -11,6 +11,7 @@
|
|||
# LSP
|
||||
lua-language-server
|
||||
lua
|
||||
pkgs.nodePackages.typescript-language-server
|
||||
|
||||
# Formatters
|
||||
stylua # lua
|
||||
|
@ -19,6 +20,8 @@
|
|||
clang-tools_16 # c/c++
|
||||
rustfmt
|
||||
yamlfmt
|
||||
prettierd
|
||||
vscode-langservers-extracted
|
||||
|
||||
# Linters
|
||||
ruff # python
|
||||
|
@ -184,7 +187,7 @@ in {
|
|||
|
||||
{
|
||||
plugin = nvim-autopairs;
|
||||
config = "require('nvim-autopairs').setup({})";
|
||||
config = "require('nvim-autopairs').setup()";
|
||||
type = "lua";
|
||||
}
|
||||
|
||||
|
@ -207,6 +210,12 @@ in {
|
|||
config = builtins.readFile ./plugin/vim-tmux-navigator.lua;
|
||||
type = "lua";
|
||||
}
|
||||
|
||||
{
|
||||
plugin = nvim-ts-autotag;
|
||||
config = "require('nvim-ts-autotag').setup({})";
|
||||
type = "lua";
|
||||
}
|
||||
];
|
||||
|
||||
extraLuaConfig = ''
|
||||
|
|
|
@ -43,3 +43,25 @@ require("lspconfig").nixd.setup({
|
|||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
require("lspconfig").tsserver.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
require("lspconfig").eslint.setup({
|
||||
settings = {
|
||||
packageManager = "yarn",
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
buffer = bufnr,
|
||||
command = "EslintFixAll",
|
||||
})
|
||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||
callback = function()
|
||||
vim.lsp.buf.format()
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -19,6 +19,12 @@ local opts = {
|
|||
null_ls.builtins.formatting.rustfmt,
|
||||
-- YAML
|
||||
null_ls.builtins.formatting.yamlfmt,
|
||||
-- Typescript
|
||||
null_ls.builtins.formatting.prettier.with({
|
||||
condition = function(utils)
|
||||
return utils.has_file({ ".prettierrc.js" })
|
||||
end,
|
||||
}),
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
|
|
Loading…
Reference in a new issue