Compare commits

...

10 Commits

Author SHA1 Message Date
Talia f08e1712cf Add nvim simple snippet manager 2024-02-02 14:09:20 +01:00
Talia 7fdb7c8be3 Remove vimscript snippet management 2024-02-02 14:09:20 +01:00
Talia a874a985f3 Add nvim lua loader for matcha 2024-02-02 14:07:15 +01:00
Talia e12e46a089 Add matcha command to vim 2024-01-23 13:26:47 +01:00
Talia e366f12b56 Uncomment git validation hook 2024-01-22 14:03:41 +01:00
Talia 4000cea465 Shrink vim side panels 2024-01-11 13:41:17 +01:00
Talia 8e94f1c836 Add twilight nvim plugin 2024-01-08 16:53:54 +01:00
Talia 78c1fd2ca5 Add marks plugin to nvim 2024-01-08 16:22:31 +01:00
Talia 5bf3ffc167
Add nightfox vim theme 2024-01-05 11:32:33 +01:00
Talia 31c6db495b
Fix repository name in vim packs 2024-01-05 11:32:10 +01:00
9 changed files with 225 additions and 77 deletions

View File

@ -57,13 +57,13 @@ esac
if [ -n "$validate" ]; then
/bin/echo -e "\x1b[33mValidating commit\x1b[0m"
/bin/echo -e "\x1b[2mλ $validate\x1b[0m"
# if sh -c "$validate"
# then
# /bin/echo -e "\x1b[32mValidation Passed!\x1b[0m"
# else
# error=1
# /bin/echo -e "\x1b[1;31mValidation Failed!\x1b[0m"
# fi
if sh -c "$validate"
then
/bin/echo -e "\x1b[32mValidation Passed!\x1b[0m"
else
error=1
/bin/echo -e "\x1b[1;31mValidation Failed!\x1b[0m"
fi
fi
rm .git

61
vim/lua/matcha.lua Normal file
View File

@ -0,0 +1,61 @@
local function nextcol(state)
local from, to = state.str:find(state.pattern, state.last)
if from then
state.last = to+1
return from, to
end
end
local function colmatch(str, pattern)
return nextcol, {str=str,pattern=pattern,last=0}
end
local function findLocations(args)
local files = vim.fs.find(function(file)
if #args>1 then
for _, pattern in ipairs(args), args, 1 do
if vim.fs.basename(file):find(pattern) then
return true
end
end
else
return true
end
return false
end, {
limit=math.huge;
type="file";
})
local locations = {}
for _, file in ipairs(files) do
local lnum = 0
for line in io.lines(file) do
lnum = lnum + 1
for from, to in colmatch(line, args[1]) do
table.insert(locations, {
filename = file;
lnum = lnum;
col = from;
end_col = to;
text = line:sub(from, to)
})
end
end
end
return locations
end
vim.api.nvim_create_user_command("Matcha", function(params)
vim.fn.setqflist(findLocations(params.fargs))
vim.cmd("copen")
vim.cmd("crewind")
end, {nargs="+"})
vim.api.nvim_create_user_command("MatchaLocal", function(params)
vim.fn.setloclist(0, findLocations(params.farts))
vim.cmd("lopen")
vim.cmd("lrewind")
end, {nargs="+"})

View File

@ -28,18 +28,27 @@ use {
end
};
{
"hedyhli/outline.nvim",
config = function()
vim.keymap.set("n", "<leader>o", "<cmd>OutlineOpen<CR><cmd>OutlineFocus<CR>", { desc = "Toggle Outline" })
require("outline").setup()
end
"hedyhli/outline.nvim", config = require 'pack.setup.outline';
};
{ 'jinh0/eyeliner.nvim', config = function()
require('eyeliner').setup {
highlight_on_key = true;
dim = true;
}
end};
require('eyeliner').setup {
highlight_on_key = true;
dim = true;
}
end
};
{
'chentoast/marks.nvim';
config = function()
require'marks'.setup {
sign_priority = { lower=10, upper=15, builtin=8, bookmark=20 },
excluded_filetypes = {},
excluded_buftypes = {},
mappings = {}
}
end
};
'folke/twilight.nvim';
'leafo/moonscript-vim';
'neovim/nvim-lspconfig';
'pigpigyyy/Yuescript-vim';
@ -49,11 +58,12 @@ use {
'AlessandroYorba/Alduin';
'AlessandroYorba/Sierra';
'DarkWiiPlayer/papercolor-theme';
'EdenEast/nightfox.nvim';
'axvr/photon.vim';
'ayu-theme/ayu-vim';
'dracula/vim';
'jaredgorski/fogbell.vim';
'kvrohit/mellow';
'kvrohit/mellow.nvim';
'optionalg/Arcadia';
'rakr/vim-two-firewatch';
'rebelot/kanagawa.nvim';

View File

@ -1,5 +1,8 @@
return function()
require('neo-tree').setup {
window = {
width = 25;
};
filesystem = {
use_libuv_file_watcher = true;
};

View File

@ -0,0 +1,9 @@
return function()
vim.keymap.set("n", "<leader>o", "<cmd>OutlineOpen<CR><cmd>OutlineFocus<CR>", { desc = "Toggle Outline" })
require("outline").setup {
outline_window = {
width = 20;
relative_width = false;
};
}
end

116
vim/lua/snip.lua Normal file
View File

@ -0,0 +1,116 @@
local snip = {
snippets = {};
ft = {};
}
function snip:new(name, filetype, snippet)
if snippet==nil then
return self:new(name, nil, filetype)
end
if type(snippet) ~= "table" then
snippet = { snippet }
end
if filetype then
if not self.ft[filetype] then
self.ft[filetype] = {snippets = {}}
end
self.ft[filetype].snippets[name] = snippet
else
self.snippets[name] = snippet
end
end
function snip:each(filetype)
return coroutine.wrap(function()
for name, snippet in pairs(snip.snippets) do
coroutine.yield(name, snippet)
end
if filetype and snip.ft[filetype] then
for name, snippet in pairs(snip.ft[filetype].snippets) do
coroutine.yield(name, snippet)
end
end
end)
end
function snip:get(name, filetype)
local snippet = snip.snippets[name]
if filetype and snip.ft[filetype] then
snippet = snip.ft[filetype].snippets[name] or snippet
end
if snippet then
return snippet
end
end
local function complete(lead)
local names = {}
local known = {}
for name, snippet in snip:each(vim.o.filetype) do
if (name:find("^"..lead)) then
if type(snippet)=="string"
or snippet.condition == nil
or snippet.condition() then
if not known[name] then
table.insert(names, name)
end
known[name] = true
end
end
end
table.sort(names)
return names
end
local function process_item(item, lines)
if type(item) == "string" then
for _, line in ipairs(vim.fn.split(item, "\n")) do
table.insert(lines, line)
end
elseif type(item) == "function" then
process_item(item(), lines)
else
error("Unable to handle snippet item of type "..type(item))
end
end
function snip:insert(name)
local snippet = self:get(name, vim.o.filetype)
if not snippet then
print "No snippet with that name"
return
end
local mode = snippet.mode or "l"
local lines = {}
for _, item in ipairs(snippet) do
process_item(item, lines)
end
vim.api.nvim_put(lines, mode, true, true)
end
vim.api.nvim_create_user_command("Snip", function(params)
snip:insert(params.args)
end, {nargs=1, complete=complete})
vim.api.nvim_create_user_command("Snips", function()
local list = {}
for name in snip:each(vim.o.filetype) do
table.insert(list, name)
end
table.sort(list)
print(table.concat(list, ", "))
end, {})
vim.api.nvim_create_user_command("SnipReload", function()
package.loaded.snip = nil
require "snip"
end, {})
return snip

1
vim/plugin/matcha.lua Normal file
View File

@ -0,0 +1 @@
require 'matcha'

View File

@ -118,14 +118,6 @@ abbrev eshrug ¯\_(ツ)_/¯
" === GENERAL UTILITIES ===
" --- TEXT SNIPPETS ---
" -- Global --
if !exists('s:snippets')
let s:snippets = {}
end
" Runs a sequence of commands asynchronously
function! Async(array, ...)
if len(a:array) > 0
@ -137,57 +129,6 @@ function! Async(array, ...)
end
endfun
function! s:make_snippet(name, lines)
let s:snippets[a:name] = a:lines
endfun
function! s:make_snippet_range(name, line_start, line_end)
call s:make_snippet(a:name, getline(a:line_start, a:line_end))
endfun
function! s:insert_snippet(name)
for line in get(s:snippets, a:name, [])
put =line
endfor
endfun
function! MkSnip(name, str)
call s:make_snippet(a:name, split(a:str, '\n'))
endfun
command! -nargs=1 Snippet call s:insert_snippet(<f-args>)
command! -range -nargs=1 MkSnippet call s:make_snippet_range(<f-args>, <line1>, <line2>)
" -- Filetype --
if !exists('s:ft_snippets')
let s:ft_snippets = {}
end
function! s:make_ft_snippet(ft, name, lines)
if !get(s:ft_snippets, a:ft, 0)
let s:ft_snippets[a:ft] = {}
end
let s:ft_snippets[a:ft][a:name] = a:lines
endfun
function! s:make_ft_snippet_range(ft, name, line_start, line_end)
call s:make_ft_snippet(a:ft, a:name, getline(a:line_start, a:line_end))
endfun
function! s:insert_ft_snippet(ft, name)
for line in get(get(s:ft_snippets, a:ft, {}), a:name, [])
put =line
endfor
endfun
function! MkFTSnip(ft, name, str)
call s:make_ft_snippet(a:ft, a:name, split(a:str, '\n'))
endfun
command! -nargs=1 FTSnippet call s:insert_ft_snippet(&filetype, <f-args>)
command! -range -nargs=1 FTMkSnippet call s:make_ft_snippet_range(&filetype, <f-args>, <line1>, <line2>)
function! RangeChooser()
let temp = tempname()

7
vim/plugin/snip.lua Normal file
View File

@ -0,0 +1,7 @@
require "snip"
for _, path in ipairs(vim.api.nvim__get_runtime({"snip/snippets.lua"}, true, {})) do
local code = io.open(path):read("*a")
if code then
dofile(path)
end
end