Skip to content

Commit

Permalink
fix(code_actions): absolute path support
Browse files Browse the repository at this point in the history
When a CSpell config is loaded from a custom location, the paths for the
dictionary files need to be resolved relative to the config file.

Resolves #53
  • Loading branch information
davidmh committed Apr 28, 2024
1 parent 8c20fb6 commit 1127649
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lua/cspell/code_actions/make_add_to_dictionary_action.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local Path = require("plenary.path")
local h = require("cspell.helpers")

---@class AddToDictionaryAction
Expand Down Expand Up @@ -27,7 +28,7 @@ return function(opts)
if opts.dictionary == nil then
return
end
local dictionary_path = vim.fn.expand(opts.dictionary.path)
local dictionary_path = Path:new(opts.cspell.path):parent():joinpath(opts.dictionary.path):absolute()
local dictionary_ok, dictionary_body = pcall(vim.fn.readfile, dictionary_path)
if not dictionary_ok then
vim.notify("Can't read " .. dictionary_path, vim.log.levels.ERROR, { title = "cspell.nvim" })
Expand Down

0 comments on commit 1127649

Please sign in to comment.