Update neovim treesitter configuration
This commit is contained in:
parent
958e8c7d39
commit
2af0914538
4 changed files with 28 additions and 23 deletions
|
|
@ -22,7 +22,7 @@ neovim_plugins:
|
||||||
name: "cmp-nvim-lua"
|
name: "cmp-nvim-lua"
|
||||||
- url: "https://github.com/nvim-treesitter/nvim-treesitter"
|
- url: "https://github.com/nvim-treesitter/nvim-treesitter"
|
||||||
name: "nvim-treesitter"
|
name: "nvim-treesitter"
|
||||||
version: master # main seems broken?
|
version: main
|
||||||
- url: "https://github.com/nvim-lua/plenary.nvim"
|
- url: "https://github.com/nvim-lua/plenary.nvim"
|
||||||
name: "plenary.nvim"
|
name: "plenary.nvim"
|
||||||
- url: "https://github.com/nvim-telescope/telescope-fzf-native.nvim"
|
- url: "https://github.com/nvim-telescope/telescope-fzf-native.nvim"
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@
|
||||||
dest: "{{ xdg_config_dir }}/nvim/lua/options.lua"
|
dest: "{{ xdg_config_dir }}/nvim/lua/options.lua"
|
||||||
|
|
||||||
- src: "templates/nvim/lua/tree-sitter.lua.j2"
|
- src: "templates/nvim/lua/tree-sitter.lua.j2"
|
||||||
dest: "{{ xdg_config_dir }}/nvim/lua/tree-sitter.lua"
|
dest: "{{ xdg_config_dir }}/nvim/lua/_tree-sitter.lua"
|
||||||
|
|
||||||
- src: "templates/nvim/lua/git-signs.lua.j2"
|
- src: "templates/nvim/lua/git-signs.lua.j2"
|
||||||
dest: "{{ xdg_config_dir }}/nvim/lua/git-signs.lua"
|
dest: "{{ xdg_config_dir }}/nvim/lua/git-signs.lua"
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ require('options')
|
||||||
require('_filetype')
|
require('_filetype')
|
||||||
require('colorscheme')
|
require('colorscheme')
|
||||||
require('lsp')
|
require('lsp')
|
||||||
require('tree-sitter')
|
require('_tree-sitter')
|
||||||
require('git-signs')
|
require('git-signs')
|
||||||
require('_telescope')
|
require('_telescope')
|
||||||
require('indent-blankline')
|
require('indent-blankline')
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,31 @@
|
||||||
-- {{ ansible_managed }}
|
-- {{ ansible_managed }}
|
||||||
|
|
||||||
-- Tree sitter language parsers are installed automatically (through `auto_install`).
|
|
||||||
-- To update installed parsers use `:TSUpdate {language}`.
|
-- To update installed parsers use `:TSUpdate {language}`.
|
||||||
-- See https://github.com/nvim-treesitter/nvim-treesitter for more info.
|
-- See https://github.com/nvim-treesitter/nvim-treesitter for more info.
|
||||||
local tree_sitter_config = require('nvim-treesitter.configs')
|
local tree_sitter_config = require('nvim-treesitter')
|
||||||
|
|
||||||
tree_sitter_config.setup {
|
local ensure_installed = {
|
||||||
ensure_installed = {
|
'lua', 'yaml', 'bash', 'python', 'javascript', 'typescript', 'jsx', 'css', 'scss',
|
||||||
'lua', 'yaml', 'bash', 'python', 'javascript', 'typescript', 'css', 'scss',
|
'html', 'htmldjango', 'sql', 'json', 'dockerfile', 'markdown', 'rst', 'tmux',
|
||||||
'html', 'htmldjango', 'sql', 'json', 'dockerfile', 'markdown', 'rst', 'tmux',
|
'xml', 'toml', 'editorconfig', 'diff', 'gitcommit', 'git_config', 'gitignore',
|
||||||
'xml', 'toml', 'editorconfig', 'diff', 'gitcommit', 'git_config', 'gitignore',
|
'gitattributes', 'make', 'nginx', 'vim', 'vimdoc', 'passwd', 'regex'
|
||||||
'gitattributes', 'make', 'nginx', 'vim', 'vimdoc', 'passwd', 'regex'
|
|
||||||
},
|
|
||||||
auto_install = true,
|
|
||||||
highlight = {
|
|
||||||
enable = true,
|
|
||||||
additional_vim_regex_highlighting = false,
|
|
||||||
},
|
|
||||||
indent = {
|
|
||||||
enable = true,
|
|
||||||
},
|
|
||||||
incremental_selection = {
|
|
||||||
enable = true,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local already_installed = require('nvim-treesitter.config').get_installed()
|
||||||
|
local parsers_to_install = vim.iter(ensure_installed)
|
||||||
|
:filter(function(parser) return not vim.tbl_contains(already_installed, parser) end)
|
||||||
|
:totable()
|
||||||
|
|
||||||
|
tree_sitter_config.install(parsers_to_install)
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
|
callback = function()
|
||||||
|
-- Enable treesitter highlighting and disable regex syntax
|
||||||
|
pcall(vim.treesitter.start)
|
||||||
|
-- folds, provided by Neovim
|
||||||
|
vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
|
||||||
|
vim.wo.foldmethod = 'expr'
|
||||||
|
-- indentation, provided by nvim-treesitter
|
||||||
|
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue