146 lines
5.6 KiB
Lua
146 lines
5.6 KiB
Lua
return {
|
|
{
|
|
"pmizio/typescript-tools.nvim",
|
|
dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
|
|
opts = {},
|
|
config = function()
|
|
local lspconfig = require('lspconfig')
|
|
require('typescript-tools').setup({
|
|
settings = {
|
|
complete_function_calls = true,
|
|
},
|
|
root_dir = lspconfig.util.root_pattern("package.json"),
|
|
single_file_support = false,
|
|
})
|
|
|
|
vim.keymap.set('n', '<leader>co', function()
|
|
vim.cmd [[TSToolsOrganizeImports]]
|
|
end, {desc = "TSTools Organize Imports"})
|
|
|
|
vim.keymap.set('n', '<leader>ci', function()
|
|
vim.cmd [[TSToolsAddMissingImports]]
|
|
end, {desc = "TSTools Add Missing Imports"})
|
|
end
|
|
},{
|
|
"hrsh7th/nvim-cmp",
|
|
event = "InsertEnter",
|
|
dependencies = {
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
"hrsh7th/cmp-buffer",
|
|
"hrsh7th/cmp-path",
|
|
"SirVer/ultisnips",
|
|
"quangnguyen30192/cmp-nvim-ultisnips"
|
|
},
|
|
config = function()
|
|
local cmp = require('cmp')
|
|
local cmp_ultisnips_mappings = require("cmp_nvim_ultisnips.mappings")
|
|
cmp.setup({
|
|
snippet = {
|
|
expand = function(args)
|
|
vim.fn["UltiSnips#Anon"](args.body)
|
|
end
|
|
},
|
|
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 },
|
|
{ name = "ultisnips" },
|
|
},
|
|
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
|
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
['<C-e>'] = cmp.mapping.abort(),
|
|
["<Tab>"] = cmp.mapping(
|
|
function(fallback)
|
|
cmp_ultisnips_mappings.expand_or_jump_forwards(fallback)
|
|
end,
|
|
{ "i", "s" }
|
|
),
|
|
["<S-Tab>"] = cmp.mapping(
|
|
function(fallback)
|
|
cmp_ultisnips_mappings.jump_backwards(fallback)
|
|
end,
|
|
{ "i", "s" }
|
|
),
|
|
},
|
|
sorting = {
|
|
comparators = {
|
|
cmp.config.compare.offset,
|
|
cmp.config.compare.exact,
|
|
cmp.config.compare.score,
|
|
cmp.config.compare.recently_used,
|
|
cmp.config.compare.kind,
|
|
},
|
|
},
|
|
})
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
|
|
local lspconfig = require('lspconfig')
|
|
lspconfig.cssls.setup {
|
|
capabilities = capabilities
|
|
}
|
|
lspconfig.denols.setup{
|
|
single_file_support = false,
|
|
root_dir = lspconfig.util.root_pattern("deno.json", "deno.jsonc")
|
|
}
|
|
lspconfig.marksman.setup{
|
|
capabilities = capabilities
|
|
}
|
|
end
|
|
},{
|
|
"nvim-treesitter/nvim-treesitter",
|
|
build = ":TSUpdate",
|
|
config = function ()
|
|
local configs = require("nvim-treesitter.configs")
|
|
|
|
configs.setup({
|
|
ensure_installed = { "tsx", "typescript", "javascript", "html", "markdown", "c_sharp" },
|
|
sync_install = false,
|
|
highlight = { enable = true },
|
|
indent = { enable = true },
|
|
})
|
|
end
|
|
},
|
|
{
|
|
'stevearc/conform.nvim',
|
|
opts = {},
|
|
config = function()
|
|
local conform = require('conform')
|
|
conform.setup({
|
|
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" },
|
|
},
|
|
})
|
|
|
|
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" })
|
|
end
|
|
}
|
|
|
|
}
|
|
|