Migrate to lazy.nvim with more lua config
This commit is contained in:
parent
d7aa29354c
commit
be6559c1b6
28 changed files with 823 additions and 445 deletions
61
lua/common.lua
Normal file
61
lua/common.lua
Normal file
|
@ -0,0 +1,61 @@
|
|||
-- Adapted from https://github.com/LazyVim/LazyVim/
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
return {
|
||||
icons = {
|
||||
dap = {
|
||||
Stopped = { " ", "DiagnosticWarn", "DapStoppedLine" },
|
||||
Breakpoint = " ",
|
||||
BreakpointCondition = " ",
|
||||
BreakpointRejected = { " ", "DiagnosticError" },
|
||||
LogPoint = ".>",
|
||||
},
|
||||
diagnostics = {
|
||||
Error = " ",
|
||||
Warn = " ",
|
||||
Hint = " ",
|
||||
Info = " ",
|
||||
},
|
||||
git = {
|
||||
added = " ",
|
||||
modified = " ",
|
||||
removed = " ",
|
||||
},
|
||||
kinds = {
|
||||
Array = " ",
|
||||
Boolean = " ",
|
||||
Class = " ",
|
||||
Color = " ",
|
||||
Constant = " ",
|
||||
Constructor = " ",
|
||||
Copilot = " ",
|
||||
Enum = " ",
|
||||
EnumMember = " ",
|
||||
Event = " ",
|
||||
Field = " ",
|
||||
File = " ",
|
||||
Folder = " ",
|
||||
Function = " ",
|
||||
Interface = " ",
|
||||
Key = " ",
|
||||
Keyword = " ",
|
||||
Method = " ",
|
||||
Module = " ",
|
||||
Namespace = " ",
|
||||
Null = " ",
|
||||
Number = " ",
|
||||
Object = " ",
|
||||
Operator = " ",
|
||||
Package = " ",
|
||||
Property = " ",
|
||||
Reference = " ",
|
||||
Snippet = " ",
|
||||
String = " ",
|
||||
Struct = " ",
|
||||
Text = " ",
|
||||
TypeParameter = " ",
|
||||
Unit = " ",
|
||||
Value = " ",
|
||||
Variable = " ",
|
||||
},
|
||||
},
|
||||
}
|
5
lua/plugins/chroma.lua
Normal file
5
lua/plugins/chroma.lua
Normal file
|
@ -0,0 +1,5 @@
|
|||
return {
|
||||
'crater2150/vim-theme-chroma',
|
||||
lazy = false, priority = 1000,
|
||||
config = function() vim.cmd.colorscheme("chroma") end
|
||||
}
|
65
lua/plugins/cmp.lua
Normal file
65
lua/plugins/cmp.lua
Normal file
|
@ -0,0 +1,65 @@
|
|||
return {
|
||||
"hrsh7th/nvim-cmp",
|
||||
-- load cmp on InsertEnter
|
||||
event = "InsertEnter",
|
||||
-- these dependencies will only be loaded when cmp loads
|
||||
-- dependencies are always lazy-loaded unless specified otherwise
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'hrsh7th/cmp-path',
|
||||
'hrsh7th/cmp-cmdline',
|
||||
'hrsh7th/cmp-vsnip',
|
||||
'hrsh7th/vim-vsnip',
|
||||
'hrsh7th/vim-vsnip-integ',
|
||||
'onsails/lspkind.nvim',
|
||||
},
|
||||
config = function()
|
||||
local cmp = require('cmp')
|
||||
local lspkind = require('lspkind')
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body)
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.close(),
|
||||
['<CR>'] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
}),
|
||||
['<Tab>'] = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'vsnip' },
|
||||
{ name = "copilot"},
|
||||
},{
|
||||
{ name = 'buffer' },
|
||||
--{ name = 'path' },
|
||||
}),
|
||||
formatting = {
|
||||
format = lspkind.cmp_format({
|
||||
mode = 'symbol_text', -- show only symbol annotations
|
||||
maxwidth = 80, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
|
||||
ellipsis_char = '…', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
|
||||
symbol_map = { Copilot = "" },
|
||||
})
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
12
lua/plugins/deepl.lua
Normal file
12
lua/plugins/deepl.lua
Normal file
|
@ -0,0 +1,12 @@
|
|||
return { 'ryicoh/deepl.vim',
|
||||
keys = {
|
||||
|
||||
{ '<leader><C-e>', function() vim.fn['deepl#v']("EN") end, mode = 'v' },
|
||||
{ '<leader><C-d>', function() vim.fn['deepl#v']("DE") end, mode = 'v' },
|
||||
},
|
||||
dependencies = { 'tsuyoshicho/vim-pass' },
|
||||
config = function ()
|
||||
vim.g['deepl#endpoint'] = "https://api-free.deepl.com/v2/translate"
|
||||
vim.g['deepl#auth_key'] = vim.fn['pass#get']('web/deepl.com', 'apikey')
|
||||
end
|
||||
}
|
64
lua/plugins/init.lua
Normal file
64
lua/plugins/init.lua
Normal file
|
@ -0,0 +1,64 @@
|
|||
return {
|
||||
"folke/which-key.nvim",
|
||||
'pbrisbin/vim-mkdir',
|
||||
'fladson/vim-kitty',
|
||||
|
||||
'tpope/vim-repeat',
|
||||
'tpope/vim-surround',
|
||||
'tpope/vim-characterize',
|
||||
'tpope/vim-eunuch',
|
||||
'tpope/vim-commentary',
|
||||
'tpope/vim-sleuth',
|
||||
|
||||
-- ic / ac
|
||||
{'glts/vim-textobj-comment',
|
||||
dependencies = { 'kana/vim-textobj-user' }
|
||||
},
|
||||
-- ii / ai
|
||||
'michaeljsmith/vim-indent-object',
|
||||
'airblade/vim-gitgutter',
|
||||
|
||||
'neovim/nvim-lspconfig',
|
||||
|
||||
{ 'nvim-telescope/telescope.nvim',
|
||||
dependencies = { 'nvim-lua/plenary.nvim' }
|
||||
},
|
||||
|
||||
{ 'ray-x/lsp_signature.nvim',
|
||||
config = function()
|
||||
require('lsp_signature').setup({})
|
||||
end
|
||||
},
|
||||
'nvim-lua/lsp-status.nvim',
|
||||
'kyazdani42/nvim-web-devicons',
|
||||
'folke/trouble.nvim',
|
||||
'folke/lsp-colors.nvim',
|
||||
'nvim-lua/popup.nvim',
|
||||
|
||||
'zbirenbaum/copilot.lua',
|
||||
{'zbirenbaum/copilot-cmp',
|
||||
dependencies = { "hrsh7th/nvim-cmp" },
|
||||
},
|
||||
'junegunn/vim-easy-align',
|
||||
'machakann/vim-highlightedyank',
|
||||
'vim-airline/vim-airline',
|
||||
'lukas-reineke/indent-blankline.nvim',
|
||||
'lambdalisue/suda.vim',
|
||||
-- git
|
||||
'lambdalisue/gina.vim',
|
||||
'gregsexton/gitv',
|
||||
'gisphm/vim-gitignore',
|
||||
'sjl/splice.vim',
|
||||
'jamessan/vim-gnupg',
|
||||
|
||||
'lervag/vimtex',
|
||||
'ledger/vim-ledger',
|
||||
'anekos/hledger-vim',
|
||||
|
||||
'vim-pandoc/vim-pandoc',
|
||||
'vim-pandoc/vim-pandoc-syntax',
|
||||
'isobit/vim-caddyfile',
|
||||
'GEverding/vim-hocon',
|
||||
'nfnty/vim-nftables',
|
||||
}
|
||||
-- 'powerman/vim-plugin-AnsiEsc',
|
200
lua/plugins/lspconfig.lua
Normal file
200
lua/plugins/lspconfig.lua
Normal file
|
@ -0,0 +1,200 @@
|
|||
return {
|
||||
-- lspconfig
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
{ "folke/neoconf.nvim", cmd = "Neoconf", config = true },
|
||||
{ "folke/neodev.nvim", opts = {} },
|
||||
"mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
{
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
cond = function()
|
||||
return require("lazy.core.config").plugins["nvim-cmp"] ~= nil
|
||||
end,
|
||||
},
|
||||
},
|
||||
---@class PluginLspOpts
|
||||
opts = {
|
||||
-- options for vim.diagnostic.config()
|
||||
diagnostics = {
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
virtual_text = {
|
||||
spacing = 4,
|
||||
source = "if_many",
|
||||
prefix = "●",
|
||||
-- this will set set the prefix to a function that returns the diagnostics icon based on the severity
|
||||
-- this only works on a recent 0.10.0 build. Will be set to "●" when not supported
|
||||
-- prefix = "icons",
|
||||
},
|
||||
severity_sort = true,
|
||||
},
|
||||
-- add any global capabilities here
|
||||
capabilities = {},
|
||||
servers = {
|
||||
jsonls = {},
|
||||
lua_ls = {
|
||||
settings = {
|
||||
Lua = {
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
},
|
||||
completion = {
|
||||
callSnippet = "Replace",
|
||||
},
|
||||
telemetry = { enable = false },
|
||||
},
|
||||
},
|
||||
},
|
||||
pylsp = {
|
||||
settings = {
|
||||
pylsp = {
|
||||
plugins = {
|
||||
rope_autoimport = { enabled = true, },
|
||||
isort = { enabled = true, },
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
-- you can do any additional lsp server setup here
|
||||
-- return true if you don't want this server to be setup with lspconfig
|
||||
---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
|
||||
setup = {
|
||||
-- example to setup with typescript.nvim
|
||||
-- tsserver = function(_, opts)
|
||||
-- require("typescript").setup({ server = opts })
|
||||
-- return true
|
||||
-- end,
|
||||
-- Specify * to use this function as a fallback for any server
|
||||
-- ["*"] = function(server, opts) end,
|
||||
},
|
||||
},
|
||||
---@param opts PluginLspOpts
|
||||
config = function(_, opts)
|
||||
-- diagnostics
|
||||
for name, icon in pairs(require("common").icons.diagnostics) do
|
||||
name = "DiagnosticSign" .. name
|
||||
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
||||
end
|
||||
|
||||
if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then
|
||||
opts.diagnostics.virtual_text.prefix = vim.fn.has("nvim-0.10.0") == 0 and "●"
|
||||
or function(diagnostic)
|
||||
local icons = require("common").icons.diagnostics
|
||||
for d, icon in pairs(icons) do
|
||||
if diagnostic.severity == vim.diagnostic.severity[d:upper()] then
|
||||
return icon
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vim.diagnostic.config(vim.deepcopy(opts.diagnostics))
|
||||
|
||||
local servers = opts.servers
|
||||
local capabilities = vim.tbl_deep_extend(
|
||||
"force",
|
||||
{},
|
||||
vim.lsp.protocol.make_client_capabilities(),
|
||||
require("cmp_nvim_lsp").default_capabilities(),
|
||||
opts.capabilities or {}
|
||||
)
|
||||
|
||||
local function setup(server)
|
||||
local server_opts = vim.tbl_deep_extend("force", {
|
||||
capabilities = vim.deepcopy(capabilities),
|
||||
}, servers[server] or {})
|
||||
|
||||
if opts.setup[server] then
|
||||
if opts.setup[server](server, server_opts) then
|
||||
return
|
||||
end
|
||||
elseif opts.setup["*"] then
|
||||
if opts.setup["*"](server, server_opts) then
|
||||
return
|
||||
end
|
||||
end
|
||||
require("lspconfig")[server].setup(server_opts)
|
||||
end
|
||||
|
||||
-- get all the servers that are available thourgh mason-lspconfig
|
||||
local have_mason, mlsp = pcall(require, "mason-lspconfig")
|
||||
local all_mslp_servers = {}
|
||||
if have_mason then
|
||||
all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package)
|
||||
end
|
||||
|
||||
local ensure_installed = {} ---@type string[]
|
||||
for server, server_opts in pairs(servers) do
|
||||
if server_opts then
|
||||
server_opts = server_opts == true and {} or server_opts
|
||||
-- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig
|
||||
if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then
|
||||
setup(server)
|
||||
else
|
||||
ensure_installed[#ensure_installed + 1] = server
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if have_mason then
|
||||
mlsp.setup({ ensure_installed = ensure_installed, handlers = { setup } })
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
-- formatters
|
||||
{
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = { "mason.nvim" },
|
||||
opts = function()
|
||||
local nls = require("null-ls")
|
||||
return {
|
||||
root_dir = require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git"),
|
||||
sources = {
|
||||
nls.builtins.formatting.stylua,
|
||||
nls.builtins.formatting.shfmt,
|
||||
nls.builtins.completion.vsnip,
|
||||
nls.builtins.diagnostics.zsh,
|
||||
nls.builtins.formatting.beautysh,
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
||||
-- cmdline tools and lsp servers
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
cmd = "Mason",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"jdtls",
|
||||
"lua-language-server",
|
||||
},
|
||||
},
|
||||
---@param opts MasonSettings | {ensure_installed: string[]}
|
||||
config = function(_, opts)
|
||||
require("mason").setup(opts)
|
||||
local mr = require("mason-registry")
|
||||
local function ensure_installed()
|
||||
for _, tool in ipairs(opts.ensure_installed) do
|
||||
local p = mr.get_package(tool)
|
||||
if not p:is_installed() then
|
||||
p:install()
|
||||
end
|
||||
end
|
||||
end
|
||||
if mr.refresh then
|
||||
mr.refresh(ensure_installed)
|
||||
else
|
||||
ensure_installed()
|
||||
end
|
||||
end,
|
||||
},
|
||||
'mfussenegger/nvim-jdtls',
|
||||
}
|
||||
|
4
lua/plugins/markdown.lua
Normal file
4
lua/plugins/markdown.lua
Normal file
|
@ -0,0 +1,4 @@
|
|||
return {
|
||||
'euclio/vim-markdown-composer',
|
||||
build = 'cargo build --release'
|
||||
}
|
58
lua/plugins/metals.lua
Normal file
58
lua/plugins/metals.lua
Normal file
|
@ -0,0 +1,58 @@
|
|||
return {
|
||||
'scalameta/nvim-metals',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
'mfussenegger/nvim-dap',
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
},
|
||||
config = function()
|
||||
local metals_config = require('metals').bare_config()
|
||||
metals_config.init_options.statusBarProvider = "on"
|
||||
metals_config.settings = {
|
||||
showImplicitArguments = true,
|
||||
superMethodLensesEnabled = true,
|
||||
}
|
||||
metals_config.on_attach = function(client, bufnr)
|
||||
require("metals").setup_dap()
|
||||
require("my_lsp").on_attach(client, bufnr)
|
||||
end
|
||||
metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
-- Debug settings if you're using nvim-dap
|
||||
local dap = require("dap")
|
||||
dap.configurations.scala = {
|
||||
{
|
||||
type = "scala",
|
||||
request = "launch",
|
||||
name = "RunOrTest",
|
||||
metals = {
|
||||
runType = "runOrTestFile",
|
||||
--args = { "firstArg", "secondArg", "thirdArg" }, -- here just as an example
|
||||
},
|
||||
},
|
||||
{
|
||||
type = "scala",
|
||||
request = "launch",
|
||||
name = "Test Target",
|
||||
metals = {
|
||||
runType = "testTarget",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
-- Autocmd that will actually be in charging of starting the whole thing
|
||||
local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
-- NOTE: You may or may not want java included here. You will need it if you
|
||||
-- want basic Java support but it may also conflict if you are using
|
||||
-- something like nvim-jdtls which also works on a java filetype autocmd.
|
||||
pattern = { "scala", "sbt" },
|
||||
callback = function()
|
||||
require("metals").initialize_or_attach(metals_config)
|
||||
end,
|
||||
group = nvim_metals_group,
|
||||
})
|
||||
|
||||
return metals_config
|
||||
end
|
||||
}
|
54
lua/plugins/telescope.lua
Normal file
54
lua/plugins/telescope.lua
Normal file
|
@ -0,0 +1,54 @@
|
|||
--Plug 'nvim-telescope/telescope.nvim'
|
||||
|
||||
--Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }
|
||||
--Plug 'gbrlsnchs/telescope-lsp-handlers.nvim'
|
||||
--Plug 'nvim-telescope/telescope-ui-select.nvim'
|
||||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
dependencies = {
|
||||
{'nvim-telescope/telescope-fzf-native.nvim',
|
||||
build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build',
|
||||
},
|
||||
'gbrlsnchs/telescope-lsp-handlers.nvim',
|
||||
'nvim-telescope/telescope-ui-select.nvim',
|
||||
--Plug { 'do': 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }
|
||||
},
|
||||
cmd = "Telescope",
|
||||
version = false,
|
||||
keys = {
|
||||
{',ff', require("telescope.builtin").fd, desc = "Find files"},
|
||||
{',fg', require("telescope.builtin").git_files, desc = "Find files (git)"},
|
||||
{',gs', require("telescope.builtin").git_status, desc = "Git status"},
|
||||
{',s', require("telescope.builtin").lsp_dynamic_workspace_symbols, desc = "Symbols"},
|
||||
{'g/', require("telescope.builtin").live_grep, desc = "Live grep"},
|
||||
{'<C-/>', require("telescope.builtin").current_buffer_fuzzy_find, desc = "Fuzzy find"},
|
||||
{'<leader>*', require("telescope.builtin").grep_string, desc = "Find at cursor"},
|
||||
{'gb', require("telescope.builtin").buffers},
|
||||
{ "<leader>:", require("telescope.builtin").command_history, desc = "Command History" },
|
||||
{ "<leader>;", require("telescope.builtin").commands, desc = "Commands" },
|
||||
},
|
||||
opts = {
|
||||
defaults = {
|
||||
prompt_prefix = " ",
|
||||
selection_caret = " ",
|
||||
},
|
||||
extensions = {
|
||||
fzf = {
|
||||
fuzzy = true, -- false will only do exact matching
|
||||
override_generic_sorter = true, -- override the generic sorter
|
||||
override_file_sorter = true, -- override the file sorter
|
||||
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
|
||||
-- the default case_mode is "smart_case"
|
||||
},
|
||||
["ui-select"] = {
|
||||
require("telescope.themes").get_dropdown { }
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
local telescope = require('telescope')
|
||||
telescope.setup(opts)
|
||||
telescope.load_extension('fzf')
|
||||
telescope.load_extension('ui-select')
|
||||
end,
|
||||
}
|
12
lua/plugins/text-to-color.lua
Normal file
12
lua/plugins/text-to-color.lua
Normal file
|
@ -0,0 +1,12 @@
|
|||
return {
|
||||
'svermeulen/text-to-colorscheme',
|
||||
dependencies = { 'tsuyoshicho/vim-pass' },
|
||||
config = function ()
|
||||
require('text-to-colorscheme').setup {
|
||||
ai = {
|
||||
gpt_model = "gpt-3.5-turbo",
|
||||
openai_api_key = vim.fn['pass#get']('apikeys/openai_vim'),
|
||||
},
|
||||
}
|
||||
end
|
||||
}
|
88
lua/plugins/treesitter.lua
Normal file
88
lua/plugins/treesitter.lua
Normal file
|
@ -0,0 +1,88 @@
|
|||
return {
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
version = false, -- last release is way too old and doesn't work on Windows
|
||||
build = ":TSUpdate",
|
||||
event = { "BufReadPost", "BufNewFile" },
|
||||
dependencies = {
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
init = function()
|
||||
-- PERF: no need to load the plugin, if we only need its queries for mini.ai
|
||||
local plugin = require("lazy.core.config").spec.plugins["nvim-treesitter"]
|
||||
local opts = require("lazy.core.plugin").values(plugin, "opts", false)
|
||||
local enabled = false
|
||||
if opts.textobjects then
|
||||
for _, mod in ipairs({ "move", "select", "swap", "lsp_interop" }) do
|
||||
if opts.textobjects[mod] and opts.textobjects[mod].enable then
|
||||
enabled = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if not enabled then
|
||||
require("lazy.core.loader").disable_rtp_plugin("nvim-treesitter-textobjects")
|
||||
end
|
||||
end,
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{ "<c-space>", desc = "Increment selection" },
|
||||
{ "<bs>", desc = "Decrement selection", mode = "x" },
|
||||
},
|
||||
---@type TSConfig
|
||||
opts = {
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"gitignore",
|
||||
"html",
|
||||
"java",
|
||||
"json",
|
||||
"lua",
|
||||
"luadoc",
|
||||
"luap",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"python",
|
||||
"query",
|
||||
"regex",
|
||||
"scala",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"vim",
|
||||
"vimdoc",
|
||||
"yaml",
|
||||
},
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "<C-space>",
|
||||
node_incremental = "<C-space>",
|
||||
scope_incremental = false,
|
||||
node_decremental = "<bs>",
|
||||
},
|
||||
},
|
||||
},
|
||||
---@param opts TSConfig
|
||||
config = function(_, opts)
|
||||
if type(opts.ensure_installed) == "table" then
|
||||
---@type table<string, boolean>
|
||||
local added = {}
|
||||
opts.ensure_installed = vim.tbl_filter(function(lang)
|
||||
if added[lang] then
|
||||
return false
|
||||
end
|
||||
added[lang] = true
|
||||
return true
|
||||
end, opts.ensure_installed)
|
||||
end
|
||||
require("nvim-treesitter.configs").setup(opts)
|
||||
end,
|
||||
},
|
||||
{ 'nvim-treesitter/playground',
|
||||
cmd = 'TSPlaygroundToggle'
|
||||
},
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue