Compare commits

...

2 Commits

Author SHA1 Message Date
b9be6fba5a Fix - mapping sometimes landing on wrong filename
Instead of using Lua to search through all buffer lines and match the
file line containing the filename, instead use `search()` and wrap the
filename in word boundry delimiters `\<\>` to always match the whole
filename not a subscript. This also moves the cursor to that position
in the file.
2024-03-17 14:16:34 +00:00
c235fb88e1 Setup is required for unimpaired.nvim 2024-03-17 14:16:06 +00:00
2 changed files with 7 additions and 11 deletions

View File

@ -18,17 +18,8 @@ vim.keymap.set('n', '-', function()
-- Invoke netrw on the directory containing the current file -- Invoke netrw on the directory containing the current file
vim.fn.execute(string.format("edit %s", directory)) vim.fn.execute(string.format("edit %s", directory))
if filename ~= '' then if filename ~= '' then
-- In the netrw buffer, move the cursor to the first character of filename -- In the netrw buffer, move the cursor to the first character of filename
local buffer = vim.api.nvim_get_current_buf() vim.fn.search('\\<' .. filename .. '\\>')
local lines = vim.api.nvim_buf_get_lines(buffer, 0, -1, true)
for row, content in ipairs(lines) do
local column = string.find(content, filename)
if column then
vim.api.nvim_win_set_cursor(0, { row, column - 1 })
break
end
end
end end
end) end)

View File

@ -1,5 +1,10 @@
return { return {
{ 'tummetott/unimpaired.nvim' }, {
'tummetott/unimpaired.nvim',
config = function()
require('unimpaired').setup({})
end
},
{ 'stevearc/dressing.nvim' }, { 'stevearc/dressing.nvim' },
{ 'kevinhwang91/nvim-bqf' }, { 'kevinhwang91/nvim-bqf' },
} }