Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reverse_order option to get_location() #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions lua/nvim-navic/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ local config = {
click = false,
lsp = {
auto_attach = false,
preference = nil
}
preference = nil,
},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need to add the reverse option here as well

}

setmetatable(config.icons, {
Expand Down Expand Up @@ -217,7 +217,7 @@ function M.get_location(opts, bufnr)
vim.cmd("normal! m'")
vim.api.nvim_win_set_cursor(0, {
data[minwid].scope["start"].line,
data[minwid].scope["start"].character
data[minwid].scope["start"].character,
})
if cnt > 1 then
local ok, navbuddy = pcall(require, "nvim-navbuddy")
Expand All @@ -231,11 +231,7 @@ function M.get_location(opts, bufnr)
end

local function add_click(level, component)
return "%"
.. level
.. "@v:lua.navic_click_handler@"
.. component
.. "%X"
return "%" .. level .. "@v:lua.navic_click_handler@" .. component .. "%X"
end

for i, v in ipairs(data) do
Expand Down Expand Up @@ -274,6 +270,14 @@ function M.get_location(opts, bufnr)

local ret = ""

if opts.reverse_order then
local reverse = {}
for i = #location, 1, -1 do
reverse[#reverse + 1] = location[i]
end
location = reverse
end

if local_config.highlight then
ret = table.concat(location, "%#NavicSeparator#" .. local_config.separator .. "%*")
else
Expand Down