Skip to content

Commit

Permalink
docs: Options deprecated and how to migrate notes
Browse files Browse the repository at this point in the history
  • Loading branch information
barreiroleo committed Apr 28, 2024
1 parent 67ced1d commit 0dd9a0f
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 18 deletions.
81 changes: 72 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,81 @@ manager*:
}
```

## Deprecated options notes
## Deprecations

All the options marked as deprecated will continue working until a couple of weeks after nvim's 0.10
release. Please, if you have any concerns, raise an issue and let's talk about it.
The following options are now marked deprecated and will be removed from `master` branch in a future
release after the Nvim 0.10 release. Please, if you have any concerns, raise an issue and let's talk
about it.

- `init_check`: Not needed anymore. It won't take any effect. `Ltex_extra` by default listen the
`LspAttach` event and loads the settings from disk. Just remove it safely.
- `server_start` and `server_opts`: The ability to call the `lspconfig` and start the server for you
will be removed. When I accepted this PR it made sense to me because the servers setups weren't
likely standard. When `lazy.nvim` came to the party, configs start being simplified, and now we have
the `LspAttach` event that simplifies the things much more. Keeping this feature doesn't make much
sense to me anymore and is hard to test because I need to have an A/B setup in my dotfiles.
`LspAttach` event and loads the settings from disk.

How to migrate? Just remove it.

- `server_start` and `server_opts`: When I accepted this PR it made sense to me because the servers
setups weren't likely standard. When `lazy.nvim` came to the party, configs start being simplified,
and now we have the `LspAttach` event and that simplifies the things much more. Keeping this feature
doesn't make much sense to me anymore and is hard to test because I need to have an A/B setup in my
dotfiles.

How to migrate? *Setup the `ltex` server as any other.*
```lua
{
require("lspconfig").ltex.setup({
on_attach = function(client, bufnr)
-- Setuping the ltex_extra in `on_attach` function is not a requirement anymore.
-- require('ltex_extra').setup({})
end,
filetypes = { 'markdown', 'tex', 'other supported language' },
settings = {
ltex = {
-- Your Ltex config. For instance:
checkFrequency = 'save',
language = { "en-US", 'es-AR' },
additionalRules = {
enablePickyRules = true,
motherTongue = 'es-AR',
},
},
},
})
}
```
*And setup the plugin as any other.*
```lua
{
require("ltex_extra").setup({
load_langs = { 'es-AR', 'en-US' }, -- Which languages do you want to load on init.
path = ".ltex", -- Path to your ltex files
})
}
```
- `root_dir`: It was likely unofficial, but if you provide a `root_dir` to the `ltex` client config,
and you pass the `client.config.root_dir` as a path, `ltex_extra` will use it instead of the
relative path.
I think this is a cool feature in some cases but looking back it wasn't good implemented and, to be
honest, all acrobatics are not necessary due to you can run the same `root_dir` function inner your
config function should be enough.

How to migrate: Just run your `find_root` in config function. Example sing Lazy.
```lua
{
"barreiroleo/ltex_extra.nvim",
config = function()
local function find_root()
local file_path = vim.api.nvim_buf_get_name(0)
local root_pattern = require("lspconfig").util.root_pattern
-- Look for existing `.ltex` directory first. If it doesn't exist,
-- look for .git/.hg directories. If everything else fails, get absolute path to the file parent
return root_pattern('.ltex', '.hg', '.git')(file_path) or vim.fn.fnamemodify(file_path, ':p:h')
end
require("ltex_extra").setup({
load_langs = { 'es-AR', 'en-US' },
path = find_root(),
})
end
}
```

## FAQ

Expand Down
12 changes: 7 additions & 5 deletions lua/ltex_extra/opts.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---@deprecated
---@alias server_start boolean
---@deprecated
---@alias server_opts LSPServerOpts|nil

---@class LtexExtraOpts
---@field load_langs string[] Languages to load. See LTeX definitions
---@field log_level LogLevel
---@field path string Path to store dictionaries. Relative to CWD or absolute
---@field server_opts server_opts

---@deprecated
---@alias server_start boolean
---@deprecated
---@alias server_opts LSPServerOpts|nil
---
---@class Legacy_LtexExtraOpts: LtexExtraOpts
---@field init_check boolean Perform a scan inmediatelly after load the dictionaries
---@field server_start server_start Enable the call to ltex. Usefull for migration and test
Expand All @@ -19,6 +20,7 @@
---@field capabilities any
---@field filetypes string[]
---@field settings table {ltex: LtexSettings}
---@field root_dir any?

---@class LtexSettings
---@field checkFrequency string
Expand Down
6 changes: 2 additions & 4 deletions lua/ltex_extra/utils/fs.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local log = require("ltex_extra.utils.log").log
local config_path = require("ltex_extra").__get_opts().path
local server_opts = require("ltex_extra").__get_opts().server_opts
local uv = vim.loop

local M = {}
Expand All @@ -18,10 +19,7 @@ M.path = function()
return config_path .. "/"
end

-- TODO: Get the root_dir from ltex client when do the setup
-- local server_opts = require("ltex_extra").__get_opts().server_opts
-- local root_dir = server_opts and server_opts.root_dir or uv.cwd()
local root_dir = uv.cwd()
local root_dir = server_opts and server_opts.root_dir or uv.cwd()

-- Assume relative path and append to the root dir.
return vim.fs.normalize(root_dir .. "/" .. config_path) .. "/"
Expand Down

0 comments on commit 0dd9a0f

Please sign in to comment.