diff --git a/init.lua b/init.lua index 659800b..6fe7b64 100644 --- a/init.lua +++ b/init.lua @@ -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 opt = vim.opt -- to set options local utils = require('utils') -local packerUtil = require'packer.util' -------------------- EXTERNAL ------------------------------ require('my_plugins') require('my_keymappings') require('my_options') 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 = { - ["df"] = "@function.outer", - ["dF"] = "@class.outer", - }, - }, - }, -}) -------------------- GITSIGNS ------------------------------ require('gitsigns').setup({ current_line_blame = true, @@ -58,34 +19,6 @@ require('gitsigns').setup({ 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', 'tt', 'NvimTreeToggle') -g.nvim_tree_highlight_opened_files = 1 -g.nvim_tree_respect_buf_cwd = 1 -------------------- COMMENTED ----------------------------- require('Comment').setup({ toggler = { diff --git a/lua/my_plugins.lua b/lua/my_plugins.lua index ad8fda5..ce16612 100644 --- a/lua/my_plugins.lua +++ b/lua/my_plugins.lua @@ -30,7 +30,8 @@ return require('packer').startup(function() use {'neovim/nvim-lspconfig'} use { 'nvim-treesitter/nvim-treesitter', - run = ':TSUpdate' + run = ':TSUpdate', + config = get_setup("treesitter") } use({ 'nvim-telescope/telescope.nvim', @@ -48,7 +49,8 @@ return require('packer').startup(function() use {'lewis6991/gitsigns.nvim'} use { 'kyazdani42/nvim-tree.lua', - requires = 'kyazdani42/nvim-web-devicons' + requires = 'kyazdani42/nvim-web-devicons', + config = get_setup("nvim-tree") } use{'numToStr/Comment.nvim'} use { diff --git a/lua/setup/nvim-tree.lua b/lua/setup/nvim-tree.lua new file mode 100644 index 0000000..ab0a880 --- /dev/null +++ b/lua/setup/nvim-tree.lua @@ -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', 'tt', 'NvimTreeToggle') +vim.g.nvim_tree_highlight_opened_files = 1 +vim.g.nvim_tree_respect_buf_cwd = 1 diff --git a/lua/setup/treesitter.lua b/lua/setup/treesitter.lua new file mode 100644 index 0000000..b747236 --- /dev/null +++ b/lua/setup/treesitter.lua @@ -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 = { + ["df"] = "@function.outer", + ["dF"] = "@class.outer", + }, + }, + }, +})