From 3e2f73551169dfc717270c673af04001e0a4d449 Mon Sep 17 00:00:00 2001 From: Daan Vanoverloop Date: Tue, 24 Aug 2021 18:17:11 +0200 Subject: [PATCH] Neovim lua config --- .config/nvim/init.lua | 7 + .config/nvim/{init.vim => init.vim_old} | 223 ++++++++++++++++++++---- .config/nvim/lua/completion.lua | 59 +++++++ .config/nvim/lua/format.lua | 54 ++++++ .config/nvim/lua/keys.lua | 38 ++++ .config/nvim/lua/lsp.lua | 55 ++++++ .config/nvim/lua/options.lua | 24 +++ .config/nvim/lua/plugins.lua | 54 ++++++ .config/nvim/lua/session.lua | 23 +++ .config/nvim/lua/statusline.lua | 210 ++++++++++++++++++++++ .config/nvim/lua/treesitter.lua | 23 +++ 11 files changed, 740 insertions(+), 30 deletions(-) create mode 100644 .config/nvim/init.lua rename .config/nvim/{init.vim => init.vim_old} (50%) create mode 100644 .config/nvim/lua/completion.lua create mode 100644 .config/nvim/lua/format.lua create mode 100644 .config/nvim/lua/keys.lua create mode 100644 .config/nvim/lua/lsp.lua create mode 100644 .config/nvim/lua/options.lua create mode 100644 .config/nvim/lua/plugins.lua create mode 100644 .config/nvim/lua/session.lua create mode 100644 .config/nvim/lua/statusline.lua create mode 100644 .config/nvim/lua/treesitter.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..a59033b --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,7 @@ +require('plugins') +require('options') +require('treesitter') +require('format') +require('keys') +require('completion') +require('statusline') diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim_old similarity index 50% rename from .config/nvim/init.vim rename to .config/nvim/init.vim_old index de5576a..5dc2d2d 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim_old @@ -29,7 +29,7 @@ Plug 'nikvdp/ejs-syntax' Plug 'pangloss/vim-javascript' Plug 'MaxMEllon/vim-jsx-pretty' Plug 'jelera/vim-javascript-syntax' -Plug 'w0rp/ale' +"Plug 'w0rp/ale' Plug 'prettier/prettier' Plug 'flrnprz/plastic.vim' Plug 'rakr/vim-one' @@ -40,36 +40,222 @@ Plug 'vim-pandoc/vim-pandoc' Plug 'vim-pandoc/vim-pandoc-syntax' Plug 'junegunn/fzf.vim' Plug 'tpope/vim-dadbod' -"Plug 'lervag/vimtex' +Plug 'lervag/vimtex' Plug 'dpelle/vim-LanguageTool' -Plug 'neoclide/coc.nvim', {'branch': 'release'} +"Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'tikhomirov/vim-glsl' Plug 'soli/prolog-vim' +Plug 'tpope/vim-dispatch' +"Plug 'rafcamlet/coc-nvim-lua' +Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} + +Plug 'neovim/nvim-lspconfig' +Plug 'hrsh7th/nvim-compe' +Plug 'nvim-lua/lsp-status.nvim' +"Plug 'evanleck/vim-svelte', {'branch': 'main'} +Plug 'leafOfTree/vim-svelte-plugin' +Plug 'prettier/vim-prettier', { 'do': 'yarn install' } call plug#end() " required filetype plugin indent on " required +let g:prettier#config#tab_width = 2 + +lua < compe#complete() +inoremap compe#confirm('') +inoremap compe#close('') +inoremap compe#scroll({ 'delta': +4 }) +inoremap compe#scroll({ 'delta': -4 }) + +lua << END +local lsp_status = require('lsp-status') +lsp_status.register_progress() + +local lspconfig = require('lspconfig') + +-- Some arbitrary servers +lspconfig.clangd.setup({ + handlers = lsp_status.extensions.clangd.setup(), + init_options = { + clangdFileStatus = true + }, + on_attach = lsp_status.on_attach, + capabilities = lsp_status.capabilities +}) + +lspconfig.rust_analyzer.setup({ + on_attach = lsp_status.on_attach, + capabilities = lsp_status.capabilities +}) + +lspconfig.pyright.setup({ + on_attach = lsp_status.on_attach, + capabilities = lsp_status.capabilities +}) + +lspconfig.elmls.setup({ + on_attach = lsp_status.on_attach, + capabilities = lsp_status.capabilities +}) +lspconfig.svelte.setup({ + on_attach = lsp_status.on_attach, + capabilities = lsp_status.capabilities +}) + +lspconfig.tsserver.setup({ + on_attach = lsp_status.on_attach, + capabilities = lsp_status.capabilities +}) + +lspconfig.gdscript.setup({ + on_attach = function (client) + local _notify = client.notify + client.notify = function (method, params) + if method == 'textDocument/didClose' then + -- Godot doesn't implement didClose yet + return + end + _notify(method, params) + end + lsp_status.on_attach(client) + end, + capabilities = lsp_status.capabilities, + flags = { + debounce_text_changes = 150, + } +}) +END + +" Statusline +function! LspStatus() abort + let status = luaeval('require("lsp-status").status()') + return trim(status) +endfunction + +call airline#parts#define_function('lsp_status', 'LspStatus') +call airline#parts#define_condition('lsp_status', 'luaeval("#vim.lsp.buf_get_clients() > 0")') +let g:airline#extensions#nvimlsp#enabled = 0 +let g:airline_section_x = airline#section#create_right(['lsp_status']) + +" Errors in Red +hi LspDiagnosticsVirtualTextError guifg=red ctermfg=red +" Warnings in Yellow +hi LspDiagnosticsVirtualTextWarning guifg=yellow ctermfg=yellow +" Info and Hints in White +hi LspDiagnosticsVirtualTextInformation guifg=white ctermfg=white +hi LspDiagnosticsVirtualTextHint guifg=white ctermfg=white + +" Underline the offending code +hi LspDiagnosticsUnderlineError guifg=NONE ctermfg=NONE cterm=underline gui=underline +hi LspDiagnosticsUnderlineWarning guifg=NONE ctermfg=NONE cterm=underline gui=underline +hi LspDiagnosticsUnderlineInformation guifg=NONE ctermfg=NONE cterm=underline gui=underline +hi LspDiagnosticsUnderlineHint guifg=NONE ctermfg=NONE cterm=underline gui=underline + +lua << EOF +vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, { + -- Enable underline, use default values + underline = true, + -- Enable virtual text only on Warning or above, override spacing to 2 + virtual_text = { + spacing = 2, + }, + } +) +EOF + +autocmd ColorScheme * :lua require('vim.lsp.diagnostic')._define_default_signs_and_highlights() + +autocmd CursorHold * lua vim.lsp.diagnostic.show_line_diagnostics() + autocmd FileType matlab setlocal keywordprg=info\ octave\ --vi-keys\ --index-search augroup filetypedetect " Mail autocmd BufRead,BufNewFile *mutt-* setfiletype mail + autocmd BufRead,BufNewFile *.gd set filetype=gdscript3 augroup END -let g:languagetool_jar = "/home/daan/.local/share/languagetool/languagetool-commandline.jar" +let g:languagetool_jar = "/home/daan/.local/share/LanguageTool-5.2-SNAPSHOT/languagetool-commandline.jar" let g:jsx_ext_required = 0 let g:neosnippet#enable_completed_snippet = 1 let g:autocomplete_flow#insert_paren_after_function = 0 -let g:languagetool_jar = "~/Documents/LanguageTool-4.9.1/languagetool-commandline.jar" +let g:fzf_buffers_jump = 1 + +"let g:coc_filetype_map = { + "\ 'md': 'tex', + "\ } set tags+=./.tags set nobackup set nowritebackup +set guifont=Fira\ Code:h12 + "Credit joshdick "Use 24-bit (true-color) mode in Vim/Neovim when outside tmux. "If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support @@ -227,31 +413,8 @@ set expandtab :set ma let g:C_Mapfeader = ',' -nnoremap :noh: -imap (neosnippet_expand_or_jump) -smap (neosnippet_expand_or_jump) -xmap (neosnippet_expand_target) - -imap neosnippet#expandable_or_jumpable() ? -\ "\(neosnippet_expand_or_jump)" -\: pumvisible() ? "\" : "\" -smap neosnippet#expandable_or_jumpable() ? -\ "\(neosnippet_expand_or_jump)" -\: "\" - -inoremap - \ pumvisible() ? coc#_select_confirm() : - \ coc#expandableOrJumpable() ? "\=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\" : - \ check_back_space() ? "\" : - \ coc#refresh() - -function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction - -let g:coc_snippet_next = '' +"let g:coc_snippet_next = '' nnoremap :Files nnoremap :Buffers @@ -274,5 +437,5 @@ imap imap imap -set completeopt=menu,noinsert +set completeopt=menuone,noselect diff --git a/.config/nvim/lua/completion.lua b/.config/nvim/lua/completion.lua new file mode 100644 index 0000000..9de9122 --- /dev/null +++ b/.config/nvim/lua/completion.lua @@ -0,0 +1,59 @@ +local lspconfig = require 'lspconfig' + +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.completion.completionItem.documentationFormat = { 'markdown', 'plaintext' } +capabilities.textDocument.completion.completionItem.snippetSupport = true +capabilities.textDocument.completion.completionItem.preselectSupport = true +capabilities.textDocument.completion.completionItem.insertReplaceSupport = true +capabilities.textDocument.completion.completionItem.labelDetailsSupport = true +capabilities.textDocument.completion.completionItem.deprecatedSupport = true +capabilities.textDocument.completion.completionItem.commitCharactersSupport = true +capabilities.textDocument.completion.completionItem.tagSupport = { valueSet = { 1 } } +capabilities.textDocument.completion.completionItem.resolveSupport = { + properties = { + 'documentation', + 'detail', + 'additionalTextEdits', + }, +} + +-- Enable some language servers with the additional completion capabilities offered by nvim-cmp +local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'svelte' } +for _, lsp in ipairs(servers) do + lspconfig[lsp].setup { + -- on_attach = my_custom_on_attach, + capabilities = capabilities, + } +end + +-- luasnip setup +local luasnip = require 'luasnip' + +-- nvim-cmp setup +local cmp = require 'cmp' +cmp.setup { + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + mapping = { + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 's' }), + [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'nvim_lua' }, + { name = 'luasnip' }, + }, +} diff --git a/.config/nvim/lua/format.lua b/.config/nvim/lua/format.lua new file mode 100644 index 0000000..4f71332 --- /dev/null +++ b/.config/nvim/lua/format.lua @@ -0,0 +1,54 @@ +require('formatter').setup({ + logging = false, + filetype = { + javascript = { + -- prettier + function() + return { + exe = "prettier", + args = {"--stdin-filepath", vim.api.nvim_buf_get_name(0), '--single-quote'}, + stdin = true + } + end + }, + svelte = { + -- prettier + function() + return { + exe = "prettier", + args = { + "--stdin-filepath", vim.api.nvim_buf_get_name(0), '--single-quote' + }, + stdin = true + } + end + }, + rust = { + -- Rustfmt + function() + return { + exe = "rustfmt", + args = {"--emit=stdout"}, + stdin = true + } + end + }, + lua = { + -- luafmt + function() + return { + exe = "luafmt", + args = {"--indent-count", 2, "--stdin"}, + stdin = true + } + end + }, + } +}) + +vim.api.nvim_exec([[ +augroup FormatAutogroup +autocmd! +autocmd BufWritePost *.svelte,*.js,*.rs,*.lua FormatWrite +augroup END +]], true) diff --git a/.config/nvim/lua/keys.lua b/.config/nvim/lua/keys.lua new file mode 100644 index 0000000..61d1a87 --- /dev/null +++ b/.config/nvim/lua/keys.lua @@ -0,0 +1,38 @@ +local map = vim.api.nvim_set_keymap +local function n(...) map("n", ...) end +local function x(...) map("x", ...) end +local function i(...) map("i", ...) end + +-- Telescope +n("", "Telescope find_files", { noremap = true }) +n("", "Telescope buffers", { noremap = true }) + +-- Tree +n("", ":NvimTreeToggle", {}) + +-- Movement +n("", "", { noremap = true }) +n("", "", { noremap = true }) +n("", "", { noremap = true }) +n("", "", { noremap = true }) + +-- Tabs +n("", ":tabnew", {}) + +-- Split +n("", ":vsplit", {}) +n("", ":split", {}) + +-- Quit +n("Q", "", { noremap = true }) +vim.api.nvim_exec( +[[ +:command WQ wq +:command Wq wq +:command W w +:command Q q +:command WQa wqa +:command Wqa wqa +]], +true) + diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua new file mode 100644 index 0000000..891eb7d --- /dev/null +++ b/.config/nvim/lua/lsp.lua @@ -0,0 +1,55 @@ +local lspconfig = require('lspconfig') +local lsp_status = require('lsp-status') +lsp_status.register_progress() + +-- Some arbitrary servers +lspconfig.clangd.setup({ + handlers = lsp_status.extensions.clangd.setup(), + init_options = { + clangdFileStatus = true + }, + on_attach = lsp_status.on_attach, + capabilities = lsp_status.capabilities +}) + +lspconfig.rust_analyzer.setup({ + on_attach = lsp_status.on_attach, + capabilities = lsp_status.capabilities +}) + +lspconfig.pyright.setup({ + on_attach = lsp_status.on_attach, + capabilities = lsp_status.capabilities +}) + +lspconfig.elmls.setup({ + on_attach = lsp_status.on_attach, + capabilities = lsp_status.capabilities +}) +lspconfig.svelte.setup({ + on_attach = lsp_status.on_attach, + capabilities = lsp_status.capabilities +}) + +lspconfig.tsserver.setup({ + on_attach = lsp_status.on_attach, + capabilities = lsp_status.capabilities +}) + +lspconfig.gdscript.setup({ + on_attach = function (client) + local _notify = client.notify + client.notify = function (method, params) + if method == 'textDocument/didClose' then + -- Godot doesn't implement didClose yet + return + end + _notify(method, params) + end + lsp_status.on_attach(client) + end, + capabilities = lsp_status.capabilities, + flags = { + debounce_text_changes = 150, + } +}) diff --git a/.config/nvim/lua/options.lua b/.config/nvim/lua/options.lua new file mode 100644 index 0000000..372ebdc --- /dev/null +++ b/.config/nvim/lua/options.lua @@ -0,0 +1,24 @@ +local o = vim.opt + +-- Indentation +o.smartindent = true +o.tabstop = 4 +o.shiftwidth = 4 +o.expandtab = true +o.backspace = "indent,eol,start" + +-- Numbers +o.number = true +o.relativenumber = true + +-- Theme +o.background = "dark" +vim.cmd("colorscheme one") + +-- Misc +o.mouse = 'a' +o.linebreak = true +o.backup = false +o.swapfile = false +o.showmode = true +o.termguicolors = true diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua new file mode 100644 index 0000000..59f5626 --- /dev/null +++ b/.config/nvim/lua/plugins.lua @@ -0,0 +1,54 @@ +vim.cmd [[packadd packer.nvim]] + +return require('packer').startup(function() + -- packer + use 'wbthomason/packer.nvim' + + -- Languages + use 'rust-lang/rust.vim' + use 'calviken/vim-gdscript3' + use 'vim-pandoc/vim-pandoc' + use 'vim-pandoc/vim-pandoc-syntax' + use 'dpelle/vim-LanguageTool' + use 'tikhomirov/vim-glsl' + use 'leafOfTree/vim-svelte-plugin' + + -- Completion + use 'neovim/nvim-lspconfig' + use 'nvim-lua/lsp-status.nvim' + use 'hrsh7th/nvim-cmp' + use 'hrsh7th/cmp-buffer' + use 'hrsh7th/cmp-nvim-lsp' + use 'saadparwaiz1/cmp_luasnip' + use 'L3MON4D3/LuaSnip' + + -- Syntax highlighting + use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } + + -- Formatting + use 'mhartington/formatter.nvim' + + -- Telescope + use { + 'nvim-telescope/telescope.nvim', + requires = { {'nvim-lua/plenary.nvim'} } + } + + -- File tree + use { + 'kyazdani42/nvim-tree.lua', + requires = 'kyazdani42/nvim-web-devicons' + } + + -- Session + use 'rmagatti/auto-session' + + -- Theme + use 'rakr/vim-one' + + -- Status lioe + use 'glepnir/galaxyline.nvim' + + -- Icons + use 'ryanoasis/vim-devicons' +end) diff --git a/.config/nvim/lua/session.lua b/.config/nvim/lua/session.lua new file mode 100644 index 0000000..f8b0cd9 --- /dev/null +++ b/.config/nvim/lua/session.lua @@ -0,0 +1,23 @@ + +local Session = {} + +function Session.save() + vim.cmd("execute 'mksession! ' . getcwd() . '/.session.vim'") +end + +function Session.restore() + if vim.filereadable(getcwd() . '/.session.vim') + let initial_args = argv() + execute 'so ' . getcwd() . '/.session.vim' + for file in initial_args + if bufloaded(file) != 1 + execute 'tabnew ' . getcwd() . '/' . file + else + execute 'sb ' . file + endif + endfor + let g:session = 1 + endif +end + +return Session diff --git a/.config/nvim/lua/statusline.lua b/.config/nvim/lua/statusline.lua new file mode 100644 index 0000000..631f9a5 --- /dev/null +++ b/.config/nvim/lua/statusline.lua @@ -0,0 +1,210 @@ +local gl = require('galaxyline') +local colors = require('galaxyline.theme').default +local condition = require('galaxyline.condition') +local gls = gl.section +gl.short_line_list = {'NvimTree','vista','dbui','packer'} + +gls.left[1] = { + RainbowRed = { + provider = function() return '▊ ' end, + highlight = {colors.blue,colors.bg} + }, +} +gls.left[2] = { + ViMode = { + provider = function() + -- auto change color according the vim mode + local mode_color = {n = colors.red, i = colors.green,v=colors.blue, + [''] = colors.blue,V=colors.blue, + c = colors.magenta,no = colors.red,s = colors.orange, + S=colors.orange,[''] = colors.orange, + ic = colors.yellow,R = colors.violet,Rv = colors.violet, + cv = colors.red,ce=colors.red, r = colors.cyan, + rm = colors.cyan, ['r?'] = colors.cyan, + ['!'] = colors.red,t = colors.red} + vim.api.nvim_command('hi GalaxyViMode guifg='..mode_color[vim.fn.mode()]) + return ' ' + end, + highlight = {colors.red,colors.bg,'bold'}, + }, +} +gls.left[3] = { + FileSize = { + provider = 'FileSize', + condition = condition.buffer_not_empty, + highlight = {colors.fg,colors.bg} + } +} +gls.left[4] ={ + FileIcon = { + provider = 'FileIcon', + condition = condition.buffer_not_empty, + highlight = {require('galaxyline.provider_fileinfo').get_file_icon_color,colors.bg}, + }, +} + +gls.left[5] = { + FileName = { + provider = 'FileName', + condition = condition.buffer_not_empty, + highlight = {colors.magenta,colors.bg,'bold'} + } +} + +gls.left[6] = { + LineInfo = { + provider = 'LineColumn', + separator = ' ', + separator_highlight = {'NONE',colors.bg}, + highlight = {colors.fg,colors.bg}, + }, +} + +gls.left[7] = { + PerCent = { + provider = 'LinePercent', + separator = ' ', + separator_highlight = {'NONE',colors.bg}, + highlight = {colors.fg,colors.bg,'bold'}, + } +} + +gls.left[8] = { + DiagnosticError = { + provider = 'DiagnosticError', + icon = '  ', + highlight = {colors.red,colors.bg} + } +} +gls.left[9] = { + DiagnosticWarn = { + provider = 'DiagnosticWarn', + icon = '  ', + highlight = {colors.yellow,colors.bg}, + } +} + +gls.left[10] = { + DiagnosticHint = { + provider = 'DiagnosticHint', + icon = '  ', + highlight = {colors.cyan,colors.bg}, + } +} + +gls.left[11] = { + DiagnosticInfo = { + provider = 'DiagnosticInfo', + icon = '  ', + highlight = {colors.blue,colors.bg}, + } +} + +gls.mid[1] = { + ShowLspClient = { + provider = 'GetLspClient', + condition = function () + local tbl = {['dashboard'] = true,['']=true} + if tbl[vim.bo.filetype] then + return false + end + return true + end, + icon = ' LSP:', + highlight = {colors.cyan,colors.bg,'bold'} + } +} + +gls.right[1] = { + FileEncode = { + provider = 'FileEncode', + condition = condition.hide_in_width, + separator = ' ', + separator_highlight = {'NONE',colors.bg}, + highlight = {colors.green,colors.bg,'bold'} + } +} + +gls.right[2] = { + FileFormat = { + provider = 'FileFormat', + condition = condition.hide_in_width, + separator = ' ', + separator_highlight = {'NONE',colors.bg}, + highlight = {colors.green,colors.bg,'bold'} + } +} + +gls.right[3] = { + GitIcon = { + provider = function() return '  ' end, + condition = condition.check_git_workspace, + separator = ' ', + separator_highlight = {'NONE',colors.bg}, + highlight = {colors.violet,colors.bg,'bold'}, + } +} + +gls.right[4] = { + GitBranch = { + provider = 'GitBranch', + condition = condition.check_git_workspace, + highlight = {colors.violet,colors.bg,'bold'}, + } +} + +gls.right[5] = { + DiffAdd = { + provider = 'DiffAdd', + condition = condition.hide_in_width, + icon = '  ', + highlight = {colors.green,colors.bg}, + } +} +gls.right[6] = { + DiffModified = { + provider = 'DiffModified', + condition = condition.hide_in_width, + icon = ' 柳', + highlight = {colors.orange,colors.bg}, + } +} +gls.right[7] = { + DiffRemove = { + provider = 'DiffRemove', + condition = condition.hide_in_width, + icon = '  ', + highlight = {colors.red,colors.bg}, + } +} + +gls.right[8] = { + RainbowBlue = { + provider = function() return ' ▊' end, + highlight = {colors.blue,colors.bg} + }, +} + +gls.short_line_left[1] = { + BufferType = { + provider = 'FileTypeName', + separator = ' ', + separator_highlight = {'NONE',colors.bg}, + highlight = {colors.blue,colors.bg,'bold'} + } +} + +gls.short_line_left[2] = { + SFileName = { + provider = 'SFileName', + condition = condition.buffer_not_empty, + highlight = {colors.fg,colors.bg,'bold'} + } +} + +gls.short_line_right[1] = { + BufferIcon = { + provider= 'BufferIcon', + highlight = {colors.fg,colors.bg} + } +} diff --git a/.config/nvim/lua/treesitter.lua b/.config/nvim/lua/treesitter.lua new file mode 100644 index 0000000..395c3cc --- /dev/null +++ b/.config/nvim/lua/treesitter.lua @@ -0,0 +1,23 @@ +require'nvim-treesitter.configs'.setup { + highlight = { + enable = true, + custom_captures = { + -- Highlight the @foo.bar capture group with the "Identifier" highlight group. + ["foo.bar"] = "Identifier", + }, + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, +}