Skip to content

Commit 15869e0

Browse files
chore(refactor): use uppercase imports for class-like modules only
## Details Changes the following "imports" to lowercase: - `render-markdown.lib.compat` - `render-markdown.lib.converter` - `render-markdown.lib.env` - `render-markdown.lib.icons` - `render-markdown.lib.iter` - `render-markdown.lib.list` - `render-markdown.lib.str`
1 parent a706be7 commit 15869e0

34 files changed

+200
-194
lines changed

doc/render-markdown.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For NVIM v0.11.2 Last change: 2025 June 12
1+
*render-markdown.txt* For NVIM v0.11.2 Last change: 2025 June 13
22

33
==============================================================================
44
Table of Contents *render-markdown-table-of-contents*

lua/render-markdown/core/log.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local Env = require('render-markdown.lib.env')
1+
local env = require('render-markdown.lib.env')
22

33
---@class render.md.log.Entry
44
---@field date string
@@ -38,7 +38,7 @@ end
3838
---called from plugin directory
3939
function M.init()
4040
-- clear the file contents if it is too big
41-
if Env.file_size_mb(M.file) > 5 then
41+
if env.file_size_mb(M.file) > 5 then
4242
assert(io.open(M.file, 'w')):close()
4343
end
4444
-- write out any logs before closing
@@ -54,10 +54,10 @@ end
5454
function M.runtime(name, callback)
5555
if M.config.runtime then
5656
return function()
57-
local Compat = require('render-markdown.lib.compat')
58-
local start_time = Compat.uv.hrtime()
57+
local compat = require('render-markdown.lib.compat')
58+
local start_time = compat.uv.hrtime()
5959
callback()
60-
local end_time = Compat.uv.hrtime()
60+
local end_time = compat.uv.hrtime()
6161
local elapsed = (end_time - start_time) / 1e+6
6262
assert(elapsed < 1000, 'invalid elapsed time')
6363
-- selene: allow(deprecated)
@@ -110,7 +110,7 @@ end
110110
---@param buf integer
111111
---@return string
112112
function M.file_name(buf)
113-
if not Env.buf.valid(buf) then
113+
if not env.buf.valid(buf) then
114114
return 'INVALID'
115115
end
116116
local file = vim.api.nvim_buf_get_name(buf)

lua/render-markdown/core/manager.lua

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local Env = require('render-markdown.lib.env')
1+
local env = require('render-markdown.lib.env')
22
local log = require('render-markdown.core.log')
33
local state = require('render-markdown.state')
44
local ui = require('render-markdown.core.ui')
@@ -30,8 +30,8 @@ end
3030
---called from plugin directory
3131
function M.init()
3232
-- lazy loading: ignores current buffer as FileType event already executed
33-
if #Env.lazy('ft') == 0 and #Env.lazy('cmd') == 0 then
34-
M.attach(Env.buf.current())
33+
if #env.lazy('ft') == 0 and #env.lazy('cmd') == 0 then
34+
M.attach(env.buf.current())
3535
end
3636
-- attempt to attach to all buffers, cannot use pattern to support plugin directory
3737
vim.api.nvim_create_autocmd('FileType', {
@@ -45,7 +45,7 @@ function M.init()
4545
group = M.group,
4646
callback = function(args)
4747
for _, win in ipairs(vim.v.event.windows) do
48-
local buf = Env.win.buf(win)
48+
local buf = env.win.buf(win)
4949
if M.attached(buf) and state.get(buf).enabled then
5050
ui.update(buf, win, args.event, true)
5151
end
@@ -63,8 +63,8 @@ end
6363
---@param enabled? boolean
6464
function M.set_all(enabled)
6565
-- lazy loading: all previously opened buffers have been ignored
66-
if #Env.lazy('cmd') > 0 then
67-
M.attach(Env.buf.current())
66+
if #env.lazy('cmd') > 0 then
67+
M.attach(env.buf.current())
6868
end
6969
if enabled ~= nil then
7070
state.enabled = enabled
@@ -79,15 +79,15 @@ end
7979
---@param buf? integer
8080
---@param enabled? boolean
8181
function M.set_buf(buf, enabled)
82-
buf = buf or Env.buf.current()
82+
buf = buf or env.buf.current()
8383
if M.attached(buf) then
8484
local config = state.get(buf)
8585
if enabled ~= nil then
8686
config.enabled = enabled
8787
else
8888
config.enabled = not config.enabled
8989
end
90-
ui.update(buf, Env.buf.win(buf), 'UserCommand', true)
90+
ui.update(buf, env.buf.win(buf), 'UserCommand', true)
9191
end
9292
end
9393

@@ -141,7 +141,7 @@ function M.attach(buf)
141141
if not state.get(buf).enabled then
142142
return
143143
end
144-
local win, wins = Env.win.current(), Env.buf.windows(buf)
144+
local win, wins = env.win.current(), env.buf.windows(buf)
145145
win = vim.tbl_contains(wins, win) and win or wins[1]
146146
if not win then
147147
return
@@ -152,7 +152,7 @@ function M.attach(buf)
152152
})
153153

154154
if config.enabled then
155-
ui.update(buf, Env.buf.win(buf), 'Initial', true)
155+
ui.update(buf, env.buf.win(buf), 'Initial', true)
156156
end
157157
end
158158

@@ -172,15 +172,15 @@ function M.should_attach(buf)
172172
return false
173173
end
174174

175-
local file_type = Env.buf.get(buf, 'filetype')
175+
local file_type = env.buf.get(buf, 'filetype')
176176
local file_types = M.config.file_types
177177
if not vim.tbl_contains(file_types, file_type) then
178178
local reason = ('%s /∈ %s'):format(file_type, vim.inspect(file_types))
179179
log.attach(buf, 'skip', 'file type', reason)
180180
return false
181181
end
182182

183-
local file_size = Env.file_size_mb(buf)
183+
local file_size = env.file_size_mb(buf)
184184
local max_file_size = state.get(buf).max_file_size
185185
if file_size > max_file_size then
186186
local reason = ('%f > %f'):format(file_size, max_file_size)

lua/render-markdown/core/ts.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local Compat = require('render-markdown.lib.compat')
1+
local compat = require('render-markdown.lib.compat')
22

33
---@class render.md.ts.Config
44
---@field file_types string[]
@@ -57,7 +57,7 @@ function M.inject(language)
5757
return
5858
end
5959
local query = ''
60-
if Compat.has_11 then
60+
if compat.has_11 then
6161
query = query .. ';; extends' .. '\n'
6262
else
6363
local files = vim.treesitter.query.get_files(language, 'injections')
@@ -80,15 +80,15 @@ function M.disable(language)
8080
if not pattern or not pattern.disable then
8181
return
8282
end
83-
if not Compat.has_11 then
83+
if not compat.has_11 then
8484
return
8585
end
8686
local query = vim.treesitter.query.get(language, 'highlights')
8787
if not query then
8888
return
8989
end
9090
if not query.query.disable_pattern then
91-
Compat.release('TSQuery missing disable_pattern API')
91+
compat.release('TSQuery missing disable_pattern API')
9292
return
9393
end
9494
local query_directives = query.info.patterns

lua/render-markdown/core/ui.lua

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
local Compat = require('render-markdown.lib.compat')
21
local Context = require('render-markdown.request.context')
32
local Decorator = require('render-markdown.lib.decorator')
4-
local Env = require('render-markdown.lib.env')
53
local Extmark = require('render-markdown.lib.extmark')
6-
local Iter = require('render-markdown.lib.iter')
74
local Range = require('render-markdown.lib.range')
5+
local compat = require('render-markdown.lib.compat')
6+
local env = require('render-markdown.lib.env')
87
local handlers = require('render-markdown.core.handlers')
8+
local iter = require('render-markdown.lib.iter')
99
local log = require('render-markdown.core.log')
1010
local state = require('render-markdown.state')
1111

@@ -79,10 +79,10 @@ function Updater.new(buf, win, force)
7979
end
8080

8181
function Updater:start()
82-
if not Env.valid(self.buf, self.win) then
82+
if not env.valid(self.buf, self.win) then
8383
return
8484
end
85-
if Env.buf.empty(self.buf) then
85+
if env.buf.empty(self.buf) then
8686
return
8787
end
8888
self.decorator:schedule(
@@ -105,19 +105,19 @@ end
105105

106106
---@private
107107
function Updater:run()
108-
if not Env.valid(self.buf, self.win) then
108+
if not env.valid(self.buf, self.win) then
109109
return
110110
end
111-
self.mode = Env.mode.get() -- mode is only available after this point
111+
self.mode = env.mode.get() -- mode is only available after this point
112112
local render = self.config.enabled
113113
and self.config.resolved:render(self.mode)
114-
and not Env.win.get(self.win, 'diff')
115-
and Env.win.view(self.win).leftcol == 0
114+
and not env.win.get(self.win, 'diff')
115+
and env.win.view(self.win).leftcol == 0
116116
log.buf('info', 'Render', self.buf, render)
117117
local next_state = render and 'rendered' or 'default'
118-
for _, win in ipairs(Env.buf.windows(self.buf)) do
118+
for _, win in ipairs(env.buf.windows(self.buf)) do
119119
for name, value in pairs(self.config.win_options) do
120-
Env.win.set(win, name, value[next_state])
120+
env.win.set(win, name, value[next_state])
121121
end
122122
end
123123
if not render then
@@ -145,7 +145,7 @@ function Updater:render()
145145
local extmarks = self:get_extmarks()
146146
self.decorator:set(extmarks)
147147
if initial then
148-
Compat.fix_lsp_window(self.buf, self.win, extmarks)
148+
compat.fix_lsp_window(self.buf, self.win, extmarks)
149149
M.config.on.initial({ buf = self.buf, win = self.win })
150150
end
151151
end
@@ -173,7 +173,7 @@ function Updater:get_extmarks()
173173
-- make sure injections are processed
174174
context.view:parse(parser)
175175
local marks = handlers.run(context, parser)
176-
return Iter.list.map(marks, Extmark.new)
176+
return iter.list.map(marks, Extmark.new)
177177
end
178178

179179
---@private
@@ -182,15 +182,15 @@ function Updater:hidden()
182182
-- anti-conceal is not enabled -> hide nothing
183183
-- in disabled mode -> hide nothing
184184
local config = self.config.anti_conceal
185-
if not config.enabled or Env.mode.is(self.mode, config.disabled_modes) then
185+
if not config.enabled or env.mode.is(self.mode, config.disabled_modes) then
186186
return nil
187187
end
188188
-- row is not known -> buffer is not active -> hide nothing
189-
local row = Env.row.get(self.buf, self.win)
189+
local row = env.row.get(self.buf, self.win)
190190
if not row then
191191
return nil
192192
end
193-
if Env.mode.is(self.mode, { 'v', 'V', '\22' }) then
193+
if env.mode.is(self.mode, { 'v', 'V', '\22' }) then
194194
local start = vim.fn.getpos('v')[2] - 1
195195
return Range.new(math.min(row, start), math.max(row, start))
196196
else

lua/render-markdown/debug/marks.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@ end
148148
local M = {}
149149

150150
function M.show()
151-
local Env = require('render-markdown.lib.env')
152151
local Range = require('render-markdown.lib.range')
152+
local env = require('render-markdown.lib.env')
153153
local ui = require('render-markdown.core.ui')
154154

155-
local buf = Env.buf.current()
156-
local win = Env.win.current()
157-
local row = assert(Env.row.get(buf, win), 'row must be known')
155+
local buf = env.buf.current()
156+
local win = env.win.current()
157+
local row = assert(env.row.get(buf, win), 'row must be known')
158158
local range = Range.new(row, row)
159159

160160
local marks = {} ---@type render.md.debug.Mark[]

lua/render-markdown/debug/validator.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local Iter = require('render-markdown.lib.iter')
1+
local iter = require('render-markdown.lib.iter')
22

33
---@enum render.md.debug.spec.Kind
44
local Kind = {
@@ -75,7 +75,7 @@ end
7575
---@param values any[]
7676
---@param ts? type|type[]
7777
function Spec:one_of(keys, values, ts)
78-
local options = Iter.list.map(values, vim.inspect)
78+
local options = iter.list.map(values, vim.inspect)
7979
local types, message = self:handle_types(options, ts)
8080
self:add(keys, Kind.data, message, function(value)
8181
local valid_value = vim.tbl_contains(values, value)
@@ -141,7 +141,7 @@ end
141141
---@param values any[]
142142
---@param ts? type|type[]
143143
function Spec:one_or_list_of(keys, values, ts)
144-
local body = table.concat(Iter.list.map(values, vim.inspect), '|')
144+
local body = table.concat(iter.list.map(values, vim.inspect), '|')
145145
local options = '(' .. body .. ')'
146146
local types, message = self:handle_types({ options, options .. '[]' }, ts)
147147
self:add(keys, Kind.type, message, function(value)

lua/render-markdown/handler/latex.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
local Context = require('render-markdown.request.context')
22
local Indent = require('render-markdown.lib.indent')
3-
local Iter = require('render-markdown.lib.iter')
43
local Marks = require('render-markdown.lib.marks')
54
local Node = require('render-markdown.lib.node')
6-
local Str = require('render-markdown.lib.str')
5+
local iter = require('render-markdown.lib.iter')
76
local log = require('render-markdown.core.log')
7+
local str = require('render-markdown.lib.str')
88

99
---@class render.md.handler.buf.Latex
1010
---@field private context render.md.request.Context
@@ -40,7 +40,7 @@ function Handler:run(root)
4040
log.node('latex', node)
4141

4242
local indent = self:indent(node.start_row, node.start_col)
43-
local lines = Iter.list.map(self:expressions(node), function(expression)
43+
local lines = iter.list.map(self:expressions(node), function(expression)
4444
local line = vim.list_extend({}, indent)
4545
line[#line + 1] = { expression, self.config.highlight }
4646
return line
@@ -65,11 +65,11 @@ function Handler:expressions(node)
6565
for _ = 1, self.config.top_pad do
6666
result[#result + 1] = ''
6767
end
68-
local lines = Str.split(self:convert(node.text), '\n', true)
69-
local width = vim.fn.max(Iter.list.map(lines, Str.width))
68+
local lines = str.split(self:convert(node.text), '\n', true)
69+
local width = vim.fn.max(iter.list.map(lines, str.width))
7070
for _, line in ipairs(lines) do
71-
local prefix = Str.pad(node.start_col)
72-
local suffix = Str.pad(width - Str.width(line))
71+
local prefix = str.pad(node.start_col)
72+
local suffix = str.pad(width - str.width(line))
7373
result[#result + 1] = prefix .. line .. suffix
7474
end
7575
for _ = 1, self.config.bottom_pad do

lua/render-markdown/health.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
local Icons = require('render-markdown.lib.icons')
1+
local icons = require('render-markdown.lib.icons')
22
local state = require('render-markdown.state')
33

44
---@class render.md.Health
55
local M = {}
66

77
---@private
8-
M.version = '8.5.3'
8+
M.version = '8.5.4'
99

1010
function M.check()
1111
M.start('version')
@@ -39,7 +39,7 @@ function M.check()
3939
end
4040

4141
M.start('icons')
42-
local provider = Icons.name()
42+
local provider = icons.name()
4343
if provider then
4444
vim.health.ok('using: ' .. provider)
4545
else

lua/render-markdown/init.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ function M.resolve_config(user)
129129
config.pipe_table.border_virtual = true
130130
end
131131
-- override settings incompatible with neovim version with compatible alternatives
132-
local Compat = require('render-markdown.lib.compat')
133-
if config.code.position == 'left' and not Compat.has_10 then
132+
local compat = require('render-markdown.lib.compat')
133+
if config.code.position == 'left' and not compat.has_10 then
134134
config.code.position = 'right'
135135
end
136-
if config.code.border == 'hide' and not Compat.has_11 then
136+
if config.code.border == 'hide' and not compat.has_11 then
137137
config.code.border = 'thin'
138138
end
139139
-- use lazy.nvim file type configuration if available and no user value is specified

0 commit comments

Comments
 (0)