nvim: add comments to undocumented functions
This commit is contained in:
parent
b776aa4260
commit
62dacd2c04
3 changed files with 19 additions and 1 deletions
|
@ -41,7 +41,7 @@ M.toggle = function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Crate a lualine component that shows an icon when autoformatting is enabled.
|
---Create a lualine component that shows an icon when autoformatting is enabled.
|
||||||
---@return table component
|
---@return table component
|
||||||
M.lualine = function()
|
M.lualine = function()
|
||||||
local icon = require("fschauen.util.icons").ui.Format
|
local icon = require("fschauen.util.icons").ui.Format
|
||||||
|
|
|
@ -3,6 +3,10 @@ local M = {}
|
||||||
local util = require("fschauen.util")
|
local util = require("fschauen.util")
|
||||||
local exists = util.exists
|
local exists = util.exists
|
||||||
|
|
||||||
|
---Find lua module source.
|
||||||
|
---@param modname string Module name.
|
||||||
|
---@return table results List of source files in the runtime path that implement
|
||||||
|
--- `modname`.
|
||||||
local find_module_sources = function(modname)
|
local find_module_sources = function(modname)
|
||||||
modname = modname:gsub("^%.+", ""):gsub("/", ".")
|
modname = modname:gsub("^%.+", ""):gsub("/", ".")
|
||||||
local base = "lua/" .. modname:gsub("%.", "/")
|
local base = "lua/" .. modname:gsub("%.", "/")
|
||||||
|
@ -18,6 +22,10 @@ local find_module_sources = function(modname)
|
||||||
return results
|
return results
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Execute lua script in lines.
|
||||||
|
---@param first integer|nil First line to execute. If nil, execute current line.
|
||||||
|
---@param last integer|nil Last line to execute. If nil, execute only the first
|
||||||
|
--- line.
|
||||||
M.execute_lines = function(first, last)
|
M.execute_lines = function(first, last)
|
||||||
first = first or vim.fn.line(".")
|
first = first or vim.fn.line(".")
|
||||||
last = last or first
|
last = last or first
|
||||||
|
@ -25,6 +33,7 @@ M.execute_lines = function(first, last)
|
||||||
loadstring(code)()
|
loadstring(code)()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Execute current selection as a lua chunk.
|
||||||
M.execute_selection = function()
|
M.execute_selection = function()
|
||||||
local selection = { vim.fn.line("v"), vim.fn.line(".") }
|
local selection = { vim.fn.line("v"), vim.fn.line(".") }
|
||||||
table.sort(selection)
|
table.sort(selection)
|
||||||
|
@ -39,6 +48,9 @@ M.execute_file = function(path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Edit a lua module.
|
||||||
|
---@param modname string|nil Module name. If nil, edit path name under cursor
|
||||||
|
--- (meant to be mapped to `gf`).
|
||||||
M.go_to_module = function(modname)
|
M.go_to_module = function(modname)
|
||||||
modname = modname or vim.fn.expand("<cfile>")
|
modname = modname or vim.fn.expand("<cfile>")
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,27 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
---Toggle 'number' and disable 'relativenumber'.
|
||||||
M.toggle_number = function()
|
M.toggle_number = function()
|
||||||
vim.wo.number = not vim.wo.number
|
vim.wo.number = not vim.wo.number
|
||||||
vim.wo.relativenumber = false
|
vim.wo.relativenumber = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Toggle 'relativenumber' and enable 'number' if disabled.
|
||||||
M.toggle_relativenumber = function()
|
M.toggle_relativenumber = function()
|
||||||
vim.wo.relativenumber = not vim.wo.relativenumber
|
vim.wo.relativenumber = not vim.wo.relativenumber
|
||||||
vim.wo.number = vim.wo.relativenumber or vim.wo.number
|
vim.wo.number = vim.wo.relativenumber or vim.wo.number
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Toggle 'list'.
|
||||||
M.toggle_list = function() vim.wo.list = not vim.wo.list end
|
M.toggle_list = function() vim.wo.list = not vim.wo.list end
|
||||||
|
|
||||||
|
---Toggle 'wrap'.
|
||||||
M.toggle_wrap = function() vim.wo.wrap = not vim.wo.wrap end
|
M.toggle_wrap = function() vim.wo.wrap = not vim.wo.wrap end
|
||||||
|
|
||||||
|
---Toggle 'spell'.
|
||||||
M.toggle_spell = function() vim.wo.spell = not vim.wo.spell end
|
M.toggle_spell = function() vim.wo.spell = not vim.wo.spell end
|
||||||
|
|
||||||
|
---Set buffer options for git commits.
|
||||||
M.set_gitcommit_buffer_options = function()
|
M.set_gitcommit_buffer_options = function()
|
||||||
vim.bo.textwidth = 72
|
vim.bo.textwidth = 72
|
||||||
vim.opt.formatoptions:append("t") -- wrap text on 'textwidth'
|
vim.opt.formatoptions:append("t") -- wrap text on 'textwidth'
|
||||||
|
|
Loading…
Add table
Reference in a new issue