Skip to content

Commit a30367a

Browse files
Merge pull request #10 from DeadlySquad13/dev
Navigation and search.
2 parents 88cf948 + 94b94d5 commit a30367a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+767
-220
lines changed

after/ftplugin/lua

Submodule lua updated from 9ced5f2 to 8ddd63f

init.vim

+5
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,8 @@ func AppendSome()
214214
" return cmd
215215
endfunc
216216

217+
" Highlight only leading whitespace characters.
218+
highlight WhiteSpaceLeading guifg=#918278
219+
highlight WhiteSpace guifg=#efe0b9
220+
match WhiteSpace / /
221+
2match WhiteSpaceLeading /^ \+/

lua/config/Editing/undo.lua

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
local undo_actions = require("telescope-undo.actions")
2+
3+
return {
4+
-- use_custom_command = { 'cmd.exe', '/c', [[echo $DIFF | delta]]}, -- setting this implies `use_delta = false`. Accepted format is: { "bash", "-c", "echo '$DIFF' | delta" }
5+
use_custom_command = { 'pwsh.exe', '-NoProfile', '-Command', 'echo "$DIFF" | delta'}, -- setting this implies `use_delta = false`. Accepted format is: { "bash", "-c", "echo '$DIFF' | delta" }
6+
side_by_side = true, -- Available only with delta.
7+
layout_strategy = 'vertical',
8+
layout_config = {
9+
preview_height = 0.8,
10+
},
11+
12+
diff_context_lines = vim.o.scrolloff,
13+
entry_format = 'state #$ID, $STAT, $TIME',
14+
15+
mappings = {
16+
i = {
17+
-- IMPORTANT: Note that telescope-undo must be available when telescope is configured if
18+
-- you want to replicate these defaults and use the following actions. This means
19+
-- installing as a dependency of telescope in it's `requirements` and loading this
20+
-- extension from there instead of having the separate plugin definition as outlined
21+
-- above.
22+
["<C-y>"] = undo_actions.yank_additions,
23+
-- ["<C-y>"] = undo_actions.yank_deletions,
24+
["<Cr>"] = undo_actions.restore,
25+
},
26+
},
27+
}

lua/config/Lsp/completion/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ local window_visuals = require('config.lsp.completion.window_visuals')
77
local formatting = require('config.lsp.completion.formatting')
88
local keymappings = require('config.lsp.completion.keymappings')
99

10-
local MIN_KEYWORD_LENGTH = 4
10+
local MIN_KEYWORD_LENGTH = 2
1111

1212
cmp.setup({
1313
window = window_visuals,

lua/config/Lsp/lspsaga.lua

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- change the lsp symbol kind
2-
local lspkind = require('lspsaga.lspkind')
2+
-- local lspkind = require('lspsaga.lspkind')
33

44
return {
55
-- ???
@@ -87,4 +87,23 @@ return {
8787
-- the related filetypes into this table
8888
-- like server_filetype_map = { metals = { "sbt", "scala" } }
8989
server_filetype_map = {},
90+
91+
ui = {
92+
-- Currently, only the round theme exists
93+
theme = "round",
94+
-- This option only works in Neovim 0.9
95+
title = true,
96+
-- Border type can be single, double, rounded, solid, shadow.
97+
border = "solid",
98+
winblend = 0,
99+
expand = "",
100+
collapse = "",
101+
preview = "👁 ", -- Eye: U+1F441.
102+
code_action = "💡",
103+
diagnostic = "🐞 ",
104+
incoming = "📨 ", -- Incoming envelope: U+1F4E8.
105+
outgoing = "", -- Envelope: ^Vu2709.
106+
hover = '🔍 ', -- Left-Pointing Magnifying Glass: U+1F50D.
107+
kind = {},
108+
}
90109
}

lua/config/Lsp/null_ls.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ return {
1919
formatting.stylua,
2020

2121
-- General
22-
---@see [misspell](https://github.com/client9/misspell).
22+
-- see [misspell](https://github.com/client9/misspell).
2323
-- diagnostics.misspell,
2424

2525
-- Typescript

lua/config/Navigation/flit.lua

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
local leap_settings = require('config.Navigation.leap.settings')
2+
3+
return {
4+
labeled_modes = 'vo',
5+
multiline = false,
6+
opts = {
7+
safe_labels = leap_settings.safe_labels,
8+
}
9+
}

lua/config/Navigation/leap/init.lua

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
return {
2+
settings = require('config.Navigation.leap.settings'),
3+
keymappings = require('config.Navigation.leap.keymappings'),
4+
5+
commands = {
6+
multi_normal = require('config.Navigation.leap.multi_normal'),
7+
}
8+
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-- See [second proposal](https://github.com/ggandor/leap.nvim/discussions/41):
2+
-- abcd| |bcde
3+
-- ████e ← Zab zde → █████ (this might also be the desired behavior for Visual `s` - see below)
4+
-- ab██e ← Xab xde → ███de
5+
local keymappings = {
6+
z = { '<Plug>(leap-forward-to)', 'Leap forward to' },
7+
Z = { '<Plug>(leap-backward-to)', 'Leap backward to' },
8+
9+
-- 'x' for exclusive.
10+
x = { '<Plug>(leap-forward-till)', 'Leap forward till' },
11+
X = { '<Plug>(leap-backward-till)', 'Leap backward till' },
12+
}
13+
14+
return {
15+
o = keymappings,
16+
x = keymappings,
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
local prequire = require('utils').prequire
2+
3+
local leap_is_available, leap = prequire('leap')
4+
5+
if not leap_is_available then
6+
return
7+
end
8+
9+
-- see [multi-cursor ':normal'](https://github.com/ggandor/leap.nvim#calling-leap-with-custom-arguments)
10+
-- The following example showcases a custom action, using `multiselect`. We're
11+
-- executing a `normal!` command at each selected position (this could be even
12+
-- more useful if we'd pass in custom targets too).
13+
function multi_normal(targets)
14+
-- Get the :normal sequence to be executed.
15+
local input = vim.fn.input("normal! ")
16+
if #input < 1 then return end
17+
18+
local ns = vim.api.nvim_create_namespace("")
19+
20+
-- Set an extmark as an anchor for each target, so that we can also execute
21+
-- commands that modify the positions of other targets (insert/change/delete).
22+
for _, target in ipairs(targets) do
23+
local line, col = unpack(target.pos)
24+
id = vim.api.nvim_buf_set_extmark(0, ns, line - 1, col - 1, {})
25+
target.extmark_id = id
26+
end
27+
28+
-- Jump to each extmark (anchored to the "moving" targets), and execute the
29+
-- command sequence.
30+
for _, target in ipairs(targets) do
31+
local id = target.extmark_id
32+
local pos = vim.api.nvim_buf_get_extmark_by_id(0, ns, id, {})
33+
vim.fn.cursor(pos[1] + 1, pos[2] + 1)
34+
vim.cmd("normal! " .. input)
35+
end
36+
37+
-- Clean up the extmarks.
38+
vim.api.nvim_buf_clear_namespace(0, ns, 0, -1)
39+
end
40+
41+
-- Usage:
42+
local create_user_command = require('config.commands.utils').create_user_command
43+
44+
create_user_command(
45+
'MultiNormal',
46+
function()
47+
leap.leap({
48+
target_windows = { vim.fn.win_getid() },
49+
action = multi_normal,
50+
multiselect = true,
51+
})
52+
end,
53+
{ nargs = 0 }
54+
)
55+
56+
return multi_normal
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
return {
2+
max_phase_one_targets = nil,
3+
highlight_unlabeled_phase_one_targets = true,
4+
max_highlighted_traversal_targets = 10,
5+
case_sensitive = true,
6+
equivalence_classes = { ' \t\r\n' },
7+
substitute_chars = { ['\r'] = '¬' },
8+
safe_labels = {
9+
's', 'f', 'n', 'u', 't', '/',
10+
'S', 'F', 'N', 'L', 'H', 'M', 'U', 'G', 'T', '?', 'Z',
11+
},
12+
labels = {
13+
's', 'f',
14+
'j', 'k', 'l', 'h', 'o', 'd', 'w', 'e', 'm',
15+
'v', 'r', 'c', 'x', '/', 'z',
16+
'S', 'F',
17+
'J', 'K', 'L', 'H', 'O', 'D', 'W', 'E', 'M',
18+
'V', 'R', 'C', 'X', '?', 'Z',
19+
},
20+
special_keys = {
21+
repeat_search = '<enter>',
22+
next_phase_one_target = '<enter>',
23+
next_target = {'<enter>', ';'},
24+
prev_target = {'<tab>', ','},
25+
next_group = '<space>',
26+
prev_group = '<tab>',
27+
multi_accept = '<enter>',
28+
multi_revert = '<backspace>',
29+
},
30+
}

lua/config/Navigation/sj/init.lua

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
return {
2+
settings = require('config.Navigation.sj.settings'),
3+
keymappings = require('config.Navigation.sj.keymappings'),
4+
}
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
local prequire = require('utils').prequire
2+
3+
local sj_is_available, sj = prequire('sj')
4+
5+
if not sj_is_available then
6+
return
7+
end
8+
9+
-- Keymappings used during the search are in settings.
10+
return {
11+
n = {
12+
['/'] = { sj.run, 'Search and jump' },
13+
['?'] = { function() sj.run({ forward_search = false }) end, 'Search and jump backwards' },
14+
['<Leader>'] = {
15+
-- Default bindings that we have overriden in case you just want to iterate over search results.
16+
['/'] = { '/', 'Search' },
17+
['?'] = { '?', 'Search backwards' },
18+
19+
-- Like a leap but a little bit different.
20+
s = { function() sj.run({ search_scope = 'visible_lines' }) end, 'Search and jump across visible lines' },
21+
S = { function() sj.run({ search_scope = 'visible_lines', forward_search = false }) end, 'Search and jump across visible lines backwards' },
22+
},
23+
},
24+
}

lua/config/Navigation/sj/settings.lua

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
local leap_settings = require('config.Navigation.leap.settings')
2+
3+
return {
4+
auto_jump = false,
5+
separator = ';', -- Character used to split the user input in <pattern> and <label> (can be empty).
6+
use_overlay = false, -- If true, apply an overlay to better identify labels and matches.
7+
labels = leap_settings.labels,
8+
relative_labels = true, -- if true, labels are ordered from the cursor position,
9+
update_search_register = true, -- If true, update the search register with the last used pattern.
10+
-- Can be: current_line, visible_lines_above, visible_lines_below, visible_lines, buffer.
11+
search_scope = 'buffer', -- To align more with default / and ?
12+
13+
keymaps = {
14+
prev_pattern = "<C-k>", -- Select the previous pattern while searching.
15+
next_pattern = "<C-j>", -- Select the next pattern while searching.
16+
17+
send_to_qflist = "<C-q>", --- Send the search results to the quickfix list.
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
return {
2+
settings = require('config.Navigation.syntax_tree_surfer.settings'),
3+
keymappings = require('config.Navigation.syntax_tree_surfer.keymappings'),
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
return {
2+
n = {
3+
v = {
4+
-- Normal Mode Swapping.
5+
U = {
6+
function()
7+
vim.opt.opfunc = 'v:lua.STSSwapUpNormal_Dot'
8+
return 'g@l'
9+
end,
10+
'Swap up the master node relative to the cursor with its siblings',
11+
expr = true,
12+
},
13+
D = {
14+
function()
15+
vim.opt.opfunc = 'v:lua.STSSwapDownNormal_Dot'
16+
return 'g@l'
17+
end,
18+
'Swap down the master node relative to the cursor with its siblings',
19+
expr = true,
20+
},
21+
22+
-- Swap Current Node at the Cursor with it's siblings, Dot Repeatable
23+
d = {
24+
function()
25+
vim.opt.opfunc = 'v:lua.STSSwapCurrentNodeNextNormal_Dot'
26+
return 'g@l'
27+
end,
28+
'Swap current node with next',
29+
expr = true,
30+
},
31+
u = {
32+
function()
33+
vim.opt.opfunc = 'v:lua.STSSwapCurrentNodePrevNormal_Dot'
34+
return 'g@l'
35+
end,
36+
'Swap current node with previous',
37+
expr = true,
38+
},
39+
40+
41+
-- Visual Selection from Normal Mode.
42+
x = { '<Cmd>STSSelectMasterNode<Cr>', 'Select master node' },
43+
n = { '<Cmd>STSSelectCurrentNode<Cr>', 'Select current node' },
44+
},
45+
},
46+
47+
x = {
48+
-- Select Nodes in Visual Mode
49+
J = { '<Cmd>STSSelectNextSiblingNode<Cr>', 'Select next sibling node' },
50+
K = { '<Cmd>STSSelectPrevSiblingNode<Cr>', 'Select previous sibling node' },
51+
H = { '<Cmd>STSSelectParentNode<Cr>', 'Select parent node' },
52+
L = { '<Cmd>STSSelectChildNode<Cr>', 'select child node' },
53+
54+
-- Swapping Nodes in Visual Mode
55+
['<A-j>'] = { '<Cmd>STSSwapNextVisual<Cr>', 'Swap with next node' },
56+
['<A-k>'] = { '<Cmd>STSSwapPrevVisual<Cr>', 'Swap with previous node' },
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
return {}

lua/config/Navigation/telescope.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ return {
2727
},
2828

2929
extensions = {
30-
file_browser = require('config.Navigation.telescope_file_browser')
30+
file_browser = require('config.Navigation.telescope_file_browser'),
31+
undo = require('config.Editing.undo'),
3132
}
3233
}

lua/config/commands/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local choose_and_edit_target = require('config.commands.choose_and_edit_target')
22
local create_user_command = require('config.commands.utils').create_user_command
33

4-
---@see `:h user-commands` and `:h nvim_create_user_command()`.
4+
-- See `:h user-commands` and `:h nvim_create_user_command()`.
55

66
create_user_command(
77
'ChooseAndEditConfigs',

lua/config/keymappings/buffer.lua

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ return {
22
name = 'Buffer',
33

44
-- Deletes buffer without closing vim if it was in the only window.
5-
d = { ':Bdelete<cr>', 'Delete' },
5+
d = { '<Cmd>Bdelete<Cr>', 'Delete' },
6+
D = { '<Cmd>%bdelete|edit#<Cr>', 'Delete all buffer except for current one' },
67

7-
---@see{the lua api at @link{https://github.com/akinsho/bufferline.nvim/blob/main/lua/bufferline.lua}}
8+
--see the [lua api](https://github.com/akinsho/bufferline.nvim/blob/main/lua/bufferline.lua)
89
--p = { function() bufferline.pick_buffer() end, 'Pick' },
9-
p = { '<cmd>BufferLinePick<cr>', 'Pick' },
10-
n = { 'bn', 'Next' },
10+
p = { '<Cmd>BufferLinePick<Cr>', 'Pick' },
11+
n = { '<Cmd>bnext<Cr>', 'Next' },
1112
}

lua/config/treesitter/init.lua

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ local incremental_selection = require_treesitter_configuration(
2020
)
2121
local rainbow = require_treesitter_configuration('rainbow')
2222

23+
local textobjects = require_treesitter_configuration('textobjects')
24+
2325
-- List of language that will be disabled
2426
local DISABLED_HIGHLIGHT_FILETYPES = {
2527
'css',
@@ -54,6 +56,8 @@ tree_sitter.setup({
5456
-- Brackets.
5557
rainbow = rainbow,
5658

59+
textobjects = textobjects,
60+
5761
context_commentstring = {
5862
enable = true,
5963
-- Disable the CursorHold autocommand of this plugin to work with

0 commit comments

Comments
 (0)