dotfiles/nvim/.config/nvim/after/ftplugin/typescript.lua

44 lines
1.8 KiB
Lua

local root_files = { 'jsconfig.json', 'tsconfig.json', 'package.json' }
local file_types = { 'javascript', 'javascriptreact', 'javascript.jsx', 'typescript', 'typescriptreact', 'typescript.tsx' }
local path = vim.fs.find(root_files, { type = "file" })
vim.lsp.start({
name = "tsserver",
cmd = { "typescript-language-server", "--stdio" },
root_dir = vim.fs.dirname(path[1]),
filetypes = file_types,
settings = {
typescript = {
inlayHints = {
includeInlayParameterNameHints = 'all',
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
}
},
javascript = {
inlayHints = {
includeInlayParameterNameHints = 'all',
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
}
}
}
})
vim.keymap.set('n', 'gq', "<cmd>!npx prettier --write %:p<CR>:e<CR>", { noremap=true, silent=true, buffer=0 })
vim.api.nvim_create_autocmd({ "BufReadPre", "BufWinEnter" }, {
pattern = { "*/node_modules/*" },
callback = function()
vim.bo.buflisted = false
end,
})