nvim-tree and treesitter config to packer

This commit is contained in:
Oliver Hartmann 2022-03-16 19:53:08 +01:00
parent c0aa5e03d0
commit cf9b76d0e0
4 changed files with 69 additions and 69 deletions

View File

@ -3,51 +3,12 @@ local fn = vim.fn -- to call Vim functions e.g. fn.bufnr()
local g = vim.g -- a table to access global variables local g = vim.g -- a table to access global variables
local opt = vim.opt -- to set options local opt = vim.opt -- to set options
local utils = require('utils') local utils = require('utils')
local packerUtil = require'packer.util'
-------------------- EXTERNAL ------------------------------ -------------------- EXTERNAL ------------------------------
require('my_plugins') require('my_plugins')
require('my_keymappings') require('my_keymappings')
require('my_options') require('my_options')
require("my_autocommands") require("my_autocommands")
-------------------- TREE-SITTER ---------------------------
require('nvim-treesitter.configs').setup({
ensure_installed = 'maintained',
highlight = {
enable = true
},
rainbow = {
enable = true,
extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
max_file_lines = nil, -- Do not enable for files with more than n lines, int
-- colors = {}, -- table of hex strings
-- termcolors = {} -- table of colour name strings
},
textobjects = {
select = {
enable = true,
-- Automatically jump forward to textobj, similar to targets.vim
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
},
lsp_interop = {
enable = true,
border = 'none',
peek_definition_code = {
["<leader>df"] = "@function.outer",
["<leader>dF"] = "@class.outer",
},
},
},
})
-------------------- GITSIGNS ------------------------------ -------------------- GITSIGNS ------------------------------
require('gitsigns').setup({ require('gitsigns').setup({
current_line_blame = true, current_line_blame = true,
@ -58,34 +19,6 @@ require('gitsigns').setup({
ignore_whitespace = false, ignore_whitespace = false,
}, },
}) })
-------------------- NVIM-TREE -----------------------------
require('nvim-tree').setup({
auto_close = true,
update_cwd = true,
update_to_buf_dir = {
-- enable the feature
enable = true,
-- allow to open the tree if it was previously closed
auto_open = false,
},
update_focused_file = {
enable = true,
update_cwd = false,
ignore_list = {}
},
diagnostics = {
enable = true,
icons = {
hint = "",
info = "",
warning = "",
error = "",
}
},
})
utils.map('n', '<leader>tt', '<cmd>NvimTreeToggle<CR>')
g.nvim_tree_highlight_opened_files = 1
g.nvim_tree_respect_buf_cwd = 1
-------------------- COMMENTED ----------------------------- -------------------- COMMENTED -----------------------------
require('Comment').setup({ require('Comment').setup({
toggler = { toggler = {

View File

@ -30,7 +30,8 @@ return require('packer').startup(function()
use {'neovim/nvim-lspconfig'} use {'neovim/nvim-lspconfig'}
use { use {
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate' run = ':TSUpdate',
config = get_setup("treesitter")
} }
use({ use({
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim',
@ -48,7 +49,8 @@ return require('packer').startup(function()
use {'lewis6991/gitsigns.nvim'} use {'lewis6991/gitsigns.nvim'}
use { use {
'kyazdani42/nvim-tree.lua', 'kyazdani42/nvim-tree.lua',
requires = 'kyazdani42/nvim-web-devicons' requires = 'kyazdani42/nvim-web-devicons',
config = get_setup("nvim-tree")
} }
use{'numToStr/Comment.nvim'} use{'numToStr/Comment.nvim'}
use { use {

28
lua/setup/nvim-tree.lua Normal file
View File

@ -0,0 +1,28 @@
local utils = require('utils')
require('nvim-tree').setup({
auto_close = true,
update_cwd = true,
update_to_buf_dir = {
-- enable the feature
enable = true,
-- allow to open the tree if it was previously closed
auto_open = false,
},
update_focused_file = {
enable = true,
update_cwd = false,
ignore_list = {}
},
diagnostics = {
enable = true,
icons = {
hint = "",
info = "",
warning = "",
error = "",
}
},
})
utils.map('n', '<leader>tt', '<cmd>NvimTreeToggle<CR>')
vim.g.nvim_tree_highlight_opened_files = 1
vim.g.nvim_tree_respect_buf_cwd = 1

37
lua/setup/treesitter.lua Normal file
View File

@ -0,0 +1,37 @@
require('nvim-treesitter.configs').setup({
ensure_installed = 'maintained',
highlight = {
enable = true
},
rainbow = {
enable = true,
extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
max_file_lines = nil, -- Do not enable for files with more than n lines, int
-- colors = {}, -- table of hex strings
-- termcolors = {} -- table of colour name strings
},
textobjects = {
select = {
enable = true,
-- Automatically jump forward to textobj, similar to targets.vim
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
},
lsp_interop = {
enable = true,
border = 'none',
peek_definition_code = {
["<leader>df"] = "@function.outer",
["<leader>dF"] = "@class.outer",
},
},
},
})