summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.lua66
-rw-r--r--lua/plugins/init.lua8
-rw-r--r--lua/plugins/treesitter.lua69
3 files changed, 71 insertions, 72 deletions
diff --git a/init.lua b/init.lua
index 4a32cbf..7d14185 100644
--- a/init.lua
+++ b/init.lua
@@ -25,6 +25,7 @@ vim.o.hlsearch = false
-- Make line numbers default
vim.wo.number = true
+vim.wo.relativenumber = true
-- Enable mouse mode
vim.o.mouse = 'a'
@@ -75,70 +76,7 @@ vim.api.nvim_create_autocmd('TextYankPost', {
pattern = '*',
})
--- [[ Configure Treesitter ]]
-require('nvim-treesitter.configs').setup {
- -- Add languages to be installed here that you want installed for treesitter
- ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim' },
-
- -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
- auto_install = false,
-
- highlight = { enable = true },
- indent = { enable = true, disable = { 'python' } },
- incremental_selection = {
- enable = true,
- keymaps = {
- init_selection = '<c-space>',
- node_incremental = '<c-space>',
- scope_incremental = '<c-s>',
- node_decremental = '<M-space>',
- },
- },
- textobjects = {
- select = {
- enable = true,
- lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
- keymaps = {
- -- You can use the capture groups defined in textobjects.scm
- ['aa'] = '@parameter.outer',
- ['ia'] = '@parameter.inner',
- ['af'] = '@function.outer',
- ['if'] = '@function.inner',
- ['ac'] = '@class.outer',
- ['ic'] = '@class.inner',
- },
- },
- move = {
- enable = true,
- set_jumps = true, -- whether to set jumps in the jumplist
- goto_next_start = {
- [']m'] = '@function.outer',
- [']]'] = '@class.outer',
- },
- goto_next_end = {
- [']M'] = '@function.outer',
- [']['] = '@class.outer',
- },
- goto_previous_start = {
- ['[m'] = '@function.outer',
- ['[['] = '@class.outer',
- },
- goto_previous_end = {
- ['[M'] = '@function.outer',
- ['[]'] = '@class.outer',
- },
- },
- swap = {
- enable = true,
- swap_next = {
- ['<leader>a'] = '@parameter.inner',
- },
- swap_previous = {
- ['<leader>A'] = '@parameter.inner',
- },
- },
- },
-}
+
-- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua
index 9478ab5..38e8c42 100644
--- a/lua/plugins/init.lua
+++ b/lua/plugins/init.lua
@@ -74,12 +74,4 @@ return {
-- "gc" to comment visual regions/lines
{ 'numToStr/Comment.nvim', opts = {} },
- {
- -- Highlight, edit, and navigate code
- 'nvim-treesitter/nvim-treesitter',
- dependencies = {
- 'nvim-treesitter/nvim-treesitter-textobjects',
- },
- build = ':TSUpdate',
- },
}
diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua
new file mode 100644
index 0000000..4d3015a
--- /dev/null
+++ b/lua/plugins/treesitter.lua
@@ -0,0 +1,69 @@
+return {
+ 'nvim-treesitter/nvim-treesitter',
+ dependencies = {
+ 'nvim-treesitter/nvim-treesitter-textobjects',
+ },
+ build = ':TSUpdate',
+ opts = {
+ ensure_installed = { 'go', 'lua', 'python', 'typescript', 'vimdoc', 'vim' },
+ auto_install = false,
+
+ highlight = { enable = true },
+ indent = { enable = true, disable = { 'python' } },
+ incremental_selection = {
+ enable = true,
+ keymaps = {
+ init_selection = '<c-space>',
+ node_incremental = '<c-space>',
+ scope_incremental = '<c-s>',
+ node_decremental = '<M-space>',
+ },
+ },
+ 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
+ ['aa'] = '@parameter.outer',
+ ['ia'] = '@parameter.inner',
+ ['af'] = '@function.outer',
+ ['if'] = '@function.inner',
+ ['ac'] = '@class.outer',
+ ['ic'] = '@class.inner',
+ },
+ },
+ move = {
+ enable = true,
+ -- Whether to set jumps in the jumplist
+ set_jumps = true,
+ goto_next_start = {
+ [']m'] = '@function.outer',
+ [']]'] = '@class.outer',
+ },
+ goto_next_end = {
+ [']M'] = '@function.outer',
+ [']['] = '@class.outer',
+ },
+ goto_previous_start = {
+ ['[m'] = '@function.outer',
+ ['[['] = '@class.outer',
+ },
+ goto_previous_end = {
+ ['[M'] = '@function.outer',
+ ['[]'] = '@class.outer',
+ },
+ },
+ swap = {
+ enable = true,
+ swap_next = {
+ ['<leader>a'] = '@parameter.inner',
+ },
+ swap_previous = {
+ ['<leader>A'] = '@parameter.inner',
+ },
+ },
+ },
+ }
+}