diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml deleted file mode 100644 index 7ef88de..0000000 --- a/.forgejo/workflows/release.yml +++ /dev/null @@ -1,15 +0,0 @@ -jobs: - release: - name: Release - runs-on: ubuntu-latest - permissions: - contents: write # to be able to publish a GitHub release - issues: write # to be able to comment on released issues - pull-requests: write # to be able to comment on released pull requests - id-token: write # to enable use of OIDC for npm provenance - steps: - - name: Create Release - uses: https://git.kjan.de/actions/semantic-release@main - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} diff --git a/lua/jquote/init.lua b/lua/jquote/init.lua index f29c246..6f8ea6e 100644 --- a/lua/jquote/init.lua +++ b/lua/jquote/init.lua @@ -1,6 +1,7 @@ --- JQuote: A Neovim plugin for cycling through quote characters --- @module jquote ---- @author Jan +--- @author Author Name +--- @version 1.0.0 --- @license MIT local M = {} @@ -23,6 +24,7 @@ M.options = vim.deepcopy(DEFAULT_OPTIONS) --- Plugin metadata --- @type table +M._version = "1.0.0" M._name = "jquote" --- Validates if a character is one of the configured quote characters @@ -33,7 +35,7 @@ local function is_defined_quote_char(char) if type(char) ~= "string" or #char ~= 1 then return false end - + for _, quote_char in ipairs(M.options.quote_chars) do if char == quote_char then return true @@ -56,14 +58,14 @@ local function find_quoted_string_at_cursor(line, cursor_col) --- @type table[] Array of quote position records local quote_positions = {} - + -- Scan line for quote characters and record their positions for i = 1, #line do local char = line:sub(i, i) if is_defined_quote_char(char) then - table.insert(quote_positions, { - char = char, - index = i - 1 -- Convert to 0-based indexing + table.insert(quote_positions, { + char = char, + index = i - 1 -- Convert to 0-based indexing }) end end @@ -73,13 +75,13 @@ local function find_quoted_string_at_cursor(line, cursor_col) local start_quote = quote_positions[i] for j = i + 1, #quote_positions do local end_quote = quote_positions[j] - + -- Match opening and closing quotes of same type if start_quote.char == end_quote.char then - if (cursor_col >= start_quote.index and cursor_col <= end_quote.index) or (cursor_col <= start_quote.index and cursor_col <= end_quote.index) then + if cursor_col >= start_quote.index and cursor_col <= end_quote.index then return start_quote.index, end_quote.index, start_quote.char end - + -- Skip to next pair to avoid nested matches i = j goto continue_outer_loop @@ -99,9 +101,9 @@ local function get_next_quote_char(current_char) if type(current_char) ~= "string" then return M.options.quote_chars[1] end - + local quote_count = #M.options.quote_chars - + for i = 1, quote_count do if M.options.quote_chars[i] == current_char then -- Cycle to next character (wrapping around to first if at end) @@ -109,7 +111,7 @@ local function get_next_quote_char(current_char) return M.options.quote_chars[next_index] end end - + -- Fallback to first quote character if current not found return M.options.quote_chars[1] end @@ -123,13 +125,13 @@ function M.toggle_quotes() vim.notify("JQuote: Failed to get current line", vim.log.levels.ERROR) return false end - + local success_cursor, cursor_pos = pcall(vim.api.nvim_win_get_cursor, 0) if not success_cursor or type(cursor_pos) ~= "table" or #cursor_pos < 2 then vim.notify("JQuote: Failed to get cursor position", vim.log.levels.ERROR) return false end - + local cursor_row, cursor_col = cursor_pos[1], cursor_pos[2] local start_idx, end_idx, current_char = find_quoted_string_at_cursor(current_line, cursor_col) @@ -158,7 +160,7 @@ function M.toggle_quotes() vim.notify("JQuote: Failed to update line", vim.log.levels.ERROR) return false end - + -- Restore cursor position pcall(vim.api.nvim_win_set_cursor, 0, { cursor_row, cursor_col }) return true @@ -173,27 +175,27 @@ local function validate_options(options) if type(options) ~= "table" then return false, "Options must be a table" end - + if options.hotkey and type(options.hotkey) ~= "string" then return false, "hotkey must be a string" end - + if options.quote_chars then if type(options.quote_chars) ~= "table" then return false, "quote_chars must be a table" end - + if #options.quote_chars == 0 then return false, "quote_chars cannot be empty" end - + for i, char in ipairs(options.quote_chars) do if type(char) ~= "string" or #char ~= 1 then return false, string.format("quote_chars[%d] must be a single character string", i) end end end - + return true, nil end @@ -202,23 +204,23 @@ end --- @return boolean success Whether setup completed successfully function M.setup(user_options) user_options = user_options or {} - + -- Validate user options local is_valid, error_msg = validate_options(user_options) if not is_valid then vim.notify(string.format("JQuote setup error: %s", error_msg), vim.log.levels.ERROR) return false end - + -- Merge with defaults using safe deep extend local success, merged_options = pcall(vim.tbl_deep_extend, "force", vim.deepcopy(DEFAULT_OPTIONS), user_options) if not success then vim.notify("JQuote: Failed to merge configuration options", vim.log.levels.ERROR) return false end - + M.options = merged_options - + -- Defensive check for quote_chars integrity if not M.options.quote_chars or #M.options.quote_chars == 0 then vim.notify("JQuote: quote_chars corrupted, restoring defaults", vim.log.levels.WARN) @@ -237,7 +239,7 @@ function M.setup(user_options) vim.notify(string.format("JQuote: Failed to set keymap for '%s'", M.options.hotkey), vim.log.levels.ERROR) return false end - + vim.notify(string.format("JQuote: Initialized with hotkey '%s'", M.options.hotkey), vim.log.levels.INFO) return true end @@ -246,12 +248,13 @@ end --- @return table health_info Plugin health information function M.health() local health_info = { + version = M._version, options = M.options, quote_chars_count = M.options.quote_chars and #M.options.quote_chars or 0, hotkey_configured = M.options.hotkey ~= nil, } - + return health_info end -return M +return M \ No newline at end of file diff --git a/release.config.cjs b/release.config.cjs deleted file mode 100644 index ac34c97..0000000 --- a/release.config.cjs +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - - branches: ['main'], - plugins: [ - '@semantic-release/commit-analyzer', - '@semantic-release/release-notes-generator', - '@semantic-release/changelog', - ["@saithodev/semantic-release-gitea", { - "giteaUrl": "https://git.kjan.de" - }], - ], -};