From a1135381c693a7b472e4499c10dc0bdca130871c Mon Sep 17 00:00:00 2001 From: Matthew Leong Date: Fri, 17 Nov 2023 21:02:58 -0800 Subject: [PATCH] feat: update lsp capabilities - dynamicRegistration --- lazy-lock.json | 18 +++--- lua/cosmic/lsp/providers/defaults.lua | 10 +++- lua/cosmic/plugins/mason-lspconfig/init.lua | 65 +++++++++++++++++++++ lua/cosmic/plugins/nvim-cmp/config.lua | 2 - lua/cosmic/plugins/nvim-cmp/init.lua | 1 - 5 files changed, 84 insertions(+), 12 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 081b8b3..3d0ec16 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,7 +1,7 @@ { "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, "LuaSnip": { "branch": "master", "commit": "1f4ad8bb72bdeb60975e98652636b991a9b7475d" }, - "SchemaStore.nvim": { "branch": "main", "commit": "357fe900baae09e1a3fcef913e49733d05d1f888" }, + "SchemaStore.nvim": { "branch": "main", "commit": "9fb873af43568464f9a1936fc334dfa3d7a59418" }, "auto-session": { "branch": "main", "commit": "3eb26b949e1b90798e84926848551046e2eb0721" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" }, @@ -11,30 +11,32 @@ "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "cosmic-ui": { "branch": "main", "commit": "c0b14531999f2bfef3d927c4dcd57a1a8fed5ee9" }, "friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" }, - "gitsigns.nvim": { "branch": "main", "commit": "af0f583cd35286dd6f0e3ed52622728703237e50" }, + "garbage-day.nvim": { "branch": "main", "commit": "cecb3b5672b61d970bb714cec781720c9ab76bbf" }, + "gitsigns.nvim": { "branch": "main", "commit": "0ccd5fb2316b3f8d8b2f775bc31cae7bc6a77a55" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, "lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "faeb361507aa1ef1b0e5645781e2aa0d36a4aa84" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "ab640b38ca9fa50d25d2d249b6606b9456b628d5" }, "mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" }, + "neodev.nvim": { "branch": "main", "commit": "b2881eeb395d2b268de5fe9b5e201a8f1816beb8" }, "noice.nvim": { "branch": "main", "commit": "92433164e2f7118d4122c7674c3834d9511722ba" }, - "none-ls.nvim": { "branch": "main", "commit": "e5abf91b410e28e823b26fe9141287fb416d2dee" }, + "none-ls.nvim": { "branch": "main", "commit": "fa9be1679db7bf57d44128a018db43da5488a07f" }, "nui.nvim": { "branch": "main", "commit": "c0c8e347ceac53030f5c1ece1c5a5b6a17a25b32" }, "nvim-autopairs": { "branch": "master", "commit": "0f04d78619cce9a5af4f355968040f7d675854a1" }, "nvim-cmp": { "branch": "main", "commit": "0b751f6beef40fd47375eaf53d3057e0bfa317e4" }, "nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" }, "nvim-lsp-ts-utils": { "branch": "main", "commit": "0a6a16ef292c9b61eac6dad00d52666c7f84b0e7" }, - "nvim-lspconfig": { "branch": "master", "commit": "d5d7412ff267b92a11a94e6559d5507c43670a52" }, + "nvim-lspconfig": { "branch": "master", "commit": "a4083b0e875866a04e866ee5bd2b00ede52e9cac" }, "nvim-notify": { "branch": "master", "commit": "e4a2022f4fec2d5ebc79afa612f96d8b11c627b3" }, "nvim-tree.lua": { "branch": "master", "commit": "80cfeadf179d5cba76f0f502c71dbcff1b515cd8" }, - "nvim-treesitter": { "branch": "master", "commit": "8b9f99660294dcd11d42572c84ee33a1e284f70d" }, + "nvim-treesitter": { "branch": "master", "commit": "557561fbc17269cdd4e9e88ef0ca1a9ff0bbf7e6" }, "nvim-treesitter-refactor": { "branch": "master", "commit": "65ad2eca822dfaec2a3603119ec3cc8826a7859e" }, "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "6c30f3c8915d7b31c3decdfe6c7672432da1809d" }, - "nvim-web-devicons": { "branch": "master", "commit": "11eb26fc166742db8d1e8a6f5a7de9df37b09aae" }, + "nvim-web-devicons": { "branch": "master", "commit": "3523d6e6d40ab11fd66c1b2732b3d6b60affa951" }, "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, - "telescope.nvim": { "branch": "master", "commit": "721cdcae134eb5c564cb6c9df6c317c3854528ad" }, + "telescope.nvim": { "branch": "master", "commit": "18774ec7929c8a8003a91e9e1f69f6c32258bbfe" }, "todo-comments.nvim": { "branch": "main", "commit": "4a6737a8d70fe1ac55c64dfa47fcb189ca431872" }, "tokyonight.nvim": { "branch": "main", "commit": "f247ee700b569ed43f39320413a13ba9b0aef0db" }, "vim-floaterm": { "branch": "master", "commit": "b1d93789faf8bfe1f3e17eec03b8312c2939fcf2" }, diff --git a/lua/cosmic/lsp/providers/defaults.lua b/lua/cosmic/lsp/providers/defaults.lua index af097ad..c19d6f5 100644 --- a/lua/cosmic/lsp/providers/defaults.lua +++ b/lua/cosmic/lsp/providers/defaults.lua @@ -3,6 +3,7 @@ local M = {} local augroup_name = 'CosmicNvimLspFormat' local group = vim.api.nvim_create_augroup(augroup_name, { clear = true }) local user_config = require('cosmic.core.user') +local u = require('cosmic.utils') function M.on_attach(client, bufnr) local function buf_set_option(name, value) @@ -65,7 +66,14 @@ function M.on_attach(client, bufnr) end end -M.capabilities = capabilities +M.capabilities = u.merge(capabilities, { + -- See: https://github.com/neovim/neovim/issues/23291 + workspace = { + didChangeWatchedFiles = { + dynamicRegistration = false, + }, + }, +}) M.root_dir = function(fname) local util = require('lspconfig').util diff --git a/lua/cosmic/plugins/mason-lspconfig/init.lua b/lua/cosmic/plugins/mason-lspconfig/init.lua index 898af8f..516c181 100644 --- a/lua/cosmic/plugins/mason-lspconfig/init.lua +++ b/lua/cosmic/plugins/mason-lspconfig/init.lua @@ -50,6 +50,71 @@ return { start_server(config_server) end end + + -- See: https://github.com/neovim/neovim/issues/23291 + --[[ local watch_type = require('vim._watch').FileChangeType ]] + --[[]] + --[[ local function handler(res, callback) ]] + --[[ if not res.files or res.is_fresh_instance then ]] + --[[ return ]] + --[[ end ]] + --[[]] + --[[ for _, file in ipairs(res.files) do ]] + --[[ local path = res.root .. '/' .. file.name ]] + --[[ local change = watch_type.Changed ]] + --[[ if file.new then ]] + --[[ change = watch_type.Created ]] + --[[ end ]] + --[[ if not file.exists then ]] + --[[ change = watch_type.Deleted ]] + --[[ end ]] + --[[ callback(path, change) ]] + --[[ end ]] + --[[ end ]] + --[[]] + --[[ local function watchman(path, opts, callback) ]] + --[[ vim.system({ 'watchman', 'watch', path }):wait() ]] + --[[]] + --[[ local buf = {} ]] + --[[ local sub = vim.system({ ]] + --[[ 'watchman', ]] + --[[ '-j', ]] + --[[ '--server-encoding=json', ]] + --[[ '-p', ]] + --[[ }, { ]] + --[[ stdin = vim.json.encode({ ]] + --[[ 'subscribe', ]] + --[[ path, ]] + --[[ 'nvim:' .. path, ]] + --[[ { ]] + --[[ expression = { 'anyof', { 'type', 'f' }, { 'type', 'd' } }, ]] + --[[ fields = { 'name', 'exists', 'new' }, ]] + --[[ }, ]] + --[[ }), ]] + --[[ stdout = function(_, data) ]] + --[[ if not data then ]] + --[[ return ]] + --[[ end ]] + --[[ for line in vim.gsplit(data, '\n', { plain = true, trimempty = true }) do ]] + --[[ table.insert(buf, line) ]] + --[[ if line == '}' then ]] + --[[ local res = vim.json.decode(table.concat(buf)) ]] + --[[ handler(res, callback) ]] + --[[ buf = {} ]] + --[[ end ]] + --[[ end ]] + --[[ end, ]] + --[[ text = true, ]] + --[[ }) ]] + --[[]] + --[[ return function() ]] + --[[ sub:kill('sigint') ]] + --[[ end ]] + --[[ end ]] + --[[]] + --[[ if vim.fn.executable('watchman') == 1 then ]] + --[[ require('vim.lsp._watchfiles')._watchfunc = watchman ]] + --[[ end ]] end, dependencies = { 'williamboman/mason.nvim', diff --git a/lua/cosmic/plugins/nvim-cmp/config.lua b/lua/cosmic/plugins/nvim-cmp/config.lua index 62cc488..ff666b8 100644 --- a/lua/cosmic/plugins/nvim-cmp/config.lua +++ b/lua/cosmic/plugins/nvim-cmp/config.lua @@ -82,7 +82,6 @@ local default_cmp_opts = { sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'luasnip' }, - { name = 'nvim_lua' }, { name = 'path' }, }, { { name = 'buffer' }, @@ -96,7 +95,6 @@ local default_cmp_opts = { luasnip = '[snip]', buffer = '[buf]', path = '[path]', - nvim_lua = '[nvim_api]', })[entry.source.name] return vim_item end, diff --git a/lua/cosmic/plugins/nvim-cmp/init.lua b/lua/cosmic/plugins/nvim-cmp/init.lua index 2cf6a13..e3fe89f 100644 --- a/lua/cosmic/plugins/nvim-cmp/init.lua +++ b/lua/cosmic/plugins/nvim-cmp/init.lua @@ -9,7 +9,6 @@ return { 'hrsh7th/cmp-nvim-lsp', 'saadparwaiz1/cmp_luasnip', 'hrsh7th/cmp-buffer', - 'hrsh7th/cmp-nvim-lua', 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-path', -- has configs