]> git.armaanb.net Git - dotfiles.git/commitdiff
nvim: use treesitter
authorArmaan Bhojwani <me@armaanb.net>
Mon, 22 Nov 2021 03:11:09 +0000 (22:11 -0500)
committerArmaan Bhojwani <me@armaanb.net>
Mon, 22 Nov 2021 03:11:09 +0000 (22:11 -0500)
.config/nvim/init.lua

index 148dfde6e8b230823be21fb67c227da4838ce459..b7888e62ed2a6679c5fd73a5fe7749568a26dd33 100644 (file)
@@ -8,9 +8,6 @@ vim.opt.textwidth = 80
 map('', 'Q', '<nop>', opts)
 vim.g.mapleader = ' '
 
--- Polyglot
-vim.g.polyglot_disabled = {'sensible'}
-
 -- Plugins
 local install_path = vim.fn.stdpath('data') .. '/site/pack/paqs/start/paq-nvim'
 
@@ -22,11 +19,11 @@ end
 require('impatient')
 
 require('paq') {
-       'junegunn/fzf';                   -- Fuzzy file finding
-       'junegunn/fzf.vim';               -- Fuzzy file finding
        'editorconfig/editorconfig-vim';  -- Follow editorconfig
        'folke/lsp-colors.nvim';          -- Add LSP colors to any theme
        'godlygeek/tabular';              -- Line things up
+       'junegunn/fzf';                   -- Fuzzy file finding
+       'junegunn/fzf.vim';               -- Fuzzy file finding
        'lewis6991/impatient.nvim';       -- Improve startup time
        'lifepillar/vim-mucomplete';      -- Simple autocompletion
        'meain/hima-vim';                 -- Nice color scheme
@@ -34,8 +31,9 @@ require('paq') {
        'neovim/nvim-lspconfig';          -- LSP configurations
        'norcalli/nvim-colorizer.lua';    -- Highlight css colors
        'ntpeters/vim-better-whitespace'; -- Highlight and strip whitespace
+       'nvim-treesitter/nvim-treesitter';-- Parsing
+       'romgrk/nvim-treesitter-context'; -- Shows context for where you are
        'savq/paq-nvim';                  -- paq manages itself
-       'sheerun/vim-polyglot';           -- Language pack
        'tpope/vim-commentary';           -- Easily comment
        'tpope/vim-rsi';                  -- Readline bindings
        'tpope/vim-sensible';             -- Sensible defaults
@@ -57,7 +55,7 @@ map('n', '<C-l>', '<C-w><C-l>', opts)
 map('n', '<C-c>', ':noh<CR>', opts)
 
 -- FZF
-map('n', '<leader>f', ':Files<CR>', opts)
+map('n', '<leader>ff', ':Files<CR>', opts)
 -- TODO: Sharp corners... I can't figure this out
 
 -- Disable keyword completion
@@ -118,3 +116,31 @@ vim.opt.path = vim.opt.path + '**'
 
 -- Disable intro message
 vim.opt.shortmess = "I"
+
+-- Treesitter
+require('nvim-treesitter.configs').setup {
+       ensure_installed = "maintained",
+       highlight = {
+               enable = true,
+               additional_vim_regex_highlighting = false,
+       },
+       incremental_selection = {
+               enable = true,
+               keymaps = {
+                       init_selection = "gnn",
+                       node_incremental = "grn",
+                       scope_incremental = "grc",
+                       node_decremental = "grm",
+               },
+       },
+       indent = {
+               enable = true
+       }
+}
+
+-- Folds
+vim.opt.foldmethod = 'expr'
+vim.opt.foldexpr = 'nvim_treesitter#foldexpr()'
+vim.opt.foldenable = false
+map('n', '<leader>fe', ':set foldenable<CR>', opts)
+map('n', '<leader>fd', ':set nofoldenable<CR>', opts)