From f815679d89e58811004b56efa7e3a475d49d3904 Mon Sep 17 00:00:00 2001 From: Christian Nieves Date: Sat, 11 Jan 2025 20:36:39 -0600 Subject: [PATCH] blink stuff --- config/.config/nvim/lazy-lock.json | 2 +- vim/.vim/lua/plugins/blink.lua | 242 +++++++++++--------- vim/.vim/lua/plugins/cmp.lua | 350 ++++++++++++++--------------- vim/.vim/lua/plugins/lsp.lua | 40 ---- vim/.vim/lua/utils.lua | 144 ++++++------ 5 files changed, 384 insertions(+), 394 deletions(-) diff --git a/config/.config/nvim/lazy-lock.json b/config/.config/nvim/lazy-lock.json index 724dac1..eed6eea 100644 --- a/config/.config/nvim/lazy-lock.json +++ b/config/.config/nvim/lazy-lock.json @@ -1,3 +1,3 @@ { - "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" } + "lazy.nvim": { "branch": "main", "commit": "d8f26efd456190241afd1b0f5235fe6fdba13d4a" } } diff --git a/vim/.vim/lua/plugins/blink.lua b/vim/.vim/lua/plugins/blink.lua index 694d260..2513785 100644 --- a/vim/.vim/lua/plugins/blink.lua +++ b/vim/.vim/lua/plugins/blink.lua @@ -2,115 +2,145 @@ local use_google = require("utils").use_google local flags = require("utils").flags return { - { - "saghen/blink.compat", - -- use the latest release, via version = '*', if you also use the latest release for blink.cmp - version = "*", - -- lazy.nvim will automatically load the plugin when it's required by blink.cmp - lazy = true, - -- make sure to set opts so that lazy.nvim calls blink.compat's setup - opts = { - impersonate_nvim_cmp = use_google(), -- only cider needs this - }, - cond = not use_google(), - }, - { - "saghen/blink.cmp", - lazy = false, -- lazy loading handled internally - cond = flags.blink, - dependencies = { - "Exafunction/codeium.nvim", - "mikavilpas/blink-ripgrep.nvim", - "hrsh7th/cmp-cmdline", - -- "FelipeLema/cmp-async-path", - "chrisgrieser/cmp-nerdfont", - "hrsh7th/cmp-emoji", - "rafamadriz/friendly-snippets", -- optional: provides snippets for the snippet source - }, - version = "v0.*", -- use a release tag to download pre-built binaries - -- build = 'cargo build --release', + { + "saghen/blink.compat", + -- use the latest release, via version = '*', if you also use the latest release for blink.cmp + version = "*", + -- lazy.nvim will automatically load the plugin when it's required by blink.cmp + lazy = true, + -- make sure to set opts so that lazy.nvim calls blink.compat's setup + opts = { + impersonate_nvim_cmp = use_google(), -- only cider needs this + }, + cond = not use_google(), + }, + { + "saghen/blink.cmp", + lazy = false, -- lazy loading handled internally + cond = flags.blink, + dependencies = { + "Exafunction/codeium.nvim", + "mikavilpas/blink-ripgrep.nvim", + "chrisgrieser/cmp-nerdfont", + "hrsh7th/cmp-emoji", + "rafamadriz/friendly-snippets", -- optional: provides snippets for the snippet source + }, + version = "v0.*", -- use a release tag to download pre-built binaries + -- build = 'cargo build --release', - ---@module 'blink.cmp' - ---@type blink.cmp.Config - opts = { - keymap = { - [""] = { "show", "show_documentation", "hide_documentation" }, - [""] = { "hide", "fallback" }, - [""] = { "accept", "fallback" }, + ---@module 'blink.cmp' + ---@type blink.cmp.Config + opts = { + keymap = { + [""] = { "show", "show_documentation", "hide_documentation" }, + [""] = { "hide", "fallback" }, + [""] = { "accept", "fallback" }, - [""] = { "select_next", "snippet_forward", "accept", "fallback" }, - [""] = { "select_prev", "snippet_backward", "fallback" }, + [""] = { "select_next", "snippet_forward", "accept", "fallback" }, + [""] = { "select_prev", "snippet_backward", "fallback" }, - [""] = { "select_prev", "fallback" }, - [""] = { "select_next", "fallback" }, + [""] = { "select_prev", "fallback" }, + [""] = { "select_next", "fallback" }, - [""] = { "scroll_documentation_up", "fallback" }, - [""] = { "scroll_documentation_down", "fallback" }, - }, - sources = { - default = function(ctx) - local providerToEnable = { - "lsp", - "path", - "crates", - "snippets", - "ripgrep", - "emoji", - "nerdfont", - "buffer", - } - if use_google() then - table.insert(providerToEnable, "nvim_ciderlsp") - table.insert(providerToEnable, "buganizer") - else - table.insert(providerToEnable, "codeium") - end - vim.notify("BOOOOOOP") - vim.notify(vim.inspect(providerToEnable)) - return providerToEnable - end, - }, - providers = { - -- dont show LuaLS require statements when lazydev has items - lsp = { fallback_for = { "lazydev" } }, - lazydev = { name = "LazyDev", module = "lazydev.integrations.blink" }, - ripgrep = { - module = "blink-ripgrep", - name = "Ripgrep", - -- the options below are optional, some default values are shown - ---@module "blink-ripgrep" - ---@type blink-ripgrep.Options - opts = { - prefix_min_len = 3, - context_size = 5, - max_filesize = "1M", - additional_rg_options = {}, - }, - }, - nvim_ciderlsp = { - name = "nvim_ciderlsp", - module = "blink.compat.source", - }, - buganizer = { - name = "nvim_buganizer", - module = "blink.compat.source", - }, - codeium = { - name = "codeium", - module = "blink.compat.source", - }, - }, - -- experimental signature help support - signature = { enabled = true }, - completion = { - trigger = { - show_on_x_blocked_trigger_characters = { "'", '"', "(", "{" }, - }, - }, - }, + [""] = { "scroll_documentation_up", "fallback" }, + [""] = { "scroll_documentation_down", "fallback" }, + }, + sources = { + default = function(ctx) + local providerToEnable = { + "lsp", + "path", + "snippets", + "ripgrep", + "emoji", + "nerdfont", + "buffer", + } + if use_google() then + table.insert(providerToEnable, "nvim_ciderlsp") + table.insert(providerToEnable, "buganizer") + else + table.insert(providerToEnable, "codeium") + end + return providerToEnable + end, + providers = { + -- dont show LuaLS require statements when lazydev has items + lazydev = { name = "LazyDev", module = "lazydev.integrations.blink", fallbacks = { "lsp" } }, + ripgrep = { + module = "blink-ripgrep", + name = "Ripgrep", + -- the options below are optional, some default values are shown + ---@module "blink-ripgrep" + ---@type blink-ripgrep.Options + opts = { + prefix_min_len = 3, + context_size = 5, + max_filesize = "1M", + additional_rg_options = {}, + }, + }, + nvim_ciderlsp = { + name = "nvim_ciderlsp", + module = "blink.compat.source", + }, + buganizer = { + name = "nvim_buganizer", + module = "blink.compat.source", + }, + codeium = { + name = "codeium", + module = "blink.compat.source", + }, + emoji = { + name = "emoji", + module = "blink.compat.source", + }, + nerdfont = { + name = "nerdfont", + module = "blink.compat.source", + }, + }, + }, + -- experimental signature help support + signature = { enabled = true }, + completion = { + menu = { + draw = { + components = { + kind_icon = { + ellipsis = false, + text = function(ctx) + local kind_icon, _, _ = require("mini.icons").get("lsp", ctx.kind) + return kind_icon + end, + -- Optionally, you may also use the highlights from mini.icons + highlight = function(ctx) + local _, hl, _ = require("mini.icons").get("lsp", ctx.kind) + return hl + end, + }, + }, + }, + }, + list = { + selection = { + preselect = function(ctx) + return ctx.mode ~= "cmdline" + end, + auto_insert = function(ctx) + return ctx.mode ~= "cmdline" + end, + }, + }, + trigger = { + show_on_x_blocked_trigger_characters = { "'", '"', "(", "{" }, + }, + }, + }, - -- allows extending the providers array elsewhere in your config - -- without having to redefine it - opts_extend = { "sources.default" }, - }, + -- allows extending the providers array elsewhere in your config + -- without having to redefine it + opts_extend = { "sources.default" }, + }, } diff --git a/vim/.vim/lua/plugins/cmp.lua b/vim/.vim/lua/plugins/cmp.lua index 1b73c2c..7fc0c2b 100644 --- a/vim/.vim/lua/plugins/cmp.lua +++ b/vim/.vim/lua/plugins/cmp.lua @@ -1,192 +1,192 @@ -local use_google = require("utils").use_google +local use_google = require("utils").use_googlecmp local flags = require("utils").flags return { - { - "hrsh7th/nvim-cmp", - event = { "InsertEnter", "CmdlineEnter" }, - cond = use_google(), - dependencies = { - "Exafunction/codeium.nvim", - "FelipeLema/cmp-async-path", - "amarakon/nvim-cmp-buffer-lines", - "chrisgrieser/cmp-nerdfont", - "dmitmel/cmp-cmdline-history", - "f3fora/cmp-spell", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-calc", - "hrsh7th/cmp-cmdline", - "hrsh7th/cmp-emoji", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-nvim-lsp-document-symbol", - -- "hrsh7th/cmp-nvim-lsp-signature-help", - "hrsh7th/cmp-nvim-lua", - "lukas-reineke/cmp-under-comparator", - "onsails/lspkind.nvim", - "ray-x/cmp-treesitter", - }, - config = function() - vim.opt.shortmess:append("c") - vim.opt.completeopt = { "menu", "menuone", "noselect" } + { + "hrsh7th/nvim-cmp", + event = { "InsertEnter", "CmdlineEnter" }, + cond = not flags.blink, + dependencies = { + "Exafunction/codeium.nvim", + "FelipeLema/cmp-async-path", + "amarakon/nvim-cmp-buffer-lines", + "chrisgrieser/cmp-nerdfont", + "dmitmel/cmp-cmdline-history", + "f3fora/cmp-spell", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-calc", + "hrsh7th/cmp-cmdline", + "hrsh7th/cmp-emoji", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-nvim-lsp-document-symbol", + -- "hrsh7th/cmp-nvim-lsp-signature-help", + "hrsh7th/cmp-nvim-lua", + "lukas-reineke/cmp-under-comparator", + "onsails/lspkind.nvim", + "ray-x/cmp-treesitter", + }, + config = function() + vim.opt.shortmess:append("c") + vim.opt.completeopt = { "menu", "menuone", "noselect" } - local cmp = require("cmp") - local luasnip = require("luasnip") + local cmp = require("cmp") + local luasnip = require("luasnip") - local compare = cmp.config.compare + local compare = cmp.config.compare - local conditionalSources = {} + local conditionalSources = {} - if use_google() then - table.insert(conditionalSources, { name = "nvim_ciderlsp", priority = 8 }) - table.insert(conditionalSources, { name = "buganizer", option = { notifications_enabled = true } }) - else - table.insert(conditionalSources, { name = "codeium", priority = 8 }) - end + if use_google() then + table.insert(conditionalSources, { name = "nvim_ciderlsp", priority = 8 }) + table.insert(conditionalSources, { name = "buganizer", option = { notifications_enabled = true } }) + else + table.insert(conditionalSources, { name = "codeium", priority = 8 }) + end - local lspkind = require("lspkind") - lspkind.init() + local lspkind = require("lspkind") + lspkind.init() - cmp.setup.filetype("txt", { - enabled = false, - }) - -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline({ "/", "?" }, { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = "treesitter" }, - { name = "buffer" }, - }), - }) + cmp.setup.filetype("txt", { + enabled = false, + }) + -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({ "/", "?" }, { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "treesitter" }, + { name = "buffer" }, + }), + }) - -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - -- { name = "nvim_lsp_signature_help", priority = 9 }, - { name = "async_path" }, - { name = "cmdline", option = { ignore_cmds = { "edit", "write", "tabedit" } } }, - }), - }) + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + -- { name = "nvim_lsp_signature_help", priority = 9 }, + { name = "async_path" }, + { name = "cmdline", option = { ignore_cmds = { "edit", "write", "tabedit" } } }, + }), + }) - cmp.setup({ - preselect = cmp.PreselectMode.None, - performance = { - -- debounce = 60, - -- throttle = 30, - fetching_timeout = 300, - -- confirm_resolve_timeout = 80, - -- async_budget = 1, - -- max_view_entries = 200, - }, - sources = cmp.config.sources( - require("utils").TableConcat(conditionalSources, { - -- { name = "nvim_lsp_signature_help", priority = 9 }, - -- Conditional sources injected here. - { name = "luasnip", priority = 7 }, - { name = "nvim_lsp", priority = 6 }, - { name = "async_path" }, - { name = "crates" }, - { name = "calc" }, - }), - { -- symbols/icons group - { name = "nerdfont" }, - { name = "emoji" }, - }, - { -- fallback - { name = "treesitter" }, - { name = "buffer" }, - } - ), + cmp.setup({ + preselect = cmp.PreselectMode.None, + performance = { + -- debounce = 60, + -- throttle = 30, + fetching_timeout = 300, + -- confirm_resolve_timeout = 80, + -- async_budget = 1, + -- max_view_entries = 200, + }, + sources = cmp.config.sources( + require("utils").TableConcat(conditionalSources, { + -- { name = "nvim_lsp_signature_help", priority = 9 }, + -- Conditional sources injected here. + { name = "luasnip", priority = 7 }, + { name = "nvim_lsp", priority = 6 }, + { name = "async_path" }, + { name = "crates" }, + { name = "calc" }, + }), + { -- symbols/icons group + { name = "nerdfont" }, + { name = "emoji" }, + }, + { -- fallback + { name = "treesitter" }, + { name = "buffer" }, + } + ), - sorting = { - comparators = { - -- compare.score_offset, -- not good at all - compare.priority, - compare.score, -- based on : score = score + ((#sources - (source_index - 1)) * sorting.priority_weight) - compare.recently_used, - compare.offset, - compare.order, - -- compare.exact, - compare.kind, - -- compare.length, -- useless - }, - }, - formatting = { - format = lspkind.cmp_format({ - menu = { - async_path = " path", - buffer = " Buf", - cmdline = " cmd", - codeium = "󰚩 Codeium", - crates = " rust", - luasnip = " snip", - buganizer = " Buganizer", - nerdfont = "󰊪 nerdfont", - nvim_ciderlsp = "󰚩 Cider", - nvim_lsp_signature_help = "󰊕", - nvim_lsp = " LSP", - nvim_lua = " lua", - treesitter = "󰙅 ts", - }, - }), - }, + sorting = { + comparators = { + -- compare.score_offset, -- not good at all + compare.priority, + compare.score, -- based on : score = score + ((#sources - (source_index - 1)) * sorting.priority_weight) + compare.recently_used, + compare.offset, + compare.order, + -- compare.exact, + compare.kind, + -- compare.length, -- useless + }, + }, + formatting = { + format = lspkind.cmp_format({ + menu = { + async_path = " path", + buffer = " Buf", + cmdline = " cmd", + codeium = "󰚩 Codeium", + crates = " rust", + luasnip = " snip", + buganizer = " Buganizer", + nerdfont = "󰊪 nerdfont", + nvim_ciderlsp = "󰚩 Cider", + nvim_lsp_signature_help = "󰊕", + nvim_lsp = " LSP", + nvim_lua = " lua", + treesitter = "󰙅 ts", + }, + }), + }, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, - mapping = { - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.close(), - [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - if luasnip.expandable() then - luasnip.expand() - else - cmp.confirm({ - select = true, - }) - end - else - fallback() - end - end), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - else - fallback() - end - end, { "i", "s" }), + mapping = { + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.close(), + [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + if luasnip.expandable() then + luasnip.expand() + else + cmp.confirm({ + select = true, + }) + end + else + fallback() + end + end), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - else - fallback() -- The fallback function sends a already mapped key. In this case, it's probably ``. - end - end), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() -- The fallback function sends a already mapped key. In this case, it's probably ``. + end + end), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - else - fallback() -- The fallback function sends a already mapped key. In this case, it's probably ``. - end - end), - }, - }) - end, - }, + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() -- The fallback function sends a already mapped key. In this case, it's probably ``. + end + end), + }, + }) + end, + }, } diff --git a/vim/.vim/lua/plugins/lsp.lua b/vim/.vim/lua/plugins/lsp.lua index b2eab92..d95dec1 100644 --- a/vim/.vim/lua/plugins/lsp.lua +++ b/vim/.vim/lua/plugins/lsp.lua @@ -73,45 +73,6 @@ return { }) -- Run gofmt + goimports on save -<<<<<<< HEAD - local format_sync_grp = vim.api.nvim_create_augroup("goimports", {}) - vim.api.nvim_create_autocmd("BufWritePre", { - pattern = "*.go", - callback = function() - require("go.format").goimports() - end, - group = format_sync_grp, - }) - end, - ft = { "go", "gomod" }, - build = ':lua require("go.install").update_all_sync()', -- if you need to install/update all binaries - }, - { - "neovim/nvim-lspconfig", - dependencies = { - "hrsh7th/nvim-cmp", - "nvim-lua/lsp-status.nvim", - "VonHeikemen/lsp-zero.nvim", - }, - keys = { - { "F", ":lua vim.lsp.buf.format()" }, - { "rn", ":lua vim.lsp.buf.rename()" }, - { "L", ":lua vim.lsp.buf.hover()" }, - { "gr", ":Telescope lsp_references" }, - { "gd", ":lua vim.lsp.buf.definition()" }, - -- { "gd", "Telescope lsp_definitions" }, - { "gD", ":tab split | lua vim.lsp.buf.definition()" }, - { "gi", ":lua vim.lsp.buf.implementation()" }, - { "gI", ":lua vim.lsp.buf.implementation()" }, - { "gR", ":lua vim.lsp.buf.references()" }, - { "gt", ":lua vim.lsp.buf.type_definition()" }, - { "", ":lua vim.lsp.buf.signature_help()" }, - { "", ":lua vim.lsp.buf.signature_help()", mode = "i" }, - }, - config = function() - local lsp_status = require("lsp-status") - lsp_status.register_progress() -======= local format_sync_grp = vim.api.nvim_create_augroup("goimports", {}) vim.api.nvim_create_autocmd("BufWritePre", { pattern = "*.go", @@ -149,7 +110,6 @@ return { config = function() local lsp_status = require("lsp-status") lsp_status.register_progress() ->>>>>>> cc84d4d (i dont even know) local capabilities = flags.blink and require("blink.cmp").get_lsp_capabilities(vim.lsp.protocol.make_client_capabilities()) diff --git a/vim/.vim/lua/utils.lua b/vim/.vim/lua/utils.lua index 725323c..b3da80c 100644 --- a/vim/.vim/lua/utils.lua +++ b/vim/.vim/lua/utils.lua @@ -1,100 +1,100 @@ local M = { - use_google_cache = nil, - flags = {}, + use_google_cache = nil, + flags = { blink = true }, } function M.exec(command, args) - local Job = require("plenary.job") - local job = Job:new({ - command = command, - args = args, - }) - job:sync() - job:wait() - return job:result() + local Job = require("plenary.job") + local job = Job:new({ + command = command, + args = args, + }) + job:sync() + job:wait() + return job:result() end function M.map(mode, lhs, rhs, opts) - local options = { noremap = true } - if opts then - options = vim.tbl_extend("force", options, opts) - end - -- vim.api.nvim_set_keymap(mode, lhs, rhs, options) - vim.keymap.set(mode, lhs, rhs, options) + local options = { noremap = true } + if opts then + options = vim.tbl_extend("force", options, opts) + end + -- vim.api.nvim_set_keymap(mode, lhs, rhs, options) + vim.keymap.set(mode, lhs, rhs, options) end function M.use_google() - if M.use_google_cache == nil then - M.use_google_cache = M.file_exists(os.getenv("HOME") .. "/use_google") - end - return M.use_google_cache + if M.use_google_cache == nil then + M.use_google_cache = M.file_exists(os.getenv("HOME") .. "/use_google") + end + return M.use_google_cache end function M.file_exists(name) - local f = io.open(name, "r") - if f ~= nil then - io.close(f) - return true - else - return false - end + local f = io.open(name, "r") + if f ~= nil then + io.close(f) + return true + else + return false + end end function M.dump(o) - if type(o) == "table" then - local s = "{ " - for k, v in pairs(o) do - if type(k) ~= "number" then - k = '"' .. k .. '"' - end - s = s .. "[" .. k .. "] = " .. M.dump(v) .. "," - end - return s .. "} " - else - return tostring(o) - end + if type(o) == "table" then + local s = "{ " + for k, v in pairs(o) do + if type(k) ~= "number" then + k = '"' .. k .. '"' + end + s = s .. "[" .. k .. "] = " .. M.dump(v) .. "," + end + return s .. "} " + else + return tostring(o) + end end function M.tprint(tbl, indent) - if not indent then - indent = 0 - end - local toprint = string.rep(" ", indent) .. "{\r\n" - indent = indent + 2 - for k, v in pairs(tbl) do - toprint = toprint .. string.rep(" ", indent) - if type(k) == "number" then - toprint = toprint .. "[" .. k .. "] = " - elseif type(k) == "string" then - toprint = toprint .. k .. "= " - end - if type(v) == "number" then - toprint = toprint .. v .. ",\r\n" - elseif type(v) == "string" then - toprint = toprint .. '"' .. v .. '",\r\n' - elseif type(v) == "table" then - toprint = toprint .. M.tprint(v, indent + 2) .. ",\r\n" - else - toprint = toprint .. '"' .. tostring(v) .. '",\r\n' - end - end - toprint = toprint .. string.rep(" ", indent - 2) .. "}" - return toprint + if not indent then + indent = 0 + end + local toprint = string.rep(" ", indent) .. "{\r\n" + indent = indent + 2 + for k, v in pairs(tbl) do + toprint = toprint .. string.rep(" ", indent) + if type(k) == "number" then + toprint = toprint .. "[" .. k .. "] = " + elseif type(k) == "string" then + toprint = toprint .. k .. "= " + end + if type(v) == "number" then + toprint = toprint .. v .. ",\r\n" + elseif type(v) == "string" then + toprint = toprint .. '"' .. v .. '",\r\n' + elseif type(v) == "table" then + toprint = toprint .. M.tprint(v, indent + 2) .. ",\r\n" + else + toprint = toprint .. '"' .. tostring(v) .. '",\r\n' + end + end + toprint = toprint .. string.rep(" ", indent - 2) .. "}" + return toprint end function M.log(message) - local log_file_path = vim.fn.expand("$HOME/nvim.log") - local log_file = io.open(log_file_path, "a") - io.output(log_file) - io.write(message .. "\n") - io.close(log_file) + local log_file_path = vim.fn.expand("$HOME/nvim.log") + local log_file = io.open(log_file_path, "a") + io.output(log_file) + io.write(message .. "\n") + io.close(log_file) end function M.TableConcat(t1, t2) - for i = 1, #t2 do - t1[#t1 + 1] = t2[i] - end - return t1 + for i = 1, #t2 do + t1[#t1 + 1] = t2[i] + end + return t1 end return M