neovim

Personal neovim configuration files
git clone git://gtms.dev/neovim
Log | Files | Refs

commit 4bf2ba6709d131e60522660e023dcccdc5ea2fcf
parent e855d7f7ba38bb6930c4088d1239f62d9b9cb2f9
Author: Tomas Nemec <owl@gtms.dev>
Date:   Tue, 20 May 2025 09:38:22 +0200

update

Diffstat:
Mafter/ftplugin/dart.lua | 2--
Dafter/ftplugin/gdscript.lua | 7-------
Mafter/ftplugin/go.lua | 2--
Mafter/ftplugin/html.lua | 2--
Mafter/ftplugin/htmlangular.lua | 2--
Mafter/ftplugin/json.lua | 13-------------
Mafter/ftplugin/lua.lua | 25-------------------------
Mafter/plugin/lsp.lua | 26++++++--------------------
Mafter/plugin/zk.lua | 3+--
Alsp/dartls.lua | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alsp/html.lua | 5+++++
Alsp/intelephense.lua | 7+++++++
Alsp/jsonls.lua | 15+++++++++++++++
Alsp/lua_ls.lua | 9+++++++++
Alsp/yamlls.lua | 8++++++++
Mlua/plugins.lua | 1-
Mlua/tms/lsp/dart.lua | 102-------------------------------------------------------------------------------
Dlua/tms/lsp/init.lua | 22----------------------
Dlua/tms/lsp/servers.lua | 59-----------------------------------------------------------
19 files changed, 121 insertions(+), 259 deletions(-)

diff --git a/after/ftplugin/dart.lua b/after/ftplugin/dart.lua @@ -30,8 +30,6 @@ if string.find(full_path, '%.pub%-cache') then vim.bo.modifiable = false end -require 'tms.lsp.dart'.start() - vim.keymap.set('n', '<leader>ar', ':make<cr>', { desc = 'Dart Run' }) vim.keymap.set('n', '<leader>at', ':DartTest<cr>', { desc = 'Dart Test' }) vim.keymap.set('n', '<leader>an', vim.cmd.Trun, { desc = 'Trun' }) diff --git a/after/ftplugin/gdscript.lua b/after/ftplugin/gdscript.lua @@ -1,7 +0,0 @@ -vim.lsp.start { - name = 'gdscript', - cmd = vim.lsp.rpc.connect('127.0.0.1', 6005), - filetypes = { 'gd', 'gdscript', 'gdscript3' }, - capabilities = require 'tms.lsp'.capabilities(), - root_dir = vim.fs.dirname(vim.fs.find({ 'project.godot', '.git' }, { upward = true })[1]), -} diff --git a/after/ftplugin/go.lua b/after/ftplugin/go.lua @@ -1,8 +1,6 @@ local set = vim.opt_local set.makeprg = [[go run %]] -vim.lsp.start(require 'tms.lsp'.make_opts('gopls')) - -- vim.cmd [[command! -buffer -nargs=? Godoc lua require('tms.ft.go.doc').godoc(vim.fn.expand('<args>'), vim.fn.expand('<cword>'))]] vim.api.nvim_create_autocmd('BufWritePre', { diff --git a/after/ftplugin/html.lua b/after/ftplugin/html.lua @@ -1,4 +1,2 @@ --- require 'tms.lsp.dart'.start() - local set = vim.opt_local set.shiftwidth = 4 diff --git a/after/ftplugin/htmlangular.lua b/after/ftplugin/htmlangular.lua @@ -1,5 +1,3 @@ --- require 'tms.lsp.dart'.start() - local set = vim.opt_local set.shiftwidth = 4 diff --git a/after/ftplugin/json.lua b/after/ftplugin/json.lua @@ -7,16 +7,3 @@ end vim.keymap.set('n', 'y<c-p>', function() vim.fn.setreg('+', require 'tms.p.jsonpath'.get()) end, { buffer = true, desc = 'Yank Json Path' }) - -local schemas -if pcall(require, 'schemastore') then - schemas = require 'schemastore'.json.schemas() -end - -vim.lsp.start { - name = 'jsonls', - cmd = { 'vscode-json-language-server', '--stdio' }, - capabilities = require 'tms.lsp'.capabilities(), - root_dir = vim.fn.getcwd(), - settings = { json = { schemas = schemas, validate = { enable = true } } }, -} diff --git a/after/ftplugin/lua.lua b/after/ftplugin/lua.lua @@ -16,29 +16,4 @@ if pcall(require, 'lazydev') then } 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/after/plugin/lsp.lua b/after/plugin/lsp.lua @@ -1,8 +1,8 @@ -if not pcall(require, 'lspconfig') then - return -end +vim.lsp.enable { 'gopls', 'lua_ls', 'dartls' } -local lsp_group = vim.api.nvim_create_augroup('user-lsp', {}) +local lsp_group = vim.api.nvim_create_augroup('my.lsp', { + clear = false +}) local function keymap(client, buf) local function opts(desc) @@ -93,7 +93,7 @@ local function keymap(client, buf) if client:supports_method('textDocument/documentHighlight') then vim.keymap.set('n', '<leader>k', vim.lsp.buf.document_highlight, opts 'LSP Highlight') vim.api.nvim_create_autocmd('CursorMoved', - { group = lsp_group, buffer = buf, callback = vim.lsp.buf.clear_references }) + { group = 'my.lsp', buffer = buf, callback = vim.lsp.buf.clear_references }) end if client:supports_method('textDocument/inlayHint') then @@ -122,7 +122,7 @@ local function keymap(client, buf) end vim.api.nvim_create_autocmd('LspAttach', { - group = lsp_group, + group = 'my.lsp', callback = function(args) local client = vim.lsp.get_client_by_id(args.data.client_id) if not client then @@ -171,18 +171,4 @@ end -- mason if pcall(require, 'mason') then require 'mason'.setup() - local mlsp = require 'mason-lspconfig' - mlsp.setup() - mlsp.setup_handlers { - function(name) - local opts = require 'tms.lsp'.make_opts(name) - require 'lspconfig'[name].setup(opts) - end, - ['jsonls'] = function() - end, - ['jdtls'] = function() - end, - -- ['lua_ls'] = function() - -- end, - } end diff --git a/after/plugin/zk.lua b/after/plugin/zk.lua @@ -24,8 +24,7 @@ vim.keymap.set('n', '<space>zo', '<cmd>ZkNotes {orphan = true}<cr>') -- end -- LSP -local lsp = require('tms.lsp') local has_zk, zk = pcall(require, 'zk') if has_zk then - zk.setup({ lsp = { config = lsp.make_opts('zk') } }) + zk.setup() end diff --git a/lsp/dartls.lua b/lsp/dartls.lua @@ -0,0 +1,70 @@ +local capabilities = { + textDocument = { + hover = { + dynamicRegistration = false + }, + inlayHint = { + dynamicRegistration = false + }, + rename = { + dynamicRegistration = false, + }, + codeAction = { + dynamicRegistration = false + }, + rangeFormatting = { + dynamicRegistration = false + }, + formatting = { + dynamicRegistration = false + }, + definition = { + dynamicRegistration = false + } + }, + workspace = { + workspaceEdit = { documentChanges = true }, + fileOperations = { willRename = true } + }, +} + +return { + -- cmd = { -- + -- 'docker', 'run', '--rm', '-i', + -- '-v', string.format('.:%s', root_dir), + -- '-w', root_dir, + -- '-p', '10000:10000', + -- 'dart:3.4.0', 'dart', 'language-server', '--protocol=lsp', '--diagnostic-port=10000', + -- -- '--instrumentation-log-file=/tmp/dart-plugin-log', + -- }, + -- cmd = vim.lsp.rpc.connect('localhost', 10000), + cmd = { -- + 'dart', + 'language-server', + '--protocol=lsp', + '--port=10000', + -- '--instrumentation-log-file=/tmp/dart-plugin-log', + }, + capabilities = vim.tbl_deep_extend('force', vim.lsp.protocol.make_client_capabilities(), capabilities), + init_options = { + closingLabels = true, + outline = false, + flutterOutline = false, + }, + settings = { dart = { completeFunctionCalls = true, showTodos = true } }, + handlers = { + ['dart/textDocument/publishClosingLabels'] = require 'dart-tools.lsp.labels'.handler(), + ['dart/textDocument/super'] = function(_, result, ctx) + local client = vim.lsp.get_client_by_id(ctx.client_id) + if client then + vim.lsp.util.show_document(result, client.offset_encoding) + end + end, + ['dart/textDocument/imports'] = function(_, result, ctx) + local client = vim.lsp.get_client_by_id(ctx.client_id) + if client then + vim.lsp.util.show_document(result, client.offset_encoding) + end + end, + }, +} diff --git a/lsp/html.lua b/lsp/html.lua @@ -0,0 +1,5 @@ +return { + init_options = { + provideFormatter = false + } +} diff --git a/lsp/intelephense.lua b/lsp/intelephense.lua @@ -0,0 +1,7 @@ +return { + init_options = { + clearCache = true, + licenceKey = os.getenv('XDG_CONFIG_HOME') .. '/intelephense/licenceKey.txt', + globalStoragePath = os.getenv('XDG_CONFIG_HOME') .. '/intelephense', + } +} diff --git a/lsp/jsonls.lua b/lsp/jsonls.lua @@ -0,0 +1,15 @@ +local schemas +if pcall(require, 'schemastore') then + schemas = require 'schemastore'.json.schemas() +end + +return { + settings = { + json = { + schemas = schemas, + validate = { + enable = true + } + } + }, +} diff --git a/lsp/lua_ls.lua b/lsp/lua_ls.lua @@ -0,0 +1,9 @@ +return { + settings = { + Lua = { + telemetry = { + enable = false, + }, + }, + } +} diff --git a/lsp/yamlls.lua b/lsp/yamlls.lua @@ -0,0 +1,8 @@ +return { + settings = { + yaml = { + schemas = require('schemastore').json.schemas(), + validate = { enable = true }, + }, + } +} diff --git a/lua/plugins.lua b/lua/plugins.lua @@ -73,7 +73,6 @@ return require('paq') { -- lsp 'neovim/nvim-lspconfig', 'williamboman/mason.nvim', - 'williamboman/mason-lspconfig.nvim', 'b0o/schemastore.nvim', -- can we get rid of this? 'folke/lazydev.nvim', diff --git a/lua/tms/lsp/dart.lua b/lua/tms/lsp/dart.lua @@ -1,107 +1,5 @@ local M = {} -local capabilities = { - textDocument = { - hover = { - dynamicRegistration = false - }, - inlayHint = { - dynamicRegistration = false - }, - rename = { - dynamicRegistration = false, - }, - codeAction = { - dynamicRegistration = false - }, - rangeFormatting = { - dynamicRegistration = false - }, - formatting = { - dynamicRegistration = false - }, - definition = { - dynamicRegistration = false - } - }, - workspace = { - workspaceEdit = { documentChanges = true }, - fileOperations = { willRename = true } - }, -} - -local root_dir = vim.fs.dirname( - vim.fs.find('pubspec.yaml', { upward = true, stop = vim.uv.os_homedir() })[1]); - -function M.start() - vim.lsp.start { - name = 'dartls', - -- cmd = { -- - -- 'docker', 'run', '--rm', '-i', - -- '-v', string.format('.:%s', root_dir), - -- '-w', root_dir, - -- '-p', '10000:10000', - -- 'dart:3.4.0', 'dart', 'language-server', '--protocol=lsp', '--diagnostic-port=10000', - -- -- '--instrumentation-log-file=/tmp/dart-plugin-log', - -- }, - -- cmd = vim.lsp.rpc.connect('localhost', 10000), - cmd = { -- - 'dart', - 'language-server', - '--protocol=lsp', - '--port=10000', - -- '--instrumentation-log-file=/tmp/dart-plugin-log', - }, - root_dir = root_dir, - capabilities = vim.tbl_deep_extend('force', require 'tms.lsp'.capabilities(), capabilities), - init_options = { - closingLabels = true, - outline = false, - flutterOutline = false, - }, - settings = { dart = { completeFunctionCalls = true, showTodos = true } }, - handlers = { - ['dart/textDocument/publishClosingLabels'] = require 'dart-tools.lsp.labels'.handler(), - ['dart/textDocument/super'] = function(_, result, ctx) - local client = vim.lsp.get_client_by_id(ctx.client_id) - if client then - vim.lsp.util.show_document(result, client.offset_encoding) - end - end, - ['dart/textDocument/imports'] = function(_, result, ctx) - local client = vim.lsp.get_client_by_id(ctx.client_id) - if client then - vim.lsp.util.show_document(result, client.offset_encoding) - end - end, - }, - } - - -- vim.api.nvim_create_autocmd('LspAttach', { - -- callback = function(args) - -- local client = vim.lsp.get_client_by_id(args.data.client_id) - -- if not client then - -- return - -- end - - -- if vim.g.dart_workspaces_populated then - -- return - -- end - - -- if client.name == "dartls" then - -- vim.g.dart_workspaces_populated = true - -- local root = root_dir() - -- for _, pubspec in pairs(vim.fs.find('pubspec.yaml', { path = root, limit = math.huge })) do - -- local dirname = vim.fs.dirname(pubspec) - -- if dirname ~= root then - -- vim.lsp.buf.add_workspace_folder(dirname); - -- end - -- end - -- end - -- end, - -- }) -end - function M.provided_references(opts) opts.items = vim.tbl_filter(function(item) return string.match(item.text, "Provider%(") diff --git a/lua/tms/lsp/init.lua b/lua/tms/lsp/init.lua @@ -1,22 +0,0 @@ -local M = {} - -function M.capabilities() - local o = vim.lsp.protocol.make_client_capabilities() - if pcall(require, 'cmp_nvim_lsp') then - o = vim.tbl_deep_extend('force', o, require 'cmp_nvim_lsp'.default_capabilities()) - end - return o -end - -function M.make_opts(name) - local opts = {} - opts.name = name - opts.capabilities = M.capabilities() - local servers = require('tms.lsp.servers') - if not servers[name] then - return opts - end - return servers[name](opts) -end - -return M diff --git a/lua/tms/lsp/servers.lua b/lua/tms/lsp/servers.lua @@ -1,59 +0,0 @@ --- 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 = { - -- - schemas = require('schemastore').json.schemas(), - validate = { enable = true }, - }, - } - return opts -end - -function M.cssls(opts) - opts.capabilities.textDocument.completion.completionItem.snippetSupport = true - return opts -end - -function M.emmet_ls(opts) - opts.root_dir = function(path) - vim.fs.dirname(vim.fs.find({ '.git', vim.fn.getcwd() }, { path = path, upward = true })[1]) - end - return opts -end - -function M.gopls(opts) - opts.cmd = { 'gopls' } - opts.filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' } - opts.root_dir = vim.fs.dirname(vim.fs.find({ 'go.work', 'go.mod', '.git', vim.fn.getcwd() }, { upward = true })[1]) - return opts -end - -function M.html(opts) - opts.init_options = { provideFormatter = false } - return opts -end - -function M.intelephense(opts) - opts.init_options = { - clearCache = true, - licenceKey = os.getenv('XDG_CONFIG_HOME') .. '/intelephense/licenceKey.txt', - globalStoragePath = os.getenv('XDG_CONFIG_HOME') .. '/intelephense', - } - return opts -end - -return M