feat: Allow setting line numbers / relative numbers

Closes #31
This commit is contained in:
simrat39
2021-06-22 19:59:49 -07:00
parent c6318d9279
commit a100b51b23
4 changed files with 24 additions and 0 deletions

View File

@@ -29,6 +29,8 @@ vim.g.symbols_outline = {
show_guides = true,
auto_preview = true,
position = 'right',
show_numbers = false,
show_relative_numbers = false,
keymaps = {
close = "<Esc>",
goto_location = "<Cr>",
@@ -49,6 +51,8 @@ let g:symbols_outline = {
\ "show_guides": v:true,
\ "position": 'right',
\ "auto_preview": v:true,
\ "show_numbers": v:false,
\ "show_relative_numbers": v:false,
\ "keymaps": {
\ "close": "<Esc>",
\ "goto_location": "<Cr>",
@@ -67,6 +71,8 @@ let g:symbols_outline = {
| show_guides | Wether to show outline guides | boolean | true |
| position | Where to open the split window | 'right' or 'left' | 'right' |
| auto_preview | Show a preview of the code on hover | boolean | true |
| show_numbers | Shows numbers with the outline | boolean | false |
| show_relative_numbers | Shows relative numbers with the outline | boolean | false |
| keymaps | Which keys do what | table (dictionary) | [here](#default-keymaps) |
| lsp_blacklist | Which lsp clients to ignore | table (array) | {} |

View File

@@ -194,6 +194,14 @@ local function setup_buffer()
vim.api.nvim_buf_set_name(M.state.outline_buf, "OUTLINE")
vim.api.nvim_buf_set_option(M.state.outline_buf, "filetype", "Outline")
vim.api.nvim_buf_set_option(M.state.outline_buf, "modifiable", false)
if config.options.show_numbers or config.options.show_relative_numbers then
vim.api.nvim_win_set_option(M.state.outline_win, "nu", true)
end
if config.options.show_relative_numbers then
vim.api.nvim_win_set_option(M.state.outline_win, "rnu", true)
end
end
local function handler(response)

View File

@@ -7,6 +7,8 @@ local defaults = {
show_guides = true,
position = 'right',
auto_preview = true,
show_numbers = false,
show_relative_numbers = false,
keymaps = {
close = "<Esc>",
goto_location = "<Cr>",
@@ -20,6 +22,10 @@ local defaults = {
M.options = {}
function M.has_numbers()
return M.options.show_numbers or M.options.show_relative_numbers
end
function M.get_position_navigation_direction()
if M.options.position == 'left' then
return 'h'

View File

@@ -29,6 +29,10 @@ local function get_offset()
local width = 53
local height = 0
if config.has_numbers() then
width = width + 4;
end
if config.options.position == 'right' then
width = 0 - width
else