commit c36e189f0b54eaa8bf3f135f2fa63aa5d47d0ac4
parent bc155252296f64d50c5deb3ab9f7e5766c866d72
Author: Tomas Nemec <owl@gtms.dev>
Date: Wed, 17 Jul 2024 09:19:43 +0200
feat: lua fix
Diffstat:
13 files changed, 62 insertions(+), 53 deletions(-)
diff --git a/after/plugin/cmp.lua b/after/plugin/cmp.lua
@@ -113,7 +113,8 @@ cmp.setup({
-- }, { { name = 'buffer' } }),
sources = cmp.config.sources({
- { name = 'snippets', max_item_count = 3 },
+ { name = 'snippets', max_item_count = 3 },
+ { name = 'lazydev' },
{
name = 'nvim_lsp',
-- entry_filter = function(entry, ctx)
diff --git a/after/plugin/difftastic.lua b/after/plugin/difftastic.lua
@@ -137,8 +137,8 @@ local function show_diff(lang, lhs_file, rhs_file, chunks)
vim.api.nvim_buf_set_name(lhs_buf, lhs_file)
vim.api.nvim_buf_set_name(rhs_buf, rhs_file)
- vim.api.nvim_buf_set_option(lhs_buf, 'filetype', lang)
- vim.api.nvim_buf_set_option(rhs_buf, 'filetype', lang)
+ vim.api.nvim_set_option_value('filetype', lang, { buf = lhs_buf })
+ vim.api.nvim_set_option_value('filetype', lang, { buf = rhs_buf })
-- print(vim.api.nvim_buf_is_valid(buf), vim.api.nvim_buf_is_loaded(buf), vim.api.nvim_buf_line_count(buf))
-- do
@@ -173,7 +173,7 @@ local function show_diff(lang, lhs_file, rhs_file, chunks)
style = 'minimal',
})
vim.keymap.set('n', 'q', function()
- vim.api.nvim_buf_delete(lsh_buf, { force = true })
+ vim.api.nvim_buf_delete(lhs_buf, { force = true })
vim.api.nvim_win_close(lhs_win, true)
vim.api.nvim_win_close(rhs_win, true)
end, { buffer = rhs_buf })
@@ -199,11 +199,9 @@ local function show_diff(lang, lhs_file, rhs_file, chunks)
-- vim.api.nvim_win_close(rhs_win, true)
-- end,
-- })
-
end
vim.api.nvim_create_user_command('Diff', function()
-
local lhs_file = vim.fn.getcwd() .. '/test/before.json'
local rhs_file = vim.fn.getcwd() .. '/test/after.json'
diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua
@@ -84,6 +84,7 @@ local function keymap(client, buf)
if client.supports_method('textDocument/inlayHint') then
vim.keymap.set('n', prefix .. 'h', function()
+ ---@diagnostic disable-next-line: missing-parameter
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
end, opts 'LSP Inlay hints')
end
@@ -145,7 +146,7 @@ handlers['client/registerCapability'] = function(_, result, ctx)
local r = crc(_, result, ctx)
local client = vim.lsp.get_client_by_id(ctx.client_id)
- keymap(client, ctx.buf)
+ keymap(client, ctx.bufnr)
return r
end
@@ -169,7 +170,7 @@ if pcall(require, 'mason') then
end,
['jdtls'] = function()
end,
- ['lua_ls'] = function()
- end,
+ -- ['lua_ls'] = function()
+ -- end,
}
end
diff --git a/after/plugin/neodev.lua b/after/plugin/neodev.lua
@@ -1,5 +0,0 @@
-if not pcall(require, 'neodev') then
- return
-end
-
-require 'neodev'.setup {}
diff --git a/ftplugin/dap-repl.lua b/ftplugin/dap-repl.lua
@@ -4,7 +4,7 @@ end
local terminal = require('terminal')
local rgb_color_table = terminal.initialize_terminal_colors()
-vim.api.nvim_win_set_option(0, 'conceallevel', 2)
-vim.api.nvim_win_set_option(0, 'concealcursor', 'nc')
-vim.api.nvim_win_set_option(0, 'wrap', false)
+vim.api.nvim_set_option_value('conceallevel', 2, { buf = 0 })
+vim.api.nvim_set_option_value('concealcursor', 'nc', { buf = 0 })
+vim.api.nvim_set_option_value('wrap', false, { buf = 0 })
terminal.attach_to_buffer(vim.api.nvim_get_current_buf(), rgb_color_table)
diff --git a/ftplugin/lua.lua b/ftplugin/lua.lua
@@ -4,30 +4,33 @@ vim.bo.shiftwidth = 2
vim.keymap.set('n', '<leader>ar', vim.cmd.make)
-vim.lsp.start {
- name = 'lua-language-server',
- cmd = { 'lua-language-server' },
- before_init = require 'neodev.lsp'.before_init,
- capabilities = require 'tms.lsp'.capabilities(),
- root_dir = vim.fn.getcwd(),
- settings = {
- Lua = {
- runtime = { version = 'LuaJIT' },
- diagnostics = {
- --
- globals = { 'vim' },
- disable = { 'missing-parameter' },
- },
- telemetry = { enable = false },
- workspace = {
- checkThirdParty = false,
- -- slow compared to neodev
- -- library = vim.api.nvim_get_runtime_file('', true),
- -- library = { vim.env.VIMRUNTIME },
- },
- completion = { callSnippet = 'Replace' },
- },
- },
-}
+if pcall(require, 'lazydev') then
+ require 'lazydev'.setup {}
+end
+
+-- vim.lsp.start {
+-- name = 'lua-language-server',
+-- cmd = { 'lua-language-server' },
+-- capabilities = require 'tms.lsp'.capabilities(),
+-- root_dir = vim.fn.getcwd(),
+-- settings = {
+-- Lua = {
+-- runtime = { version = 'LuaJIT' },
+-- diagnostics = {
+-- --
+-- globals = { 'vim' },
+-- disable = { 'missing-parameter' },
+-- },
+-- telemetry = { enable = false },
+-- workspace = {
+-- checkThirdParty = false,
+-- -- slow compared to neodev
+-- -- library = vim.api.nvim_get_runtime_file('', true),
+-- -- library = { vim.env.VIMRUNTIME },
+-- },
+-- completion = { callSnippet = 'Replace' },
+-- },
+-- },
+-- }
vim.api.nvim_set_hl(0, '@lsp.mod.defaultLibrary.lua', { link = 'Special' })
diff --git a/lua/plugins.lua b/lua/plugins.lua
@@ -66,7 +66,7 @@ return require('paq') {
'williamboman/mason-lspconfig.nvim',
'b0o/schemastore.nvim',
-- can we get rid of this?
- 'folke/neodev.nvim',
+ 'folke/lazydev.nvim',
-- { 'jose-elias-alvarez/null-ls.nvim', requires = { 'nvim-lua/plenary.nvim' } },
'stevearc/conform.nvim',
'Exafunction/codeium.vim',
diff --git a/lua/tms/lsp/servers.lua b/lua/tms/lsp/servers.lua
@@ -1,6 +1,17 @@
-- Custom configuration for servers
local M = {}
+function M.lua_ls(opts)
+ opts.settings = {
+ Lua = {
+ telemetry = {
+ enable = false,
+ },
+ },
+ }
+ return opts
+end
+
function M.yamlls(opts)
opts.settings = {
yaml = {
diff --git a/plugin/bufremove.lua b/plugin/bufremove.lua
@@ -147,7 +147,7 @@ function H.can_remove(buf_id, force, fun_name)
return true
end
- if vim.api.nvim_buf_get_option(buf_id, 'modified') then
+ if vim.api.nvim_get_option_value('modified', { buf = buf_id }) then
H.notify(string.format('Buffer %d has unsaved changes. Use `Bufremove.%s(%d, true)` to force.', buf_id, fun_name,
buf_id))
return false
diff --git a/plugin/diagflow.lua b/plugin/diagflow.lua
@@ -84,7 +84,7 @@ local function render(diagnostics, bufnr)
bufnr = bufnr or vim.api.nvim_get_current_buf()
- if vim.diagnostic.is_disabled(bufnr) then
+ if not vim.diagnostic.is_enabled(bufnr) then
return
end
diff --git a/plugin/diagnostic.lua b/plugin/diagnostic.lua
@@ -8,12 +8,12 @@ vim.diagnostic.config({
local rhs = {
local_errors = function() vim.diagnostic.setloclist { severity = vim.diagnostic.severity.ERROR } end,
all_errors = function() vim.diagnostic.setqflist { severity = vim.diagnostic.severity.ERROR } end,
- next_error = function() vim.diagnostic.goto_next { severity = vim.diagnostic.severity.ERROR } end,
- prev_error = function() vim.diagnostic.goto_prev { severity = vim.diagnostic.severity.ERROR } end,
+ next_error = function() vim.diagnostic.jump { count = 1, severity = vim.diagnostic.severity.ERROR } end,
+ prev_error = function() vim.diagnostic.jump { count = -1, severity = vim.diagnostic.severity.ERROR } end,
}
-vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = "Previous Diagnostic" })
-vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = "Next Diagnostic" })
+vim.keymap.set('n', '[d', function() vim.diagnostic.jump { count = -1 } end, { desc = "Previous Diagnostic" })
+vim.keymap.set('n', ']d', function() vim.diagnostic.jump { count = 1 } end, { desc = "Next Diagnostic" })
vim.keymap.set('n', '[D', vim.diagnostic.setloclist, { desc = "Local Diagnostic" })
vim.keymap.set('n', '[<c-d>', vim.diagnostic.setqflist, { desc = "All Diagnostic" })
diff --git a/plugin/json_qf.lua b/plugin/json_qf.lua
@@ -9,8 +9,8 @@ end
local function get_key_location(key)
return {
- row = vim.api.nvim_exec([[g/^\s*"]] .. key .. [["/echo line('.')]], true),
- col = vim.api.nvim_exec([[g/^\s*"]] .. key .. [["/execute "normal! ^" | echo col('.')-1]], true),
+ row = vim.api.nvim_exec2([[g/^\s*"]] .. key .. [["/echo line('.')]], { output = true }),
+ col = vim.api.nvim_exec2([[g/^\s*"]] .. key .. [["/execute "normal! ^" | echo col('.')-1]], { output = true }),
}
end
@@ -49,7 +49,7 @@ local function populate_qf(type, sort, use_quickfix)
end
vim.api.nvim_create_user_command('Json', function()
- local ft = vim.api.nvim_buf_get_option(0, 'ft')
+ local ft = vim.api.nvim_get_option_value('ft', { buf = 0 })
if ft == 'json' then
populate_qf(nil, true, false)
end
diff --git a/plugin/trun.lua b/plugin/trun.lua
@@ -131,7 +131,7 @@ local function open_diag(qf_items)
local diag_items = vim.diagnostic.fromqflist(items)
-- allow diag only for html template
- local ft = vim.api.nvim_buf_get_option(bufnr, 'ft')
+ local ft = vim.api.nvim_get_option_value('ft', { buf = bufnr })
if ft ~= 'html' then
return
end