ref: make workspace diagnostics more accurate
parent
fb06f151d2
commit
ba75e9b4d3
@ -1,48 +1,34 @@
|
||||
local VIM_FALSE = 0
|
||||
local VIM_TRUE = 1
|
||||
|
||||
--- @class libmodal.globals
|
||||
--- @field private ESC_NR number
|
||||
--- @field private TYPE_FUNC string
|
||||
--- @field private TYPE_NUM string
|
||||
--- @field private TYPE_STR string
|
||||
--- @field private TYPE_TBL string
|
||||
--- @field private VIM_FALSE number
|
||||
--- @field private VIM_TRUE number
|
||||
return
|
||||
--- @field ESC_NR number the key-code for the escape character.
|
||||
--- @field TYPE_FUNC string the string which is returned by `type(function() end)` (or any function)
|
||||
--- @field TYPE_NUM string the string which is returned by `type(0)` (or any number)
|
||||
--- @field TYPE_STR string the string which is returned by `type ''` (or any string)
|
||||
--- @field TYPE_TBL string the string which is returned by `type {}` (or any table)
|
||||
--- @field VIM_FALSE number the value of Vimscript's `v:false`
|
||||
--- @field VIM_TRUE number the value of Vimscript's `v:true`
|
||||
local globals =
|
||||
{
|
||||
--- the key-code for the escape character.
|
||||
ESC_NR = 27,
|
||||
|
||||
--- the string which is returned by `type(function() end)` (or any function)
|
||||
TYPE_FUNC = type(function() end),
|
||||
|
||||
--- the string which is returned by `type(0)` (or any number)
|
||||
TYPE_NUM = type(0),
|
||||
|
||||
--- the string which is returned by `type ''` (or any string)
|
||||
TYPE_STR = type '',
|
||||
|
||||
--- the string which is returned by `type {}` (or any table)
|
||||
TYPE_TBL = type {},
|
||||
|
||||
--- the value of Vimscript's `v:false`
|
||||
VIM_FALSE = VIM_FALSE,
|
||||
|
||||
--- the value of Vimscript's `v:true`
|
||||
VIM_TRUE = VIM_TRUE,
|
||||
|
||||
--- assert some value is either `false` or `v:false`.
|
||||
--- @param val boolean|number
|
||||
--- @return boolean
|
||||
is_false = function(val)
|
||||
return val == false or val == VIM_FALSE
|
||||
end,
|
||||
|
||||
--- assert some value is either `true` or `v:true`.
|
||||
--- @param val boolean|number
|
||||
--- @return boolean
|
||||
is_true = function(val)
|
||||
return val == true or val == VIM_TRUE
|
||||
end
|
||||
VIM_FALSE = 0,
|
||||
VIM_TRUE = 1,
|
||||
}
|
||||
|
||||
--- assert some value is either `false` or `v:false`.
|
||||
--- @param val boolean|number
|
||||
--- @return boolean
|
||||
function globals.is_false(val)
|
||||
return val == false or val == globals.VIM_FALSE
|
||||
end
|
||||
|
||||
--- assert some value is either `true` or `v:true`.
|
||||
--- @param val boolean|number
|
||||
--- @return boolean
|
||||
function globals.is_true(val)
|
||||
return val == true or val == globals.VIM_TRUE
|
||||
end
|
||||
|
||||
return globals
|
||||
|
@ -1,16 +1,18 @@
|
||||
--- @class libmodal
|
||||
--- @field private collections libmodal.collections
|
||||
--- @field private globals libmodal.globals
|
||||
--- @field private Layer libmodal.Layer
|
||||
--- @field private Mode libmodal.Mode
|
||||
--- @field private Prompt libmodal.Prompt
|
||||
--- @field private utils libmodal.utils
|
||||
return
|
||||
--- @field collections libmodal.collections
|
||||
--- @field globals libmodal.globals
|
||||
--- @field Layer libmodal.Layer
|
||||
--- @field Mode libmodal.Mode
|
||||
--- @field Prompt libmodal.Prompt
|
||||
--- @field utils libmodal.utils
|
||||
local libmodal =
|
||||
{
|
||||
collections = require 'libmodal/src/collections',
|
||||
globals = require 'libmodal/src/globals',
|
||||
Layer = require 'libmodal/src/Layer',
|
||||
Mode = require 'libmodal/src/Mode',
|
||||
Prompt = require 'libmodal/src/Prompt',
|
||||
utils = require 'libmodal/src/utils',
|
||||
globals = require 'libmodal/src/globals',
|
||||
Layer = require 'libmodal/src/Layer',
|
||||
Mode = require 'libmodal/src/Mode',
|
||||
Prompt = require 'libmodal/src/Prompt',
|
||||
utils = require 'libmodal/src/utils',
|
||||
}
|
||||
|
||||
return libmodal
|
||||
|
@ -1,28 +1,13 @@
|
||||
local MODE_HIGHLIGHT = 'LibmodalPrompt'
|
||||
local PROMPT_HIGHLIGHT = 'LibmodalStar'
|
||||
|
||||
--- @class libmodal.utils.Indicator
|
||||
--- @field public hl string the highlight group to use when printing `str`
|
||||
--- @field public str string the text to write
|
||||
--- @field hl string the highlight group to use when printing `str`
|
||||
--- @field str string the text to write
|
||||
local Indicator = {}
|
||||
|
||||
--- @param highlight_group string the highlight group to use when printing `str`
|
||||
--- @param str string what to print
|
||||
--- @return libmodal.utils.Indicator
|
||||
function Indicator.new(highlight_group, str)
|
||||
return
|
||||
{
|
||||
hl = highlight_group,
|
||||
str = str,
|
||||
}
|
||||
end
|
||||
|
||||
function Indicator.mode(mode_name)
|
||||
return Indicator.new(MODE_HIGHLIGHT, '-- ' .. mode_name .. ' --')
|
||||
end
|
||||
|
||||
function Indicator.prompt(prompt_name)
|
||||
return Indicator.new(PROMPT_HIGHLIGHT, '* ' .. prompt_name .. ' > ')
|
||||
return {hl = highlight_group, str = str}
|
||||
end
|
||||
|
||||
return Indicator
|
||||
|
@ -1,17 +1,18 @@
|
||||
--- @class libmodal.utils.classes
|
||||
return
|
||||
{
|
||||
--- define a metatable.
|
||||
--- @param template? table the default value
|
||||
new = function(template)
|
||||
-- set self to `template`, or `{}` if nil.
|
||||
local self = template or {}
|
||||
local classes = {}
|
||||
|
||||
-- set `__index`.
|
||||
if not self.__index then
|
||||
self.__index = self
|
||||
end
|
||||
--- define a metatable.
|
||||
--- @param template? table the default value
|
||||
function classes.new(template)
|
||||
-- set self to `template`, or `{}` if nil.
|
||||
local self = template or {}
|
||||
|
||||
return self
|
||||
end,
|
||||
}
|
||||
-- set `__index`.
|
||||
if not self.__index then
|
||||
self.__index = self
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
return classes
|
||||
|
@ -1,28 +1,29 @@
|
||||
--- @class libmodal.utils
|
||||
--- @field private completions libmodal.utils.api
|
||||
--- @field private classes libmodal.utils.classes
|
||||
--- @field private Indicator libmodal.utils.Indicator
|
||||
--- @field private Help libmodal.utils.Help
|
||||
--- @field private Popup libmodal.utils.Popup
|
||||
--- @field private Vars libmodal.utils.Vars
|
||||
return
|
||||
--- @field api libmodal.utils.api
|
||||
--- @field classes libmodal.utils.classes
|
||||
--- @field Indicator libmodal.utils.Indicator
|
||||
--- @field Help libmodal.utils.Help
|
||||
--- @field Popup libmodal.utils.Popup
|
||||
--- @field Vars libmodal.utils.Vars
|
||||
local utils =
|
||||
{
|
||||
api = require 'libmodal/src/utils/api',
|
||||
classes = require 'libmodal/src/utils/classes',
|
||||
Indicator = require 'libmodal/src/utils/Indicator',
|
||||
Help = require 'libmodal/src/utils/Help',
|
||||
|
||||
--- `vim.notify` with a `msg` some `error` which has a `vim.v.throwpoint` and `vim.v.exception`.
|
||||
--- @param msg string
|
||||
--- @param err string
|
||||
notify_error = function(msg, err)
|
||||
vim.notify(
|
||||
msg .. ': ' .. vim.v.throwpoint .. '\n' .. vim.v.exception .. '\n' .. err,
|
||||
vim.log.levels.ERROR,
|
||||
{title = 'nvim-libmodal'}
|
||||
)
|
||||
end,
|
||||
|
||||
Popup = require 'libmodal/src/utils/Popup',
|
||||
Vars = require 'libmodal/src/utils/Vars',
|
||||
}
|
||||
|
||||
--- `vim.notify` with a `msg` some `error` which has a `vim.v.throwpoint` and `vim.v.exception`.
|
||||
--- @param msg string
|
||||
--- @param err string
|
||||
function utils.notify_error(msg, err)
|
||||
vim.notify(
|
||||
msg .. ': ' .. vim.v.throwpoint .. '\n' .. vim.v.exception .. '\n' .. err,
|
||||
vim.log.levels.ERROR,
|
||||
{title = 'nvim-libmodal'}
|
||||
)
|
||||
end
|
||||
|
||||
return utils
|
||||
|
Loading…
Reference in New Issue