treesitter sruf movement/swap and line movement

master
spike 2 years ago
parent a388697e9b
commit a068850c79

@ -1,5 +1,5 @@
---@diagnostic disable: trailing-space
-- vim: foldmethod=marker foldlevel=0
-- vim: foldmethod=marker foldlevel=1
-- n, v, i, t, c = mode name.s
local function termcodes(str)
@ -92,8 +92,8 @@ M.general = { --{{{
-- lua source current file
["<leader>.."] = {"<cmd> :w | source %<CR>", "save and source script "},
["<leader>.m"] = { function ()
["<leader>."] = {"<cmd> :w | source %<CR>", "save and source script "},
["<leader>rm"] = { function ()
local ok, core = pcall(require, "core")
if not ok then
return
@ -201,8 +201,50 @@ M.general = { --{{{
"Treesitter playground"
},
["<leader>en"] = { "<cmd> cn <CR>", "next error" },
-- Moving lines around
["<M-Down>"] = {"<cmd>:m +1<CR>==", "move line up"},
["<M-Up>"] = {"<cmd>:m .-2<CR>==", "move line up"},
-- syntax-tree-surfer
-- visual selection from nomral mode
["vm"] = {"<cmd>STSSelectMasterNode<CR>", "select master node"},
["vn"] = {"<cmd>STSSelectCurrentNode<CR>", "select master node"},
-- normal mode swapping
-- swappint up/down
["vU"] = {function()
vim.opt.opfunc = "v:lua.STSSwapUpNormal_Dot"
return "g@l"
end, "TS swap Up master node with sibling", opts = { expr = true}},
["<BS><Up>"] = {function()
vim.opt.opfunc = "v:lua.STSSwapUpNormal_Dot"
return "g@l"
end, "TS swap Up master node with sibling", opts = { expr = true}},
["vD"] = {function()
vim.opt.opfunc = "v:lua.STSSwapDownNormal_Dot"
return "g@l"
end, "TS swap Down master node with sibling", opts = { expr = true}},
["<BS><Down>"] = {function()
vim.opt.opfunc = "v:lua.STSSwapDownNormal_Dot"
return "g@l"
end, "TS swap Down master node with sibling", opts = { expr = true}},
-- swapping left/right sibling nodes
["<M-Right>"] = {function()
vim.opt.opfunc = "v:lua.STSSwapCurrentNodeNextNormal_Dot"
return "g@l"
end, "TS swap right with sibling", opts = { expr = true}},
["<M-Left>"] = {function()
vim.opt.opfunc = "v:lua.STSSwapCurrentNodePrevNormal_Dot"
return "g@l"
end, "TS swap left with sibling", opts = { expr = true}},
["]e"] = { "<cmd> cn <CR>", "next error" },
["<leader>en"] = { "<cmd> cn <CR>", "next error" },
["<leader>ep"] = { "<cmd> cp <CR>", "previous error" },
["[e"] = { "<cmd> cp <CR>", "previous error" },
@ -328,8 +370,21 @@ M.general = { --{{{
-- "enable Treesitter folding"}
},--}}}
-- visual mode
-- x = { },
-- visual exclusive mode (ignore select)
x = { -- {{{
-- syntax-tree-surfer
["J"] = {"<cmd>STSSelectNextSiblingNode<CR>", "select next sibling node"},
["K"] = {"<cmd>STSSelectPrevSiblingNode<CR>", "select prev sibling node"},
["H"] = {"<cmd>STSSelectParentNode<CR>", "select prev sibling node"},
["L"] = {"<cmd>STSSelectChildNode<CR>", "select prev sibling node"},
-- swap nodes tip: start first with master/child node selection then use these
["<M-Up>"] = {"<cmd>STSSwapPrevVisual<CR>", "select prev sibling node"},
["<M-Left>"] = {"<cmd>STSSwapPrevVisual<CR>", "select prev sibling node"},
["<M-Down>"] = {"<cmd>STSSwapNextVisual<CR>", "select next sibling node"},
["<M-Right>"] = {"<cmd>STSSwapNextVisual<CR>", "select next sibling node"},
},-- }}}
} --}}}
M.tabufline = { --{{{
@ -774,7 +829,6 @@ M.general = { --{{{
plugin = true,
n = {
["<Right>"] = { "<cmd> lua require'navigator.treesitter'.side_panel()<CR><C-w>h", "toggle TreeSitter symbols panel " },
["<M-Right>"] = { "<cmd> lua require'navigator.symbols'.side_panel()<CR><C-w>h", "toggle LSP symbols panel" },
}
}--}}}

@ -33,6 +33,7 @@ local config = {
{ key = 'K', func = vim.lsp.buf.hover, desc = 'lsp hover' },
{ key = '<M-a>', mode = 'n', func = require('navigator.codeAction').code_action, desc = 'lsp code_action' },
{ key = '<M-a>', mode = 'i', func = require('navigator.codeAction').code_action, desc = 'lsp code_action' },
{ key = '<BS><Right>', mode = 'n', func = require('navigator.symbols').side_panel, desc = 'toggle lsp outline pannel'},
{
key = '<M-a>',
mode = 'v',
@ -48,7 +49,7 @@ local config = {
{ key = 'gL', func = require('navigator.diagnostics').show_diagnostics, desc = 'lsp show_diagnostics' },
{ key = 'gG', func = require('navigator.diagnostics').show_buf_diagnostics, desc = 'lsp show_buf_diagnostics' },
-- { key = '<Leader>dt', func = require('navigator.diagnostics').toggle_diagnostics, desc = 'lsp toggle_diagnostics' },
{ key = '<Leader>td', func = require('spike.lsp').toggle_diagnostics, desc = 'lsp toggle_diagnostics' },
{ key = '<Leader>td', func = require('spike.diagnostics').toggle, desc = 'lsp toggle_diagnostics' },
{ key = ']d', func = vim.diagnostic.goto_next, desc = 'lsp next diagnostics' },
{ key = '[d', func = vim.diagnostic.goto_prev, desc = 'lsp prev diagnostics' },
{ key = ']O', func = vim.diagnostic.set_loclist, desc = 'lsp diagnostics set loclist' },

@ -33,8 +33,8 @@ return {
enable = true,
keymaps = {
init_selection = "<Space>",
node_incremental = "<Space>",
node_decremental = "<BS>",
node_incremental = "<BS>",
node_decremental = "<Space>",
scope_incremental = "<CR>",
}
},
@ -104,7 +104,7 @@ return {
},
swap = {
enable = true,
enable = false, -- swap using syntax-tree-surfer
swap_next = {
["~"] = "@parameter.inner"
},

@ -58,18 +58,25 @@ return {
setup = function()
require("core.lazy_load").on_file_open "nvim-treesitter"
require("core.lazy_load").on_file_open "nvim-treesitter-textobjects"
require("core.lazy_load").on_file_open "nvim-treesitter-textsubjects"
-- require("core.lazy_load").on_file_open "nvim-treesitter-textsubjects"
require("core.lazy_load").on_file_open "nvim-treesitter-context"
require("core.lazy_load").on_file_open "syntax-tree-surfer"
-- require("core.lazy_load").on_file_open "nvim-ts-rainbow"
end,
},
["nvim-treesitter/nvim-treesitter-textobjects"] = {
opt = true,
},
["RRethy/nvim-treesitter-textsubjects"] = {
-- ["RRethy/nvim-treesitter-textsubjects"] = {
-- opt = true,
-- },
["ziontee113/syntax-tree-surfer"] = {
opt = true,
config = function()
require("syntax-tree-surfer").setup()
end
},
-- Treesitter dev/exploration tool
["nvim-treesitter/playground"] = {
opt = true,
@ -114,11 +121,12 @@ return {
["L3MON4D3/LuaSnip"] = {
lock = false,
config = function()
module = "luasnip",
config = function() -- overriding default nvchad config here
-- load default config first
require("custom.plugins.configs.luasnip").setup()
vim.g.my_snippets_paths = { "./custom_snippets" }
vim.g.my_snippets_paths = { vim.fn.stdpath('config') .. '/mysnippets' }
require("luasnip").filetype_extend("markdown", { "markdown_zk" })
-- load snippets from "honza/vim-snippets"
@ -129,6 +137,12 @@ return {
paths = vim.g.my_snippets_paths,
override_priority = 600
}
-- my luasnip snippets
require("luasnip.loaders.from_lua").lazy_load {
paths = vim.g.my_snippets_paths,
override_priority = 2000, -- highest priority for my luasnips
}
end
}, -- }}}
@ -177,7 +191,26 @@ return {
["theHamsta/nvim-dap-virtual-text"] = {
lock = true,
after = "nvim-dap"
after = "nvim-dap",
config = function()
require("nvim-dap-virtual-text").setup({
enabled = true, -- enable this plugin (the default)
enabled_commands = true, -- create commands DapVirtualTextEnable, DapVirtualTextDisable, DapVirtualTextToggle, (DapVirtualTextForceRefresh for refreshing when debug adapter did not notify its termination)
highlight_changed_variables = true, -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText
highlight_new_as_changed = false, -- highlight new variables in the same way as changed variables (if highlight_changed_variables)
show_stop_reason = true, -- show stop reason when stopped for exceptions
commented = false, -- prefix virtual text with comment string
only_first_definition = true, -- only show virtual text at first definition (if there are multiple)
all_references = false, -- show virtual text on all all references of the variable (not only definitions)
filter_references_pattern = '<module', -- filter references (not definitions) pattern when all_references is activated (Lua gmatch pattern, default filters out Python modules)
-- experimental features:
virt_text_pos = 'eol', -- position of virtual text, see `:h nvim_buf_set_extmark()`
all_frames = true, -- show virtual text for all stack frames not only current. Only works for debugpy on my machine.
virt_lines = false, -- show virtual lines instead of virtual text (will flicker!)
virt_text_win_col = 80 -- position the virtual text at a fixed window column (starting from the first text column) ,
-- e.g. 80 to position at column 80, see `:h nvim_buf_set_extmark()`
})
end
}, -- }}}
-- User Interface / UX
@ -346,7 +379,7 @@ return {
delay_ms = 1000, -- How long repeated usage of a key should be prevented
grace_period = 1, -- How many repeated keypresses are allowed
keys = { -- Which keys (in which modes) should be delayed
['nv'] = { 'h', 'j', 'k', 'l' },
['n'] = { 'h', 'j', 'k', 'l' },
-- ['nvi'] = { '<Left>', '<Down>', '<Up>', '<Right>' },
},
ignore_filetypes = {

Loading…
Cancel
Save