diff --git a/lua/marksman/init.lua b/lua/marksman/init.lua index 3b19de9..1ebb8f9 100644 --- a/lua/marksman/init.lua +++ b/lua/marksman/init.lua @@ -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) @@ -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") @@ -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") @@ -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") @@ -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() @@ -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() @@ -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) diff --git a/lua/marksman/ui.lua b/lua/marksman/ui.lua index f96c177..a83cbeb 100644 --- a/lua/marksman/ui.lua +++ b/lua/marksman/ui.lua @@ -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) @@ -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) @@ -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 @@ -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 @@ -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") @@ -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() @@ -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() @@ -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 @@ -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) diff --git a/tests/marksman_spec.lua b/tests/marksman_spec.lua index 506b231..7fde9a2 100644 --- a/tests/marksman_spec.lua +++ b/tests/marksman_spec.lua @@ -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)