nvim-old
This commit is contained in:
parent
dbba54cfd8
commit
6380f390ea
26 changed files with 2704 additions and 0 deletions
24
nvim-old/lua/config/coq.lua
Normal file
24
nvim-old/lua/config/coq.lua
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
local coq = require "coq"
|
||||
coq.Now() -- Start coq
|
||||
|
||||
-- 3party sources
|
||||
require "coq_3p" {
|
||||
{ src = "nvimlua", short_name = "nLUA", conf_only = false }, -- Lua
|
||||
{ src = "bc", short_name = "MATH", precision = 6 }, -- Calculator
|
||||
{ src = "cow", trigger = "!cow" }, -- cow command
|
||||
{ src = "figlet", trigger = "!big" }, -- figlet command
|
||||
{
|
||||
src = "repl",
|
||||
sh = "zsh",
|
||||
shell = { p = "perl", n = "node" },
|
||||
max_lines = 99,
|
||||
deadline = 500,
|
||||
unsafe = { "rm", "poweroff", "mv" },
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
7
nvim-old/lua/hotkeys.lua
Normal file
7
nvim-old/lua/hotkeys.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
vim.g.mapleader = " "
|
||||
--mapleader = vim.g.mapleader
|
||||
local builtin = require('telescope.builtin')
|
||||
|
||||
vim.keymap.set("n", "<Leader>E", vim.cmd.Ex)
|
||||
-- vim.keymap.set('n', "<Leader>to", function() require('telescope.builtin').oldfiles() end)
|
||||
vim.keymap.set('n', "<Leader>to", builtin.oldfiles, {})
|
||||
174
nvim-old/lua/init.lua
Normal file
174
nvim-old/lua/init.lua
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
local inspect = require('inspect')
|
||||
require('ldraneyLua/sudoCheckSave')
|
||||
require('hotkeys')
|
||||
require('netrw/netrw')
|
||||
|
||||
--Global options
|
||||
vim.opt.list = true
|
||||
--vim.opt.listchars:append("space:⋅")
|
||||
vim.opt.listchars:append("eol:↴")
|
||||
|
||||
--require("indent_blankline").setup {
|
||||
--show_end_of_line = true,
|
||||
--space_char_blankline = " ",
|
||||
--}
|
||||
|
||||
--turn off automatic comments for newlines with o
|
||||
--https://www.reddit.com/r/neovim/comments/sqld76/stop_automatic_newline_continuation_of_comments/
|
||||
vim.cmd("autocmd BufEnter * set formatoptions-=cro")
|
||||
vim.cmd("autocmd BufEnter * setlocal formatoptions-=cro")
|
||||
|
||||
--local function tmux_split_even_horizontal()
|
||||
--local filepath = vim.fn.expand('%:p')
|
||||
--if filepath ~= '' then
|
||||
--local tmux_command = "tmux split-window -h -c '" .. vim.fn.expand('%:p:h') .. "' && tmux send-keys -t '.tmux.active-pane' 'nvim " .. vim.fn.shellescape(filepath) .. "' Enter && tmux select-layout even-horizontal"
|
||||
--vim.fn.system(tmux_command)
|
||||
--end
|
||||
--end
|
||||
|
||||
--vim.api.nvim_set_keymap('n', '<leader>th', ':lua tmux_split_even_horizontal()<CR>', { noremap = true, silent = true })
|
||||
|
||||
|
||||
--_G.tmux_split_even_horizontal = function()
|
||||
--local filepath = vim.fn.expand('%:p')
|
||||
--if filepath ~= '' then
|
||||
--local tmux_command = "tmux split-window -h -c '" .. vim.fn.expand('%:p:h') .. "' && tmux send-keys -t '.tmux.active-pane' 'nvim " .. vim.fn.shellescape(filepath) .. "' Enter && tmux select-layout even-horizontal"
|
||||
--vim.fn.system(tmux_command)
|
||||
--end
|
||||
--end
|
||||
|
||||
--_G.tmux_split_even_horizontal = function()
|
||||
--local filepath = vim.fn.expand('%:p')
|
||||
--if filepath ~= '' then
|
||||
--local tmux_command = "tmux split-window -h 'nvim'"
|
||||
--vim.fn.system(tmux_command)
|
||||
----print("Pane ID: " .. tmux_pane_id)
|
||||
--print("Filepath: " .. filepath)
|
||||
--end
|
||||
--end
|
||||
|
||||
_G.tmux_split_even_horizontal = function()
|
||||
local filepath = vim.fn.expand('%:p')
|
||||
if filepath ~= '' then
|
||||
local tmux_command = "tmux split-window -h 'nvim -n " .. filepath .. "'; select-layout even-horizontal"
|
||||
vim.fn.system(tmux_command)
|
||||
print("Filepath: " .. filepath)
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_set_keymap('n', '<leader>th', ':lua _G.tmux_split_even_horizontal()<CR>', { noremap = true, silent = true })
|
||||
|
||||
|
||||
|
||||
--
|
||||
--
|
||||
--
|
||||
--require('lspconfig').pyright.setup{}
|
||||
--require('lspconfig').bashls.setup{}
|
||||
--require'lspconfig'.pylsp.setup{}
|
||||
---- Mappings.
|
||||
---- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
--local opts = { noremap=true, silent=true }
|
||||
--vim.api.nvim_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
|
||||
--vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
|
||||
--vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
|
||||
--vim.api.nvim_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
|
||||
|
||||
---- Use an on_attach function to only map the following keys
|
||||
---- after the language server attaches to the current buffer
|
||||
--local on_attach = function(client, bufnr)
|
||||
---- Enable completion triggered by <c-x><c-o>
|
||||
--vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
---- Mappings.
|
||||
---- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
--vim.api.nvim_set_keymap("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", { noremap = true })
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||
--end
|
||||
|
||||
---- Use a loop to conveniently call 'setup' on multiple servers and
|
||||
---- map buffer local keybindings when the language server attaches
|
||||
--local servers = { 'pyright', 'rust_analyzer', 'tsserver' }
|
||||
--for _, lsp in pairs(servers) do
|
||||
--require('lspconfig')[lsp].setup {
|
||||
--on_attach = on_attach,
|
||||
--flags = {
|
||||
---- This will be the default in neovim 0.7+
|
||||
--debounce_text_changes = 150,
|
||||
--}
|
||||
--}
|
||||
--end
|
||||
---- Add additional capabilities supported by nvim-cmp
|
||||
--local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
--capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
||||
|
||||
--local lspconfig = require('lspconfig')
|
||||
|
||||
---- Enable some language servers with the additional completion capabilities offered by nvim-cmp
|
||||
--local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver' }
|
||||
--for _, lsp in ipairs(servers) do
|
||||
--lspconfig[lsp].setup {
|
||||
---- on_attach = my_custom_on_attach,
|
||||
--capabilities = capabilities,
|
||||
--}
|
||||
--end
|
||||
|
||||
---- luasnip setup
|
||||
--local luasnip = require 'luasnip'
|
||||
|
||||
---- nvim-cmp setup
|
||||
--local cmp = require 'cmp'
|
||||
--cmp.setup {
|
||||
--snippet = {
|
||||
--expand = function(args)
|
||||
--require('luasnip').lsp_expand(args.body)
|
||||
--end,
|
||||
--},
|
||||
--mapping = {
|
||||
--['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
--['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
--['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
--['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
--['<C-Space>'] = cmp.mapping.complete(),
|
||||
--['<C-e>'] = cmp.mapping.close(),
|
||||
--['<CR>'] = cmp.mapping.confirm {
|
||||
--behavior = cmp.ConfirmBehavior.Replace,
|
||||
--select = true,
|
||||
--},
|
||||
--['<Tab>'] = function(fallback)
|
||||
--if cmp.visible() then
|
||||
--cmp.select_next_item()
|
||||
--elseif luasnip.expand_or_jumpable() then
|
||||
--luasnip.expand_or_jump()
|
||||
--else
|
||||
--fallback()
|
||||
--end
|
||||
--end,
|
||||
--['<S-Tab>'] = function(fallback)
|
||||
--if cmp.visible() then
|
||||
--cmp.select_prev_item()
|
||||
--elseif luasnip.jumpable(-1) then
|
||||
--luasnip.jump(-1)
|
||||
--else
|
||||
--fallback()
|
||||
--end
|
||||
--end,
|
||||
--},
|
||||
--sources = {
|
||||
--{ name = 'nvim_lsp' },
|
||||
--{ name = 'luasnip' },
|
||||
--},
|
||||
--}
|
||||
|
||||
337
nvim-old/lua/inspect.lua
Normal file
337
nvim-old/lua/inspect.lua
Normal file
|
|
@ -0,0 +1,337 @@
|
|||
local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local math = _tl_compat and _tl_compat.math or math; local string = _tl_compat and _tl_compat.string or string; local table = _tl_compat and _tl_compat.table or table
|
||||
local inspect = {Options = {}, }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
inspect._VERSION = 'inspect.lua 3.1.0'
|
||||
inspect._URL = 'http://github.com/kikito/inspect.lua'
|
||||
inspect._DESCRIPTION = 'human-readable representations of tables'
|
||||
inspect._LICENSE = [[
|
||||
MIT LICENSE
|
||||
|
||||
Copyright (c) 2022 Enrique García Cota
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
]]
|
||||
inspect.KEY = setmetatable({}, { __tostring = function() return 'inspect.KEY' end })
|
||||
inspect.METATABLE = setmetatable({}, { __tostring = function() return 'inspect.METATABLE' end })
|
||||
|
||||
local tostring = tostring
|
||||
local rep = string.rep
|
||||
local match = string.match
|
||||
local char = string.char
|
||||
local gsub = string.gsub
|
||||
local fmt = string.format
|
||||
|
||||
local function rawpairs(t)
|
||||
return next, t, nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function smartQuote(str)
|
||||
if match(str, '"') and not match(str, "'") then
|
||||
return "'" .. str .. "'"
|
||||
end
|
||||
return '"' .. gsub(str, '"', '\\"') .. '"'
|
||||
end
|
||||
|
||||
|
||||
local shortControlCharEscapes = {
|
||||
["\a"] = "\\a", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n",
|
||||
["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v", ["\127"] = "\\127",
|
||||
}
|
||||
local longControlCharEscapes = { ["\127"] = "\127" }
|
||||
for i = 0, 31 do
|
||||
local ch = char(i)
|
||||
if not shortControlCharEscapes[ch] then
|
||||
shortControlCharEscapes[ch] = "\\" .. i
|
||||
longControlCharEscapes[ch] = fmt("\\%03d", i)
|
||||
end
|
||||
end
|
||||
|
||||
local function escape(str)
|
||||
return (gsub(gsub(gsub(str, "\\", "\\\\"),
|
||||
"(%c)%f[0-9]", longControlCharEscapes),
|
||||
"%c", shortControlCharEscapes))
|
||||
end
|
||||
|
||||
local function isIdentifier(str)
|
||||
return type(str) == "string" and not not str:match("^[_%a][_%a%d]*$")
|
||||
end
|
||||
|
||||
local flr = math.floor
|
||||
local function isSequenceKey(k, sequenceLength)
|
||||
return type(k) == "number" and
|
||||
flr(k) == k and
|
||||
1 <= (k) and
|
||||
k <= sequenceLength
|
||||
end
|
||||
|
||||
local defaultTypeOrders = {
|
||||
['number'] = 1, ['boolean'] = 2, ['string'] = 3, ['table'] = 4,
|
||||
['function'] = 5, ['userdata'] = 6, ['thread'] = 7,
|
||||
}
|
||||
|
||||
local function sortKeys(a, b)
|
||||
local ta, tb = type(a), type(b)
|
||||
|
||||
|
||||
if ta == tb and (ta == 'string' or ta == 'number') then
|
||||
return (a) < (b)
|
||||
end
|
||||
|
||||
local dta = defaultTypeOrders[ta] or 100
|
||||
local dtb = defaultTypeOrders[tb] or 100
|
||||
|
||||
|
||||
return dta == dtb and ta < tb or dta < dtb
|
||||
end
|
||||
|
||||
local function getKeys(t)
|
||||
|
||||
local seqLen = 1
|
||||
while rawget(t, seqLen) ~= nil do
|
||||
seqLen = seqLen + 1
|
||||
end
|
||||
seqLen = seqLen - 1
|
||||
|
||||
local keys, keysLen = {}, 0
|
||||
for k in rawpairs(t) do
|
||||
if not isSequenceKey(k, seqLen) then
|
||||
keysLen = keysLen + 1
|
||||
keys[keysLen] = k
|
||||
end
|
||||
end
|
||||
table.sort(keys, sortKeys)
|
||||
return keys, keysLen, seqLen
|
||||
end
|
||||
|
||||
local function countCycles(x, cycles)
|
||||
if type(x) == "table" then
|
||||
if cycles[x] then
|
||||
cycles[x] = cycles[x] + 1
|
||||
else
|
||||
cycles[x] = 1
|
||||
for k, v in rawpairs(x) do
|
||||
countCycles(k, cycles)
|
||||
countCycles(v, cycles)
|
||||
end
|
||||
countCycles(getmetatable(x), cycles)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function makePath(path, a, b)
|
||||
local newPath = {}
|
||||
local len = #path
|
||||
for i = 1, len do newPath[i] = path[i] end
|
||||
|
||||
newPath[len + 1] = a
|
||||
newPath[len + 2] = b
|
||||
|
||||
return newPath
|
||||
end
|
||||
|
||||
|
||||
local function processRecursive(process,
|
||||
item,
|
||||
path,
|
||||
visited)
|
||||
if item == nil then return nil end
|
||||
if visited[item] then return visited[item] end
|
||||
|
||||
local processed = process(item, path)
|
||||
if type(processed) == "table" then
|
||||
local processedCopy = {}
|
||||
visited[item] = processedCopy
|
||||
local processedKey
|
||||
|
||||
for k, v in rawpairs(processed) do
|
||||
processedKey = processRecursive(process, k, makePath(path, k, inspect.KEY), visited)
|
||||
if processedKey ~= nil then
|
||||
processedCopy[processedKey] = processRecursive(process, v, makePath(path, processedKey), visited)
|
||||
end
|
||||
end
|
||||
|
||||
local mt = processRecursive(process, getmetatable(processed), makePath(path, inspect.METATABLE), visited)
|
||||
if type(mt) ~= 'table' then mt = nil end
|
||||
setmetatable(processedCopy, mt)
|
||||
processed = processedCopy
|
||||
end
|
||||
return processed
|
||||
end
|
||||
|
||||
local function puts(buf, str)
|
||||
buf.n = buf.n + 1
|
||||
buf[buf.n] = str
|
||||
end
|
||||
|
||||
|
||||
|
||||
local Inspector = {}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local Inspector_mt = { __index = Inspector }
|
||||
|
||||
local function tabify(inspector)
|
||||
puts(inspector.buf, inspector.newline .. rep(inspector.indent, inspector.level))
|
||||
end
|
||||
|
||||
function Inspector:getId(v)
|
||||
local id = self.ids[v]
|
||||
local ids = self.ids
|
||||
if not id then
|
||||
local tv = type(v)
|
||||
id = (ids[tv] or 0) + 1
|
||||
ids[v], ids[tv] = id, id
|
||||
end
|
||||
return tostring(id)
|
||||
end
|
||||
|
||||
function Inspector:putValue(v)
|
||||
local buf = self.buf
|
||||
local tv = type(v)
|
||||
if tv == 'string' then
|
||||
puts(buf, smartQuote(escape(v)))
|
||||
elseif tv == 'number' or tv == 'boolean' or tv == 'nil' or
|
||||
tv == 'cdata' or tv == 'ctype' then
|
||||
puts(buf, tostring(v))
|
||||
elseif tv == 'table' and not self.ids[v] then
|
||||
local t = v
|
||||
|
||||
if t == inspect.KEY or t == inspect.METATABLE then
|
||||
puts(buf, tostring(t))
|
||||
elseif self.level >= self.depth then
|
||||
puts(buf, '{...}')
|
||||
else
|
||||
if self.cycles[t] > 1 then puts(buf, fmt('<%d>', self:getId(t))) end
|
||||
|
||||
local keys, keysLen, seqLen = getKeys(t)
|
||||
|
||||
puts(buf, '{')
|
||||
self.level = self.level + 1
|
||||
|
||||
for i = 1, seqLen + keysLen do
|
||||
if i > 1 then puts(buf, ',') end
|
||||
if i <= seqLen then
|
||||
puts(buf, ' ')
|
||||
self:putValue(t[i])
|
||||
else
|
||||
local k = keys[i - seqLen]
|
||||
tabify(self)
|
||||
if isIdentifier(k) then
|
||||
puts(buf, k)
|
||||
else
|
||||
puts(buf, "[")
|
||||
self:putValue(k)
|
||||
puts(buf, "]")
|
||||
end
|
||||
puts(buf, ' = ')
|
||||
self:putValue(t[k])
|
||||
end
|
||||
end
|
||||
|
||||
local mt = getmetatable(t)
|
||||
if type(mt) == 'table' then
|
||||
if seqLen + keysLen > 0 then puts(buf, ',') end
|
||||
tabify(self)
|
||||
puts(buf, '<metatable> = ')
|
||||
self:putValue(mt)
|
||||
end
|
||||
|
||||
self.level = self.level - 1
|
||||
|
||||
if keysLen > 0 or type(mt) == 'table' then
|
||||
tabify(self)
|
||||
elseif seqLen > 0 then
|
||||
puts(buf, ' ')
|
||||
end
|
||||
|
||||
puts(buf, '}')
|
||||
end
|
||||
|
||||
else
|
||||
puts(buf, fmt('<%s %d>', tv, self:getId(v)))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function inspect.inspect(root, options)
|
||||
options = options or {}
|
||||
|
||||
local depth = options.depth or (math.huge)
|
||||
local newline = options.newline or '\n'
|
||||
local indent = options.indent or ' '
|
||||
local process = options.process
|
||||
|
||||
if process then
|
||||
root = processRecursive(process, root, {}, {})
|
||||
end
|
||||
|
||||
local cycles = {}
|
||||
countCycles(root, cycles)
|
||||
|
||||
local inspector = setmetatable({
|
||||
buf = { n = 0 },
|
||||
ids = {},
|
||||
cycles = cycles,
|
||||
depth = depth,
|
||||
level = 0,
|
||||
newline = newline,
|
||||
indent = indent,
|
||||
}, Inspector_mt)
|
||||
|
||||
inspector:putValue(root)
|
||||
|
||||
return table.concat(inspector.buf)
|
||||
end
|
||||
|
||||
setmetatable(inspect, {
|
||||
__call = function(_, root, options)
|
||||
return inspect.inspect(root, options)
|
||||
end,
|
||||
})
|
||||
|
||||
return inspect
|
||||
21
nvim-old/lua/ldraneyLua/sudoCheckSave.lua
Normal file
21
nvim-old/lua/ldraneyLua/sudoCheckSave.lua
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
-- **DEPRECATED**
|
||||
-- I had to do a bash script isntead, since the sudo thing didn't work
|
||||
--
|
||||
--
|
||||
--This function is useful so that I don't accidentally forget to use
|
||||
--"sudoedit" when editing VMShare.
|
||||
|
||||
--fullFilePath = vim.api.nvim_buf_get_name(0)
|
||||
---- check if filePath is VMShare. If it is, then force the save
|
||||
--function saveSudoCheck()
|
||||
--if (string.find(fullFilePath, "hgfs")) then
|
||||
--vim.cmd [[w !echo 'Asdfjkl7&' | sudo -S tee % >/dev/null]]
|
||||
--else
|
||||
--print("bye mom")
|
||||
--vim.cmd [[w]]
|
||||
--end
|
||||
--end
|
||||
|
||||
----set the keymap to s
|
||||
--local opts = { noremap=true, silent=true }
|
||||
--vim.api.nvim_set_keymap('n', '<C-s>', "<cmd>lua saveSudoCheck()<CR>", opts)
|
||||
47
nvim-old/lua/netrw/netrw.lua
Normal file
47
nvim-old/lua/netrw/netrw.lua
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
--The following code defines a function called ExitNetrw(), that checks if the current filetype is "netrw" (i.e. if you are currently in netrw), and if so, it changes the current working directory of the terminal to the directory of the current file or directory you are looking at in netrw, and then exits Neovim. If the current filetype is not "netrw", it will simply exit Neovim.
|
||||
|
||||
--It also maps the <C-q> key to call this function, so when you press <C-q> it will change the working directory and exit netrw, but if you're not in netrw it will exit Neovim directly.
|
||||
|
||||
--You can change the keybinding to your preferred key, just replace <C-q> with your preferred key.
|
||||
|
||||
local nvim_command = vim.api.nvim_command
|
||||
local nvim_call_function = vim.api.nvim_call_function
|
||||
|
||||
function ExitNetrw()
|
||||
if vim.bo.filetype == "netrw" then
|
||||
cwd = nvim_call_function("expand", {"%:p:h"})
|
||||
nvim_command("!cd " .. cwd)
|
||||
nvim_command("qa!")
|
||||
else
|
||||
nvim_command("qa!")
|
||||
end
|
||||
end
|
||||
-- need to remap this at some point
|
||||
--vim.cmd("nnoremap <silent> <C-q> :lua ExitNetrw()<CR>")
|
||||
|
||||
|
||||
|
||||
--exit neovim to the $NVIM_PWD
|
||||
--local nvim_set_option = vim.api.nvim_set_option
|
||||
--local os_getenv = os.getenv
|
||||
--
|
||||
|
||||
local os = require('os')
|
||||
local os_execute = os.execute
|
||||
local os_getenv = os.getenv
|
||||
|
||||
local pwd = os.getenv('PWD')
|
||||
--print(pwd)
|
||||
|
||||
--
|
||||
--
|
||||
--os_execute = vim.loop.os_execute
|
||||
--os_getenv = vim.loop.os_getenv
|
||||
|
||||
--vim.cmd("autocmd BufLeave * lua os_execute(\"cd \".. os_getenv(\"NVIM_PWD\"))")
|
||||
--local os = require('os')
|
||||
--local os_execute = os.execute
|
||||
--local os_getenv = os.getenv
|
||||
|
||||
--vim.cmd("autocmd BufLeave * lua os_execute("cd ".. os_getenv("NVIM_PWD"))")
|
||||
15
nvim-old/lua/plugins.lua
Normal file
15
nvim-old/lua/plugins.lua
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
use {
|
||||
"ms-jpq/coq_nvim",
|
||||
branch = "coq",
|
||||
event = "InsertEnter",
|
||||
opt = true,
|
||||
run = ":COQdeps",
|
||||
config = function()
|
||||
require("config.coq").setup()
|
||||
end,
|
||||
requires = {
|
||||
{ "ms-jpq/coq.artifacts", branch = "artifacts" },
|
||||
{ "ms-jpq/coq.thirdparty", branch = "3p", module = "coq_3p" },
|
||||
},
|
||||
disable = false,
|
||||
}
|
||||
28
nvim-old/lua/tests/test_tmux_split_even_horizontal.lua
Normal file
28
nvim-old/lua/tests/test_tmux_split_even_horizontal.lua
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
-- Mock setup
|
||||
_G.vim = {
|
||||
wo = {}, -- Window-scoped options
|
||||
bo = {}, -- Buffer-scoped options
|
||||
-- Add more fields as needed
|
||||
}
|
||||
|
||||
-- Example usage in a test case
|
||||
describe("My Neovim Function", function()
|
||||
it("does something", function()
|
||||
-- Test code that uses the mock `vim` object
|
||||
end)
|
||||
end)
|
||||
|
||||
local tmux_split_even_horizontal = require('tmux_split_even_horizontal')
|
||||
|
||||
describe("tmux_split_even_horizontal", function()
|
||||
local tmux_split_even_horizontal = require('tmux_split_even_horizontal')
|
||||
|
||||
it("should not throw errors", function()
|
||||
assert.has_no.errors(function()
|
||||
tmux_split_even_horizontal.tmux_split_even_horizontal()
|
||||
end)
|
||||
end)
|
||||
|
||||
-- Additional tests can be added here
|
||||
end)
|
||||
|
||||
35
nvim-old/lua/tests/test_toggle_rel_abs_numbers.lua
Normal file
35
nvim-old/lua/tests/test_toggle_rel_abs_numbers.lua
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
-- Mock setup
|
||||
_G.vim = {
|
||||
wo = {}, -- Window-scoped options
|
||||
bo = {}, -- Buffer-scoped options
|
||||
-- Add more fields as needed
|
||||
}
|
||||
|
||||
-- Example usage in a test case
|
||||
describe("My Neovim Function", function()
|
||||
it("does something", function()
|
||||
-- Test code that uses the mock `vim` object
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("toggle_line_numbers", function()
|
||||
local toggle_line_numbers
|
||||
|
||||
-- Mock setup before each test
|
||||
before_each(function()
|
||||
_G.vim = { wo = { relativenumber = false, number = false } }
|
||||
package.loaded['toggle_rel_abs_numbers'] = nil -- Unload the module
|
||||
toggle_line_numbers = require('toggle_rel_abs_numbers').toggle_line_numbers
|
||||
end)
|
||||
|
||||
it("toggles from relative to absolute line numbers", function()
|
||||
toggle_line_numbers()
|
||||
assert.is_true(vim.wo.relativenumber)
|
||||
assert.is_true(vim.wo.number)
|
||||
|
||||
toggle_line_numbers()
|
||||
assert.is_false(vim.wo.relativenumber)
|
||||
assert.is_true(vim.wo.number)
|
||||
end)
|
||||
end)
|
||||
|
||||
19
nvim-old/lua/tmux_split_even_horizontal.lua
Normal file
19
nvim-old/lua/tmux_split_even_horizontal.lua
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
local M = {}
|
||||
|
||||
function M.tmux_split_even_horizontal()
|
||||
local status, err = pcall(function()
|
||||
local filepath = vim.fn.expand('%:p')
|
||||
if filepath ~= '' then
|
||||
local tmux_command = "tmux split-window -h -c '" .. vim.fn.expand('%:p:h') ..
|
||||
"' && tmux send-keys -t '.tmux.active-pane' 'nvim " ..
|
||||
vim.fn.shellescape(filepath) .. "' Enter && tmux select-layout even-horizontal"
|
||||
vim.fn.system(tmux_command)
|
||||
end
|
||||
end)
|
||||
if not status then
|
||||
print("Error in tmux_split_even_horizontal: " .. err)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
23
nvim-old/lua/toggle_rel_abs_numbers.lua
Normal file
23
nvim-old/lua/toggle_rel_abs_numbers.lua
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
local M = {} -- Create a local table M to hold the module's functions
|
||||
|
||||
-- Function to toggle line numbers between relative and absolute
|
||||
function M.toggle_line_numbers()
|
||||
local status, err = pcall(function()
|
||||
-- Use pcall to catch any errors in the following block
|
||||
if vim.wo.relativenumber then
|
||||
-- If relative line numbers are on, turn them off and ensure absolute numbers are on
|
||||
vim.wo.relativenumber = false
|
||||
vim.wo.number = true
|
||||
else
|
||||
-- If relative line numbers are off, turn them on (absolute numbers stay on)
|
||||
vim.wo.relativenumber = true
|
||||
vim.wo.number = true
|
||||
end
|
||||
end)
|
||||
if not status then
|
||||
-- If there was an error, print it
|
||||
print("Error in toggle_line_numbers: " .. err)
|
||||
end
|
||||
end
|
||||
|
||||
return M -- Return the table containing the module's functions
|
||||
8
nvim-old/lua/utilities/help_menu_vert.lua
Normal file
8
nvim-old/lua/utilities/help_menu_vert.lua
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
--local nvim_command = vim.api.nvim_command
|
||||
|
||||
--function OpenHelpInVerticalSplit()
|
||||
--local input = vim.fn.input("Search term: ")
|
||||
--nvim_command("vert h " .. input)
|
||||
--end
|
||||
|
||||
--vim.cmd("nnoremap <leader>h :lua OpenHelpInVerticalSplit()<CR>")
|
||||
Loading…
Add table
Add a link
Reference in a new issue