Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 8 additions & 8 deletions lua/marksman/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ local function notify(message, level)
end

---Validate configuration against schema
---@param user_config table User provided configuration
---@param user_config table? User provided configuration
---@param schema table Validation schema
---@return table validated_config Validated configuration
local function validate_config(user_config, schema)
Expand Down Expand Up @@ -103,7 +103,7 @@ local function validate_config(user_config, schema)
end

---Lazy module loading with error handling
---@return table storage Storage module
---@return table? storage Storage module
local function get_storage()
if not storage then
local ok, module = pcall(require, "marksman.storage")
Expand All @@ -118,7 +118,7 @@ local function get_storage()
end

---Lazy module loading with error handling
---@return table ui UI module
---@return table? ui UI module
local function get_ui()
if not ui then
local ok, module = pcall(require, "marksman.ui")
Expand All @@ -133,7 +133,7 @@ local function get_ui()
end

---Lazy module loading with error handling
---@return table utils Utils module
---@return table? utils Utils module
local function get_utils()
if not utils then
local ok, module = pcall(require, "marksman.utils")
Expand Down Expand Up @@ -162,8 +162,8 @@ local function debounced_save()
end

---Add a mark at the current cursor position
---@param name string|nil Optional mark name (auto-generated if nil)
---@param description string|nil Optional mark description
---@param name string? Optional mark name (auto-generated if nil)
---@param description string? Optional mark description
---@return table result Result with success, message, and mark_name
function M.add_mark(name, description)
local storage_module = get_storage()
Expand Down Expand Up @@ -365,7 +365,7 @@ function M.move_mark(name, direction)
end

---Show marks in floating window
---@param search_query string|nil Optional search query to filter marks
---@param search_query string? Optional search query to filter marks
function M.show_marks(search_query)
local storage_module = get_storage()
local ui_module = get_ui()
Expand Down Expand Up @@ -518,7 +518,7 @@ function M.cleanup()
end

---Setup function to initialize the plugin
---@param opts table|nil User configuration options
---@param opts table? User configuration options
function M.setup(opts)
-- Validate and merge configuration
local validated_opts = validate_config(opts, config_schema)
Expand Down
27 changes: 16 additions & 11 deletions lua/marksman/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ end
---Create header content for marks window
---@param total_marks number Total number of marks
---@param shown_marks number Number of marks shown
---@param search_query string|nil Search query if any
---@param search_query string? Search query if any
---@return table lines Array of header lines
---@return table highlights Array of highlight definitions
local function create_header_content(total_marks, shown_marks, search_query)
Expand Down Expand Up @@ -137,6 +137,7 @@ end
---@param name string Mark name
---@param mark table Mark data
---@param index number Mark index
---@param line_idx number Line index for highlights
---@return string line Formatted line
---@return table highlights Array of highlight definitions for this line
local function create_minimal_mark_line(name, mark, index, line_idx)
Expand Down Expand Up @@ -239,7 +240,7 @@ end

---Create complete marks window content
---@param marks table All marks data
---@param search_query string|nil Optional search query
---@param search_query string? Optional search query
---@return table lines Array of content lines
---@return table highlights Array of highlight definitions
---@return table mark_info Mapping of line numbers to mark info
Expand Down Expand Up @@ -331,7 +332,7 @@ end

---Find mark information for current cursor position
---@param mark_info table Mapping of line numbers to mark info
---@return table|nil mark_info Mark info for cursor position
---@return table? mark_info Mark info for cursor position
local function get_mark_under_cursor(mark_info)
local line = vim.fn.line(".")
local closest_mark = nil
Expand All @@ -353,7 +354,7 @@ end
---@param marks table Marks data
---@param project_name string Project name
---@param mark_info table Mark info mapping
---@param search_query string|nil Search query
---@param search_query string? Search query
local function setup_window_keymaps(buf, marks, project_name, mark_info, search_query)
local function refresh_window(new_search)
local storage = require("marksman.storage")
Expand Down Expand Up @@ -511,7 +512,7 @@ end
-- Public API

---Setup the UI module
---@param user_config table Plugin configuration
---@param user_config table? Plugin configuration
function M.setup(user_config)
config = user_config or {}
setup_highlights()
Expand All @@ -520,7 +521,7 @@ end
---Show marks in floating window
---@param marks table Marks data
---@param project_name string Project name
---@param search_query string|nil Optional search query
---@param search_query string? Optional search query
function M.show_marks_window(marks, project_name, search_query)
-- Close existing window
close_window()
Expand All @@ -540,9 +541,11 @@ function M.show_marks_window(marks, project_name, search_query)

local ok, err = pcall(function()
vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
vim.bo[buf].modifiable = false
vim.bo[buf].buftype = "nofile"
vim.bo[buf].filetype = "marksman"
-- Use vim.bo syntax instead of deprecated option setting
local bufnr = buf
vim.bo[bufnr].modifiable = false
vim.bo[bufnr].buftype = "nofile"
vim.bo[bufnr].filetype = "marksman"
end)

if not ok then
Expand Down Expand Up @@ -587,8 +590,10 @@ function M.show_marks_window(marks, project_name, search_query)
current_window = win
current_buffer = buf

-- Set window highlight
pcall(vim.api.nvim_win_set_option, win, "winhighlight", "Normal:Normal,FloatBorder:ProjectMarksBorder")
-- Set window highlight using vim.wo syntax
pcall(function()
vim.wo[win].winhighlight = "Normal:Normal,FloatBorder:ProjectMarksBorder"
end)

-- Setup keymaps
setup_window_keymaps(buf, marks, project_name, mark_info, search_query)
Expand Down
10 changes: 1 addition & 9 deletions tests/marksman_spec.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
-- luacheck: globals describe it before_each after_each assert
local assert = require("luassert")

-- Helper to create test files
local function create_test_file(name, content)
local test_dir = vim.env.MARKSMAN_TEST_DIR or vim.fn.tempname()
local filepath = test_dir .. "/" .. name
vim.fn.mkdir(vim.fn.fnamemodify(filepath, ":h"), "p")
vim.fn.writefile(content or { "test content" }, filepath)
return filepath
end

-- Helper to setup buffer with file
local function setup_buffer_with_file(filepath, content)
vim.fn.writefile(content or { "test content" }, filepath)
Expand Down