@@ -62,6 +62,7 @@ Using [lazy.nvim](https://github.com/folke/lazy.nvim):
62
62
options = {}, -- here you can configure namu
63
63
},
64
64
-- Optional: Enable other modules if needed
65
+ ui_select = { enable = false }, -- vim.ui.select() wrapper
65
66
colorscheme = {
66
67
enable = false ,
67
68
options = {
@@ -70,11 +71,8 @@ Using [lazy.nvim](https://github.com/folke/lazy.nvim):
70
71
write_shada = false , -- If you open multiple nvim instances, then probably you need to enable this
71
72
},
72
73
},
73
- ui_select = { enable = false }, -- vim.ui.select() wrapper
74
74
})
75
75
-- === Suggested Keymaps: ===
76
- local namu = require (" namu.namu_symbols" )
77
- local colorscheme = require (" namu.colorscheme" )
78
76
vim .keymap .set (" n" , " <leader>ss" ," :Namu symbols<cr>" , {
79
77
desc = " Jump to LSP symbol" ,
80
78
silent = true ,
@@ -107,7 +105,7 @@ Using [lazy.nvim](https://github.com/folke/lazy.nvim):
107
105
108
106
</details >
109
107
110
- ### Default Keymaps
108
+ ### Keymaps
111
109
112
110
<details >
113
111
<summary >Default keymaps are:</summary >
@@ -123,16 +121,6 @@ Using [lazy.nvim](https://github.com/folke/lazy.nvim):
123
121
| ` <Up> ` | Previous item |
124
122
| ` q ` | Close help |
125
123
126
- to change the movement keys to ` C-j ` and ` C-k ` :
127
- ``` lua
128
- -- in namu_symbols.options
129
- movement = {
130
- next = " <C-j>" ,
131
- previous = " <C-k>" ,
132
- alternative_next = " <DOWN>" ,
133
- alternative_previous = " <UP>" ,
134
- },
135
- ```
136
124
137
125
138
126
#### Multiselect
@@ -154,8 +142,57 @@ movement = {
154
142
155
143
</details >
156
144
145
+ ### Change Keymaps:
146
+
147
+ <details >
148
+ <summary >change the default keymaps:</summary >
149
+
150
+ ``` lua
151
+ -- in namu_symbols.options
152
+ movement = {
153
+ next = { " <C-n>" , " <DOWN>" }, -- Support multiple keys
154
+ previous = { " <C-p>" , " <UP>" }, -- Support multiple keys
155
+ close = { " <ESC>" }, -- close mapping
156
+ select = { " <CR>" }, -- select mapping
157
+ delete_word = {}, -- delete word mapping
158
+ clear_line = {}, -- clear line mapping
159
+ },
160
+ multiselect = {
161
+ enabled = false ,
162
+ indicator = " ●" , -- or "✓"◉
163
+ keymaps = {
164
+ toggle = " <Tab>" ,
165
+ select_all = " <C-a>" ,
166
+ clear_all = " <C-l>" ,
167
+ untoggle = " <S-Tab>" ,
168
+ },
169
+ max_items = nil , -- No limit by default
170
+ },
171
+ custom_keymaps = {
172
+ yank = {
173
+ keys = { " <C-y>" }, -- yank symbol text
174
+ },
175
+ delete = {
176
+ keys = { " <C-d>" }, -- delete symbol text
177
+ },
178
+ vertical_split = {
179
+ keys = { " <C-v>" }, -- open in vertical split
180
+ },
181
+ horizontal_split = {
182
+ keys = { " <C-h>" }, -- open in horizontal split
183
+ },
184
+ codecompanion = {
185
+ keys = " <C-o>" , -- Add symbols to CodeCompanion
186
+ },
187
+ avante = {
188
+ keys = " <C-t>" , -- Add symbol to Avante
189
+ },
190
+ },
191
+ ```
192
+
193
+ </details >
157
194
158
- ## Available Commands
195
+ ## Commands
159
196
160
197
The ` Namu ` command provides several subcommands with autocomplete:
161
198
@@ -326,97 +363,28 @@ M.config = {
326
363
close_on_yank = false , -- Whether to close picker after yanking
327
364
close_on_delete = true , -- Whether to close picker after deleting
328
365
},
329
- keymaps = {
330
- {
331
- key = " <C-y>" ,
332
- handler = function (items_or_item , state )
333
- local success = M .yank_symbol_text (items_or_item , state )
334
- -- Only close if yanking was successful and config says to close
335
- if success and M .config .actions .close_on_yank then
336
- M .clear_preview_highlight ()
337
- return false -- This should close the picker
338
- end
339
- end ,
366
+ custom_keymaps = {
367
+ yank = {
368
+ keys = { " <C-y>" },
340
369
desc = " Yank symbol text" ,
341
370
},
342
- {
343
- key = " <C-d>" ,
344
- handler = function (items_or_item , state )
345
- local deleted = M .delete_symbol_text (items_or_item , state )
346
- -- Only close if deletion was successful and config says to close
347
- if deleted and M .config .actions .close_on_delete then
348
- M .clear_preview_highlight ()
349
- return false
350
- end
351
- end ,
352
- desc = " Delete symbol text" ,
371
+ delete = {
372
+ keys = { " <C-d>" },
353
373
},
354
- {
355
- key = " <C-v>" ,
356
- handler = function (item , selecta_state )
357
- if not state .original_buf then
358
- vim .notify (" No original buffer available" , vim .log .levels .ERROR )
359
- return
360
- end
361
-
362
- local new_win = selecta .open_in_split (selecta_state , item , " vertical" , state )
363
- if new_win then
364
- local symbol = item .value
365
- if symbol and symbol .lnum and symbol .col then
366
- -- Set cursor to symbol position
367
- pcall (vim .api .nvim_win_set_cursor , new_win , { symbol .lnum , symbol .col - 1 })
368
- vim .cmd (" normal! zz" )
369
- end
370
- M .clear_preview_highlight ()
371
- return false
372
- end
373
- end ,
374
+ vertical_split = {
375
+ keys = { " <C-v>" },
374
376
desc = " Open in vertical split" ,
375
377
},
376
- {
377
- key = " <C-h>" ,
378
- handler = function (item , selecta_state )
379
- if not state .original_buf then
380
- vim .notify (" No original buffer available" , vim .log .levels .ERROR )
381
- return
382
- end
383
-
384
- local new_win = selecta .open_in_split (selecta_state , item , " horizontal" , state )
385
- if new_win then
386
- local symbol = item .value
387
- if symbol and symbol .lnum and symbol .col then
388
- -- Set cursor to symbol position
389
- pcall (vim .api .nvim_win_set_cursor , new_win , { symbol .lnum , symbol .col - 1 })
390
- vim .cmd (" normal! zz" )
391
- end
392
- M .clear_preview_highlight ()
393
- return false
394
- end
395
- end ,
378
+ horizontal_split = {
379
+ keys = { " <C-h>" },
396
380
desc = " Open in horizontal split" ,
397
381
},
398
- {
399
- key = " <C-o>" ,
400
- handler = function (items_or_item )
401
- if type (items_or_item ) == " table" and items_or_item [1 ] then
402
- M .add_symbol_to_codecompanion (items_or_item , state .original_buf )
403
- else
404
- -- Single item case
405
- M .add_symbol_to_codecompanion ({ items_or_item }, state .original_buf )
406
- end
407
- end ,
382
+ codecompanion = {
383
+ keys = " <C-o>" ,
408
384
desc = " Add symbol to CodeCompanion" ,
409
385
},
410
- {
411
- key = " <C-t>" ,
412
- handler = function (items_or_item )
413
- if type (items_or_item ) == " table" and items_or_item [1 ] then
414
- M .add_symbol_to_avante (items_or_item , state .original_buf )
415
- else
416
- -- Single item case
417
- M .add_symbol_to_avante ({ items_or_item }, state .original_buf )
418
- end
419
- end ,
386
+ avante = {
387
+ keys = " <C-t>" ,
420
388
desc = " Add symbol to Avante" ,
421
389
},
422
390
},
@@ -484,5 +452,5 @@ Any suggestions to improve and integrate with other plugins are also welcome.
484
452
- [ Mini.pick] ( https://github.com/echasnovski/mini.nvim ) @echasnovski for the idea of ` getchar() ` , without which this plugin wouldn't exist.
485
453
- Magnet module (couldn’t find it anymore on GitHub, sorry!), which intrigued me a lot.
486
454
- @folke for handling multiple versions of Neovim LSP requests in [ Snacks.nvim] ( https://github.com/folke/snacks.nvim ) .
487
- - tests structure, thanks to @Oli [ CodeCompanion] ( https://github.com/olimorris/codecompanion.nvim )
455
+ - tests and ci structure, thanks to @Oli [ CodeCompanion] ( https://github.com/olimorris/codecompanion.nvim )
488
456
- A simple mechanism to persist the colorscheme, thanks to this [ Reddit comment] ( https://www.reddit.com/r/neovim/comments/1edwhk8/comment/lfb1m2f/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button ) .
0 commit comments