diff --git a/lua/setuplsp.lua b/lua/setuplsp.lua index 00730eb..e2ccea9 100644 --- a/lua/setuplsp.lua +++ b/lua/setuplsp.lua @@ -20,7 +20,8 @@ local root_file = { "eslint.config.mts", "eslint.config.cts", } -require'lspconfig'.lemminx.setup{} +require("lspconfig").gopls.setup({}) +require("lspconfig").lemminx.setup({}) require("lspconfig").vimls.setup({ cmd = { "vim-language-server", "--stdio" }, filetypes = { "vim" }, @@ -205,8 +206,30 @@ require("lspconfig").bashls.setup({ require("lspconfig").html.setup({ capabilities = capabilities, }) -require("lspconfig").nil_ls.setup({ +require("lspconfig").nixd.setup({ + cmd = { "nixd", "--semantic-tokens=true", "--inlay-hints=false" }, + formatting = { + command = { "nixfmt" }, + }, capabilities = capabilities, + settings = { + nixd = { + nixpkgs = { + expr = "import {}", + }, + options = { + nixos = { + expr = '(builtins.getFlake "/home/meyer/nixos").nixosConfigurations.nixd.options', + }, + home_manager = { + expr = '(builtins.getFlake "/home/meyer/nixos").homeConfigurations.nixd.options', + }, + flake_parts = { + expr = 'let flake = builtins.getFlake ("/home/meyer/nixos"); in flake.debug.options // flake.currentSystem.options', + }, + }, + }, + }, }) require("lspconfig").jsonls.setup({ capabilities = capabilities, diff --git a/lua/setupnoice.lua b/lua/setupnoice.lua index 944fb3c..a05fb1f 100644 --- a/lua/setupnoice.lua +++ b/lua/setupnoice.lua @@ -1,14 +1,115 @@ -local logged = false; -local function test(a, b) - if logged then return end - vim.notify(vim.inspect(a)) - vim.notify(vim.inspect(b)) - logged = true +-- this whole file is complete fucking horror +local logged = false + +-- searches the list of keymaps (arr) +-- this can be gotten from vim.api.nvim_get_keymap(mode) +-- or vim.api.nvim_buf_get_keymap(buf, mode) +-- to see if it has any mappings with (lhs) +local function hasLHS(arr, lhs) + for key, value in pairs(arr) do + if value.lhs == lhs then + return value + end + end + return nil end +-- returns +local function makeOldRightClick() + -- try buffer local mappings + local toRet = hasLHS(vim.api.nvim_buf_get_keymap(0, ""), "") + if toRet ~= nil then + return toRet + end + toRet = hasLHS(vim.api.nvim_get_keymap(""), "") + if toRet == nil then + return function() end + elseif toRet.callback ~= nil then + return toRet.callback + elseif toRet.rhs ~= nil then + return toRet.rhs + else + error("how") + end +end +local oldRightClick = nil +local function createOldRightClick() + if oldRightClick == nil then + oldRightClick = makeOldRightClick() + end +end +---@generic T +---@param tbl table +---@param el T +---@return number | -1 +local function indexOf(tbl, el) + for index, value in ipairs(tbl) do + if value == el then + return index + end + end + return -1 +end +local windows = {} +local openWindowCount = 0 +---@param rhs string +local function runTextMapping(rhs) + vim.keymap.set("", "(NotifyTempRightClickMap)", rhs) + vim.cmd([[exec "norm \(NotifyTempRightClickMap)"]]) + vim.api.nvim_del_keymap("", "(NotifyTempRightClickMap)") +end +local function runPassthruMapping() + if type(oldRightClick) == "function" then + oldRightClick() + elseif type(oldRightClick) == "string" then + runTextMapping(oldRightClick) + else + error("Unknown Type") + end +end +local function makeCloseMap(windowHandle) + openWindowCount = openWindowCount + 1 + table.insert(windows, windowHandle) + if openWindowCount == 1 then + createOldRightClick() + vim.keymap.set("", "", function() + for _, v in pairs(windows) do + local _pos = vim.api.nvim_win_get_position(v) + local min_y = _pos[1] + local min_x = _pos[2] + local max_x = vim.api.nvim_win_get_width(v) + min_x + local max_y = vim.api.nvim_win_get_height(v) + min_y + local pos = vim.fn.getmousepos() + local x = pos.screencol + local y = pos.screenrow + -- vim.notify(string.format("%s, %s, %s, %s, %s, %s", min_x, max_x, min_y, max_y, x, y)) + if (x >= min_x and x <= max_x) and (y >= min_y and y <= max_y) then + vim.api.nvim_win_close(v, true) + return + end + end + runPassthruMapping() + end) + end +end +local function removeCloseMap(winHandle) + openWindowCount = openWindowCount - 1 + local index = indexOf(windows, winHandle) + if index ~= -1 then + table.remove(windows, index) + else + vim.notify("how the fuck") + end + if openWindowCount == 0 then + vim.api.nvim_del_keymap("", "") + oldRightClick = nil + end +end + require("notify").setup({ max_width = 65, max_height = 7, - on_open = test + on_open = makeCloseMap, + on_close = removeCloseMap, }) vim.notify = require("notify") require("noice").setup({