nvim-configs/lua/plugins/tsdev.lua

98 lines
3.5 KiB
Lua
Raw Normal View History

2024-10-06 13:13:53 +08:00
return {
{
"pmizio/typescript-tools.nvim",
dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
opts = {},
config = function()
2024-10-20 18:30:12 +08:00
require'lspconfig'.cssls.setup{}
2024-10-11 00:34:52 +08:00
require('typescript-tools').setup({
settings = {
complete_function_calls = true,
}
})
2024-10-09 14:15:34 +08:00
2024-10-10 15:09:25 +08:00
vim.keymap.set('n', '<leader>co', function()
2024-10-09 14:15:34 +08:00
vim.cmd [[TSToolsOrganizeImports]]
end, {desc = "TSTools Organize Imports"})
2024-10-10 15:09:25 +08:00
vim.keymap.set('n', '<leader>ci', function()
2024-10-09 14:15:34 +08:00
vim.cmd [[TSToolsAddMissingImports]]
end, {desc = "TSTools Add Missing Imports"})
2024-10-06 13:13:53 +08:00
end
},{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
},
config = function()
2024-10-06 16:05:50 +08:00
local cmp = require('cmp')
cmp.setup({
2024-10-06 13:13:53 +08:00
completion = {
keyword_length = 1,
max_item_count = 6
},
sources = {
{ name = "nvim_lsp", keyword_length = 1, max_item_count = 6 },
{ name = "buffer", keyword_length = 1, max_item_count = 6 },
{ name = "path", keyword_length = 1, max_item_count = 6 },
2024-10-06 16:05:50 +08:00
},
mapping = {
['<C-n>'] = cmp.mapping(cmp.mapping.select_next_item(), {'i', 'c'}),
['<C-p>'] = cmp.mapping(cmp.mapping.select_prev_item(), {'i', 'c'}),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- accept currently selected item
2024-10-06 13:13:53 +08:00
}
})
end
},{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
config = function ()
local configs = require("nvim-treesitter.configs")
configs.setup({
ensure_installed = { "tsx", "typescript", "javascript", "html" },
sync_install = false,
highlight = { enable = true },
indent = { enable = true },
})
end
2024-10-06 16:05:50 +08:00
},
{
'stevearc/conform.nvim',
opts = {},
config = function()
2024-10-06 16:25:01 +08:00
local conform = require('conform')
conform.setup({
2024-10-06 16:05:50 +08:00
formatters_by_ft = {
-- lua = { "stylua" },
-- Conform will run multiple formatters sequentially
-- python = { "isort", "black" },
-- You can customize some of the format options for the filetype (:help conform.format)
-- rust = { "rustfmt", lsp_format = "fallback" },
-- Conform will run the first available formatter
javascript = { "prettierd" },
typescript = { "prettierd" },
css = { "prettierd" },
less = { "prettierd" },
html = { "prettierd" },
},
})
2024-10-06 16:25:01 +08:00
vim.keymap.set("n", "==", function()
conform.format({async = true, lsp_format = "fallback"})
end, { desc = "Conform format" })
vim.keymap.set("v", "=", function()
conform.format({async = true, lsp_format = "fallback"})
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>", true, false, true), "n", true)
end, { desc = "Conform format" })
2024-10-06 16:05:50 +08:00
end
2024-10-06 13:13:53 +08:00
}
2024-10-06 16:05:50 +08:00
2024-10-06 13:13:53 +08:00
}