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
|
--- @class libmodal.globals
|
||||||
--- @field private ESC_NR number
|
--- @field ESC_NR number the key-code for the escape character.
|
||||||
--- @field private TYPE_FUNC string
|
--- @field TYPE_FUNC string the string which is returned by `type(function() end)` (or any function)
|
||||||
--- @field private TYPE_NUM string
|
--- @field TYPE_NUM string the string which is returned by `type(0)` (or any number)
|
||||||
--- @field private TYPE_STR string
|
--- @field TYPE_STR string the string which is returned by `type ''` (or any string)
|
||||||
--- @field private TYPE_TBL string
|
--- @field TYPE_TBL string the string which is returned by `type {}` (or any table)
|
||||||
--- @field private VIM_FALSE number
|
--- @field VIM_FALSE number the value of Vimscript's `v:false`
|
||||||
--- @field private VIM_TRUE number
|
--- @field VIM_TRUE number the value of Vimscript's `v:true`
|
||||||
return
|
local globals =
|
||||||
{
|
{
|
||||||
--- the key-code for the escape character.
|
|
||||||
ESC_NR = 27,
|
ESC_NR = 27,
|
||||||
|
|
||||||
--- the string which is returned by `type(function() end)` (or any function)
|
|
||||||
TYPE_FUNC = type(function() end),
|
TYPE_FUNC = type(function() end),
|
||||||
|
|
||||||
--- the string which is returned by `type(0)` (or any number)
|
|
||||||
TYPE_NUM = type(0),
|
TYPE_NUM = type(0),
|
||||||
|
|
||||||
--- the string which is returned by `type ''` (or any string)
|
|
||||||
TYPE_STR = type '',
|
TYPE_STR = type '',
|
||||||
|
|
||||||
--- the string which is returned by `type {}` (or any table)
|
|
||||||
TYPE_TBL = type {},
|
TYPE_TBL = type {},
|
||||||
|
VIM_FALSE = 0,
|
||||||
--- the value of Vimscript's `v:false`
|
VIM_TRUE = 1,
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- 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
|
--- @class libmodal
|
||||||
--- @field private collections libmodal.collections
|
--- @field collections libmodal.collections
|
||||||
--- @field private globals libmodal.globals
|
--- @field globals libmodal.globals
|
||||||
--- @field private Layer libmodal.Layer
|
--- @field Layer libmodal.Layer
|
||||||
--- @field private Mode libmodal.Mode
|
--- @field Mode libmodal.Mode
|
||||||
--- @field private Prompt libmodal.Prompt
|
--- @field Prompt libmodal.Prompt
|
||||||
--- @field private utils libmodal.utils
|
--- @field utils libmodal.utils
|
||||||
return
|
local libmodal =
|
||||||
{
|
{
|
||||||
collections = require 'libmodal/src/collections',
|
collections = require 'libmodal/src/collections',
|
||||||
globals = require 'libmodal/src/globals',
|
globals = require 'libmodal/src/globals',
|
||||||
Layer = require 'libmodal/src/Layer',
|
Layer = require 'libmodal/src/Layer',
|
||||||
Mode = require 'libmodal/src/Mode',
|
Mode = require 'libmodal/src/Mode',
|
||||||
Prompt = require 'libmodal/src/Prompt',
|
Prompt = require 'libmodal/src/Prompt',
|
||||||
utils = require 'libmodal/src/utils',
|
utils = require 'libmodal/src/utils',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return libmodal
|
||||||
|
@ -1,28 +1,13 @@
|
|||||||
local MODE_HIGHLIGHT = 'LibmodalPrompt'
|
|
||||||
local PROMPT_HIGHLIGHT = 'LibmodalStar'
|
|
||||||
|
|
||||||
--- @class libmodal.utils.Indicator
|
--- @class libmodal.utils.Indicator
|
||||||
--- @field public hl string the highlight group to use when printing `str`
|
--- @field hl string the highlight group to use when printing `str`
|
||||||
--- @field public str string the text to write
|
--- @field str string the text to write
|
||||||
local Indicator = {}
|
local Indicator = {}
|
||||||
|
|
||||||
--- @param highlight_group string the highlight group to use when printing `str`
|
--- @param highlight_group string the highlight group to use when printing `str`
|
||||||
--- @param str string what to print
|
--- @param str string what to print
|
||||||
--- @return libmodal.utils.Indicator
|
--- @return libmodal.utils.Indicator
|
||||||
function Indicator.new(highlight_group, str)
|
function Indicator.new(highlight_group, str)
|
||||||
return
|
return {hl = highlight_group, str = str}
|
||||||
{
|
|
||||||
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 .. ' > ')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return Indicator
|
return Indicator
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
--- @class libmodal.utils.classes
|
--- @class libmodal.utils.classes
|
||||||
return
|
local classes = {}
|
||||||
{
|
|
||||||
--- define a metatable.
|
|
||||||
--- @param template? table the default value
|
|
||||||
new = function(template)
|
|
||||||
-- set self to `template`, or `{}` if nil.
|
|
||||||
local self = template or {}
|
|
||||||
|
|
||||||
-- set `__index`.
|
--- define a metatable.
|
||||||
if not self.__index then
|
--- @param template? table the default value
|
||||||
self.__index = self
|
function classes.new(template)
|
||||||
end
|
-- set self to `template`, or `{}` if nil.
|
||||||
|
local self = template or {}
|
||||||
|
|
||||||
return self
|
-- set `__index`.
|
||||||
end,
|
if not self.__index then
|
||||||
}
|
self.__index = self
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
return classes
|
||||||
|
@ -1,28 +1,29 @@
|
|||||||
--- @class libmodal.utils
|
--- @class libmodal.utils
|
||||||
--- @field private completions libmodal.utils.api
|
--- @field api libmodal.utils.api
|
||||||
--- @field private classes libmodal.utils.classes
|
--- @field classes libmodal.utils.classes
|
||||||
--- @field private Indicator libmodal.utils.Indicator
|
--- @field Indicator libmodal.utils.Indicator
|
||||||
--- @field private Help libmodal.utils.Help
|
--- @field Help libmodal.utils.Help
|
||||||
--- @field private Popup libmodal.utils.Popup
|
--- @field Popup libmodal.utils.Popup
|
||||||
--- @field private Vars libmodal.utils.Vars
|
--- @field Vars libmodal.utils.Vars
|
||||||
return
|
local utils =
|
||||||
{
|
{
|
||||||
api = require 'libmodal/src/utils/api',
|
api = require 'libmodal/src/utils/api',
|
||||||
classes = require 'libmodal/src/utils/classes',
|
classes = require 'libmodal/src/utils/classes',
|
||||||
Indicator = require 'libmodal/src/utils/Indicator',
|
Indicator = require 'libmodal/src/utils/Indicator',
|
||||||
Help = require 'libmodal/src/utils/Help',
|
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',
|
Popup = require 'libmodal/src/utils/Popup',
|
||||||
Vars = require 'libmodal/src/utils/Vars',
|
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