diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 3088502..0dfd40a 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -47,7 +47,7 @@ jobs: nvim -c 'helptags doc' -c 'quit' - name: Push Changes - uses: stefanzweifel/git-auto-commit-action@v6 + uses: stefanzweifel/git-auto-commit-action@v7 with: commit_message: "docs: Auto-generate user / API documentation + vimtags" commit_user_name: "github-actions[bot]" diff --git a/lua/lua-console.lua b/lua/lua-console.lua index 0f864d9..2911876 100644 --- a/lua/lua-console.lua +++ b/lua/lua-console.lua @@ -18,7 +18,6 @@ local get_or_create_buffer = function() vim.bo[buf].swapfile = false vim.bo[buf].buflisted = false vim.bo[buf].bufhidden = 'hide' - vim.bo[buf].buftype = 'nowrite' vim.api.nvim_buf_set_name(buf, buf_name) -- the name is only needed so the buffer is picked up by Lsp with correct root @@ -26,6 +25,8 @@ local get_or_create_buffer = function() vim.api.nvim_set_option_value('filetype', 'lua', { buf = buf }) vim.api.nvim_set_option_value('syntax', 'lua', { buf = buf }) + vim.bo[buf].buftype = 'nowrite' -- must be last, otherwise LSP will not attach + vim.diagnostic.enable(false, { bufnr = buf }) mappings.set_console_mappings(buf) diff --git a/lua/lua-console/utils.lua b/lua/lua-console/utils.lua index 889c7da..f74c2d4 100644 --- a/lua/lua-console/utils.lua +++ b/lua/lua-console/utils.lua @@ -359,7 +359,7 @@ local function strip_local(lines) local ts = vim.treesitter local ret = {} - local start_row = math.max(0, vim.fn.line('.') - 1 - #lines) + local start_row = math.max(-1, vim.fn.line('.') - 1 - #lines) for i, line in ipairs(lines) do local cs, ce = 1, 1 @@ -368,8 +368,10 @@ local function strip_local(lines) cs, ce = line:find('local%s', ce) if cs then - local node = ts.get_node { pos = { start_row + i - 1, cs } } - if node and node:parent():type() == 'chunk' then line = line:sub(1, cs - 1) .. line:sub(ce + 1) end + local node = ts.get_node { pos = { start_row + i, cs } } + if node and node:parent() and node:parent():type() == 'chunk' then + line = line:sub(1, cs - 1) .. line:sub(ce + 1) + end end end diff --git a/tests/unit/mappings_spec.lua b/tests/unit/mappings_spec.lua index d8fa10a..71954a1 100644 --- a/tests/unit/mappings_spec.lua +++ b/tests/unit/mappings_spec.lua @@ -216,7 +216,7 @@ describe('lua-console.nvim - mappings', function() assert.has_string(vim.fn.bufname(new_buf), 'lua/lua-console.lua') local line = vim.fn.line('.') - assert.is_same(line, 69) + assert.is_same(line, 70) end) it('opens a split with file from stacktrace', function()