fix: tsx support lsp and treesitter

This commit is contained in:
asep komarudin 2024-02-18 21:29:22 +07:00
parent 523588ee4f
commit a25f1abde3
7 changed files with 118 additions and 5 deletions

View file

@ -0,0 +1,10 @@
return {
-- "pmizio/typescript-tools.nvim",
-- event = "BufRead",
-- dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
-- config = function()
-- require("typescript-tools").setup({
-- on_attach = require("user.lsp.handlers").on_attach,
-- })
-- end,
}

View file

@ -4,6 +4,8 @@ if not status_ok then
return
end
local Rule = require("nvim-autopairs.rule")
npairs.setup({
check_ts = true,
ts_config = {
@ -14,7 +16,7 @@ npairs.setup({
disable_filetype = { "TelescopePrompt", "spectre_panel" },
fast_wrap = {
map = "<M-e>",
chars = { "{", "[", "(", '"', "'" },
chars = { "{", "[", "(", '"', "'", "`" },
pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""),
offset = 0, -- Offset from pattern match
end_key = "$",
@ -25,6 +27,14 @@ npairs.setup({
},
})
npairs.add_rules({
Rule("/", ">"):with_pair(function(opts)
local pair = opts.line:sub(opts.col, opts.col + 1)
if (vim.bo.filetype == "jsx" or vim.bo.filetype == "tsx") and pair == "/" then
return npairs.esc("/>") .. "<esc>i"
end
end),
})
-- If you want insert `(` after select function or method item
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local cmp_status_ok, cmp = pcall(require, "cmp")

View file

@ -101,6 +101,10 @@ M.on_attach = function(client, bufnr)
client.server_capabilities.documentFormattingProvider = false
end
if client.supports_method("textDocument/inlayHint") then
vim.lsp.inlay_hint.enable(bufnr, true)
end
lsp_keymaps(bufnr)
local status_ok, illuminate = pcall(require, "illuminate")
if not status_ok then

View file

@ -30,11 +30,11 @@ configs.setup({
-- },
rainbow = {
enable = true,
disable = { "html" },
disable = { "html", "jsx" },
equery = "rainbow-parens",
strategy = require("ts-rainbow").strategy.global,
},
autotag = { enable = true },
-- autotag = { enable = true, enable_rename = true, enable_close = true, enable_close_on_slash = true },
incremental_selection = { enable = true },
indent = { enable = true, disable = { "python", "css" } },
autopairs = {

View file

@ -27,6 +27,12 @@ material_icon.setup({
cterm_color = "220",
name = "jsx",
},
["tsx"] = {
icon = "",
color = "#1354bf",
cterm_color = "220",
name = "Tsx",
},
["svg"] = {
icon = "󰜡",
color = "#FDB03A",