chore: More remants of rename

This commit is contained in:
hedy
2023-11-16 14:29:02 +08:00
parent 4d871ec64b
commit 22051b6555
4 changed files with 23 additions and 23 deletions

View File

@@ -1,4 +1,4 @@
local so = require 'outline' local outline = require 'outline'
local cfg = require 'outline.config' local cfg = require 'outline.config'
local util = vim.lsp.util local util = vim.lsp.util
@@ -17,10 +17,10 @@ end
-- handler yoinked from the default implementation -- handler yoinked from the default implementation
function M.show_hover() function M.show_hover()
local current_line = vim.api.nvim_win_get_cursor(so.view.winnr)[1] local current_line = vim.api.nvim_win_get_cursor(outline.view.winnr)[1]
local node = so.state.flattened_outline_items[current_line] local node = outline.state.flattened_outline_items[current_line]
local hover_params = get_hover_params(node, so.state.code_win) local hover_params = get_hover_params(node, outline.state.code_win)
vim.lsp.buf_request( vim.lsp.buf_request(
hover_params.bufnr, hover_params.bufnr,

View File

@@ -1,4 +1,4 @@
local so = require 'outline' local outline = require 'outline'
local cfg = require 'outline.config' local cfg = require 'outline.config'
local hover = require 'outline.hover' local hover = require 'outline.hover'
@@ -11,15 +11,15 @@ local state = {
local function is_current_win_outline() local function is_current_win_outline()
local curwin = vim.api.nvim_get_current_win() local curwin = vim.api.nvim_get_current_win()
return curwin == so.view.winnr return curwin == outline.view.winnr
end end
local function has_code_win() local function has_code_win()
local isWinValid = vim.api.nvim_win_is_valid(so.state.code_win) local isWinValid = vim.api.nvim_win_is_valid(outline.state.code_win)
if not isWinValid then if not isWinValid then
return false return false
end end
local bufnr = vim.api.nvim_win_get_buf(so.state.code_win) local bufnr = vim.api.nvim_win_get_buf(outline.state.code_win)
local isBufValid = vim.api.nvim_buf_is_valid(bufnr) local isBufValid = vim.api.nvim_buf_is_valid(bufnr)
return isBufValid return isBufValid
end end
@@ -28,7 +28,7 @@ M.has_code_win = has_code_win
local function get_width_offset() local function get_width_offset()
---@type integer ---@type integer
local outline_winnr = so.view.winnr local outline_winnr = outline.view.winnr
local width = cfg.get_preview_width() + 3 local width = cfg.get_preview_width() + 3
local has_numbers = vim.api.nvim_win_get_option(outline_winnr, "number") local has_numbers = vim.api.nvim_win_get_option(outline_winnr, "number")
has_numbers = has_numbers or vim.api.nvim_win_get_option(outline_winnr, "relativenumber") has_numbers = has_numbers or vim.api.nvim_win_get_option(outline_winnr, "relativenumber")
@@ -51,13 +51,13 @@ local function get_height()
end end
local function get_hovered_node() local function get_hovered_node()
local hovered_line = vim.api.nvim_win_get_cursor(so.view.winnr)[1] local hovered_line = vim.api.nvim_win_get_cursor(outline.view.winnr)[1]
local node = so.state.flattened_outline_items[hovered_line] local node = outline.state.flattened_outline_items[hovered_line]
return node return node
end end
local function update_preview(code_buf) local function update_preview(code_buf)
code_buf = code_buf or vim.api.nvim_win_get_buf(so.state.code_win) code_buf = code_buf or vim.api.nvim_win_get_buf(outline.state.code_win)
local node = get_hovered_node() local node = get_hovered_node()
if not node then if not node then
@@ -75,7 +75,7 @@ local function update_preview(code_buf)
end end
local function setup_preview_buf() local function setup_preview_buf()
local code_buf = vim.api.nvim_win_get_buf(so.state.code_win) local code_buf = vim.api.nvim_win_get_buf(outline.state.code_win)
local ft = vim.api.nvim_buf_get_option(code_buf, 'filetype') local ft = vim.api.nvim_buf_get_option(code_buf, 'filetype')
local function treesitter_attach() local function treesitter_attach()

View File

@@ -1,17 +1,17 @@
local M = {} local M = {}
-- NOTE: There is in fact a markdown LSP that can provide symbols. However on
-- buffer open the LSP may not be attached immediately. Before the LSP is ready
-- if the user opens the outline, our own markdown provider will be used. After
-- refreshing/reopening, the provider will then switch to the LSP (if the user
-- has a markdown LSP).
local providers = { local providers = {
'outline/providers/nvim-lsp', 'outline/providers/nvim-lsp',
'outline/providers/coc', 'outline/providers/coc',
-- NOTE: There is in fact a markdown LSP that can provide symbols. However
-- on buffer open the LSP may not be attached immediately. Before the LSP is
-- ready if the user opens the outline, our own markdown provider will be
-- used. After refreshing/reopening, the provider will then switch to the LSP
-- (if the user has a markdown LSP).
'outline/providers/markdown', 'outline/providers/markdown',
} }
_G._symbols_outline_current_provider = nil _G._outline_current_provider = nil
function M.has_provider() function M.has_provider()
local ret = false local ret = false

View File

@@ -1,4 +1,4 @@
local so = require 'outline' local outline = require 'outline'
local M = {} local M = {}
@@ -14,10 +14,10 @@ local function get_rename_params(node, winnr)
end end
function M.rename() function M.rename()
local current_line = vim.api.nvim_win_get_cursor(so.view.winnr)[1] local current_line = vim.api.nvim_win_get_cursor(outline.view.winnr)[1]
local node = so.state.flattened_outline_items[current_line] local node = outline.state.flattened_outline_items[current_line]
local params = get_rename_params(node, so.state.code_win) local params = get_rename_params(node, outline.state.code_win)
local new_name = vim.fn.input({ prompt = 'New Name: ', default = node.name }) local new_name = vim.fn.input({ prompt = 'New Name: ', default = node.name })
if not new_name or new_name == '' or new_name == node.name then if not new_name or new_name == '' or new_name == node.name then