aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--CONTRIBUTING.md5
-rw-r--r--contrib/luarc.json23
-rw-r--r--runtime/lua/vim/diagnostic.lua10
4 files changed, 35 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index e07ce4906e..0988a51cd9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
# Tools
/venv/
compile_commands.json
+/.luarc.json
# IDEs
/.vs/
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e9c1173007..a3bfa06cfb 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -244,6 +244,10 @@ You can lint a single file (but this will _not_ exclude legacy errors):
("Exuberant ctags", the typical `ctags` binary provided by your distro, is
unmaintained and won't recognize many function signatures in Neovim source.)
- Explore the source code [on the web](https://sourcegraph.com/github.com/neovim/neovim).
+- If using [lua-language-server][], symlink `contrib/luarc.json` into the
+ project root:
+
+ $ ln -s contrib/luarc.json .luarc.json
Reviewing
@@ -288,3 +292,4 @@ as context, use the `-W` argument as well.
[pr-draft]: https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request
[pr-ready]: https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request
[uncrustify]: https://formulae.brew.sh/formula/uncrustify
+[lua-language-server]: https://github.com/sumneko/lua-language-server/
diff --git a/contrib/luarc.json b/contrib/luarc.json
new file mode 100644
index 0000000000..770b023ac6
--- /dev/null
+++ b/contrib/luarc.json
@@ -0,0 +1,23 @@
+{
+ "runtime.version": "LuaJIT",
+ "diagnostics": {
+ "enable": true,
+ "globals": [
+ "vim",
+ "describe",
+ "it",
+ "before_each",
+ "after_each",
+ "setup",
+ "teardown"
+ ]
+ },
+ "workspace": {
+ "library": {
+ "runtime/lua": true
+ },
+ "maxPreload": 2000,
+ "preloadFileSize": 1000
+ },
+ "telemetry.enable": false
+}
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index 5c5631af98..a903f25b58 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -386,7 +386,7 @@ local function get_diagnostics(bufnr, opts, clamp)
if not opts.lnum or d.lnum == opts.lnum then
if clamp and vim.api.nvim_buf_is_loaded(b) then
local line_count = buf_line_count[b] - 1
- if (d.lnum > line_count or d.end_lnum > line_count) then
+ if (d.lnum > line_count or d.end_lnum > line_count or d.lnum < 0 or d.end_lnum < 0) then
d = vim.deepcopy(d)
d.lnum = math.max(math.min(d.lnum, line_count), 0)
d.end_lnum = math.max(math.min(d.end_lnum, line_count), 0)
@@ -653,9 +653,11 @@ function M.set(namespace, bufnr, diagnostics, opts)
M.show(namespace, bufnr, nil, opts)
end
- vim.api.nvim_command(
- string.format("doautocmd <nomodeline> DiagnosticChanged %s", vim.api.nvim_buf_get_name(bufnr))
- )
+ vim.api.nvim_buf_call(bufnr, function()
+ vim.api.nvim_command(
+ string.format("doautocmd <nomodeline> DiagnosticChanged %s", vim.api.nvim_buf_get_name(bufnr))
+ )
+ end)
end
--- Get namespace metadata.