diff --git a/modules/home-manager/common.nix b/modules/home-manager/common.nix index 6d3c845c..2eea7a4c 100644 --- a/modules/home-manager/common.nix +++ b/modules/home-manager/common.nix @@ -16,7 +16,7 @@ pkgs.nix-output-monitor pkgs.nil self'.packages.env - pkgs.nodePackages.bash-language-server + # pkgs.nodePackages.bash-language-server ]; # home.sessionVariables = { diff --git a/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/completion.lua b/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/completion.lua index 957c90e9..aba8178d 100644 --- a/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/completion.lua +++ b/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/completion.lua @@ -37,18 +37,22 @@ local mapping = cmp.mapping.preset.insert { fallback() end end, { "i", "s", "c" }), - [""] = cmp.mapping(function(callback) + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item({ behavior = cmp.SelectBehavior.Select }) else - fallback() + if fallback ~= nil then + fallback() + end end end, {"i","s","c"}), - [""] = cmp.mapping(function(callback) + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select }) else - fallback() + if fallback ~= nil then + fallback() + end end end, {"i","s","c"}), } diff --git a/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/direnv.lua b/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/direnv.lua new file mode 100644 index 00000000..23499cf3 --- /dev/null +++ b/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/direnv.lua @@ -0,0 +1,3 @@ + -- on_new_config = function(config, new_root_dir) + -- end, + diff --git a/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/init.lua b/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/init.lua index cd2456a8..b061e6a2 100644 --- a/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/init.lua +++ b/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/init.lua @@ -6,6 +6,7 @@ require("viper.dap") require("viper.tree-sitter") require("viper.format") require("viper.org") +require("viper.direnv") require("neovim-project").setup { projects = { diff --git a/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/lsp.lua b/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/lsp.lua index 08898a88..397f3532 100644 --- a/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/lsp.lua +++ b/modules/wrapper-manager/neovim/viper-init-plugin/lua/viper/lsp.lua @@ -7,18 +7,6 @@ vim.filetype.add { local capabilities = require("cmp_nvim_lsp").default_capabilities() local nvim_lsp = require("lspconfig") -nvim_lsp.util.on_setup = nvim_lsp.util.add_hook_before(nvim_lsp.util.on_setup, function(config) - local bin_name = config.cmd[1] - - if bin_name ~= nil then - local bin_exists = vim.fn.executable(bin_name) - - if bin_exists == 0 then - -- config.root_dir = nil -- doesn't work? - config.autostart = false - end - end -end) local root_pattern = nvim_lsp.util.root_pattern @@ -126,10 +114,6 @@ nvim_lsp.mesonlsp.setup { capabilities = capabilities, } -nvim_lsp.bashls.setup { - capabilities = capabilities, -} - nvim_lsp.hls.setup { capabilities = capabilities, } @@ -169,9 +153,9 @@ nvim_lsp.pylsp.setup { -- Schemas -- https://www.arthurkoziel.com/json-schemas-in-neovim/ -nvim_lsp.taplo.setup { -- toml - capabilities = capabilities, -} +-- nvim_lsp.taplo.setup { -- toml +-- capabilities = capabilities, +-- } nvim_lsp.yamlls.setup { capabilities = capabilities, settings = { @@ -192,3 +176,69 @@ nvim_lsp.yamlls.setup { }, }, } + +local configs = { + ["taplo"] = {}, + ["bashls"] = {}, +} + + +nvim_lsp.util.on_setup = nvim_lsp.util.add_hook_before(nvim_lsp.util.on_setup, function(config) + vim.notify("> setuphook " .. config.name) + local bin_name = config.cmd[1] + + if bin_name ~= nil then + local bin_exists = vim.fn.executable(bin_name) + + if bin_exists == 0 then + config.autostart = false + vim.notify("Disabling " .. config.name) + else + config.autostart = true + vim.notify("Enabling " .. config.name) + end + else + vim.notify("bin_name was nil") + end + + vim.notify("< setuphook " .. config.name) +end) + +local function setup_all() + for k, v in pairs(configs) do + nvim_lsp[k].setup(v) + end +end + +setup_all() + +local function stop_all() + -- local clients = vim.lsp.get_clients() + -- for _, client in ipairs(clients) do + -- vim.notify("Stopping client: " .. client.name) + -- client:stop() + -- end + vim.lsp.stop_client(vim.lsp.get_clients(), true) + local clients = vim.lsp.get_clients() + vim.notify("Clients left: " .. vim.inspect(clients)) +end + + +vim.api.nvim_create_autocmd({ "DirChanged" }, { + pattern = "global", + callback = function() + local dir = vim.fn.getcwd() + vim.notify("> dirchanged " .. dir) + + stop_all() + + local obj = vim.system({"direnv", "export", "vim"},{}):wait() + vim.fn.execute(obj.stdout) + + setup_all() + + stop_all() + + vim.notify("< dirchanged " .. dir) + end +}) diff --git a/test.sh b/test.sh new file mode 100644 index 00000000..5b3172fb --- /dev/null +++ b/test.sh @@ -0,0 +1,5 @@ +#! /usr/bin/env bash + +set -x + +(