Skip to content

Commit

Permalink
refactor: some more code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cbochs committed Apr 28, 2024
1 parent 0e0630a commit d97dbb6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
3 changes: 1 addition & 2 deletions lua/grapple/help_content.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ function HelpContent:perform() end

---@return grapple.window.entity[] | nil, string? error
function HelpContent:entities()
local App = require("grapple.app")
local app = App.get()
local app = require("grapple").app()

---@type grapple.vim.keymap[]
local keymaps = vim.api.nvim_buf_get_keymap(self.buf_id, "n")
Expand Down
16 changes: 4 additions & 12 deletions lua/grapple/tag.lua
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@
local Path = require("grapple.path")

---@class grapple.tag
---@field path string absolute path
---@field name string | nil (optional) tag name
---@field cursor integer[] | nil (optional) (1, 0)-indexed cursor position
---@field frozen boolean
local Tag = {}
Tag.__index = Tag

---@param path string
---@param name? string
---@param cursor? integer[]
---@param frozen? boolean
function Tag:new(path, name, cursor, frozen)
function Tag:new(path, name, cursor)
return setmetatable({
path = path,
name = name,
cursor = cursor,
frozen = frozen,
}, self)
end

function Tag:update()
if not self.frozen then
self.cursor = vim.api.nvim_win_get_cursor(0)
end
self.cursor = vim.api.nvim_win_get_cursor(0)
end

---@param command? fun(path: string)
function Tag:select(command)
local App = require("grapple.app")
local app = App.get()
local app = require("grapple").app()

command = command or app.settings.command
command(self.path)
Expand All @@ -46,7 +38,7 @@ function Tag:select(command)
}

-- If the cursor has already been set, don't set again
if self.frozen or (current_cursor[1] == 1 and current_cursor[2] == 0) then
if current_cursor[1] == 1 and current_cursor[2] == 0 then
pcall(vim.api.nvim_win_set_cursor, 0, cursor)
end
end
Expand Down

0 comments on commit d97dbb6

Please sign in to comment.