Skip to content

Commit

Permalink
fix: _use_plenary private option
Browse files Browse the repository at this point in the history
  • Loading branch information
barreiroleo committed May 1, 2024
1 parent b39c11a commit 57192d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
8 changes: 4 additions & 4 deletions lua/ltex_extra/init.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local LoggerBuilder = require("ltex_extra.utils.log")
local legacy_opts = require("ltex_extra.opts").legacy_def_opts
local def_opts = require("ltex_extra.opts").legacy_def_opts

---@alias LtexClientSettings {ltex: {dictionary: content, hiddenFalsePositives: content, disabledRules: content }}
---@alias content {[string]: string[]}
Expand Down Expand Up @@ -131,7 +131,7 @@ function LtexExtra:RegisterClientMethods()
vim.lsp.commands["_ltex.disableRules"] = require("ltex_extra.commands-lsp").disableRules
end

---@param opts Legacy_LtexExtraOpts
---@param opts LtexExtraOpts
function LtexExtra:CheckLegacyOpts(opts)
local deprecated_in_use = {}
if opts.server_start then
Expand All @@ -158,10 +158,10 @@ function LtexExtra:CallLtexServer(opts)
end

function ltex_extra_api.setup(opts)
opts = vim.tbl_deep_extend("force", legacy_opts, opts or {})
opts = vim.tbl_deep_extend("force", def_opts, opts or {})
opts.path = vim.fs.normalize(opts.path)
-- Initialize the logger
LoggerBuilder:new({ logLevel = opts.log_level, usePlenary = true })
LoggerBuilder:new({ logLevel = opts.log_level, _use_plenary = opts._use_plenary })
LtexExtra:new(opts)
LtexExtra:RegisterAutocommands()
LtexExtra:RegisterClientMethods()
Expand Down
13 changes: 5 additions & 8 deletions lua/ltex_extra/opts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
---@alias server_opts LSPServerOpts|nil

---@class LtexExtraOpts
---@field init_check boolean Perform a scan inmediatelly after load the dictionaries
---@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

---@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
---@field server_opts LSPServerOpts|nil

---@field server_opts server_opts

---@class LSPServerOpts
---@field on_attach function(client: any, bufnr: integer)
Expand All @@ -27,7 +23,7 @@
---@field language string
---@field additionalRules table {enablePickyRules: boolean, motherTongue: string}

---@type Legacy_LtexExtraOpts
---@type LtexExtraOpts
local legacy_opts = {
---@deprecated
init_check = true,
Expand All @@ -38,9 +34,10 @@ local legacy_opts = {
server_start = false,
---@deprecated
server_opts = nil,
_use_plenary = false
}

---@type Legacy_LtexExtraOpts
---@type LtexExtraOpts
local tests_opts = {
init_check = true,
load_langs = { "es-AR", "en-US" },
Expand Down
9 changes: 4 additions & 5 deletions lua/ltex_extra/utils/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
---@field fatal fun(...: string)

---@class LoggerOpts
---@field usePlenary boolean
---@field logLevel LogLevel
---@field _use_plenary boolean

---@class LoggerBuilder
---@field log Logger
---@field usePlenary boolean
---@field _use_plenary boolean
---@field loglevel LogLevel

---@enum (key) LogLevel
Expand All @@ -37,11 +37,10 @@ function LoggerBuilder:new(opts)
---@type Logger
self.log = nil
---@type boolean
self.usePlenary = opts.usePlenary or false
---@type string
self._use_plenary = opts._use_plenary
self.logLevel = opts.logLevel or "trace"

if self.usePlenary then
if self._use_plenary then
self.log = self:GetPlenaryLogger(self.logLevel)
else
self.log = self:GetVimLogger(self.logLevel)
Expand Down

0 comments on commit 57192d7

Please sign in to comment.