uiua pad and link (plus some other stuff)

main
aprzn 1 year ago
parent a9d3bceb9f
commit 7d462d0294

@ -1,5 +1,5 @@
require('packages') require('packages')()
require('bindings') require('bindings')()
require('autocmds') require('autocmds')()
require('nvcfg') require('nvcfg')()
require('local') require('local')()

@ -1,26 +1,27 @@
-- detect filetype return function()
vim.filetype.add({extension = {ua = "uiua" }}) -- detect filetype
vim.filetype.add({extension = {ua = "uiua" }})
vim.api.nvim_create_augroup("aprzn", {clear = true}) vim.api.nvim_create_augroup("aprzn", {clear = true})
vim.api.nvim_create_autocmd("BufWritePost", { vim.api.nvim_create_autocmd("BufWritePost", {
group = "aprzn", group = "aprzn",
pattern = {"*/.config/nvim/*.lua", "*/.config/nvim/lua/*.lua"}, pattern = {"*/nvim/*.lua", "*/nvim/lua/*.lua"},
command = "source $MYVIMRC" command = "source $MYVIMRC"
}) -- reload config file on save }) -- reload config file on save
-- vim.api.nvim_create_autocmd("VimEnter", { -- vim.api.nvim_create_autocmd("VimEnter", {
-- group = "aprzn", -- group = "aprzn",
-- pattern = {"*"}, -- pattern = {"*"},
-- command = "NERDTree" -- command = "NERDTree"
-- }) -- open nerdtree on start -- }) -- open nerdtree on start
vim.api.nvim_create_autocmd("CursorHold", { vim.api.nvim_create_autocmd("CursorHold", {
group = "aprzn", group = "aprzn",
pattern = {"*"}, pattern = {"*"},
command = "call CocActionAsync('highlight')" command = "call CocActionAsync('highlight')"
}) -- highlight matching tokens when not moving cursor }) -- highlight matching tokens when not moving cursor
vim.api.nvim_create_autocmd("ColorScheme", { vim.api.nvim_create_autocmd("ColorScheme", {
group = "aprzn", group = "aprzn",
pattern = {"*"}, pattern = {"*"},
callback = function(ev) callback = function(ev)
@ -29,22 +30,22 @@ vim.api.nvim_create_autocmd("ColorScheme", {
file:write(cs) file:write(cs)
file:close() file:close()
end end
}) -- save colorscheme }) -- save colorscheme
vim.api.nvim_create_autocmd("BufWritePost", { vim.api.nvim_create_autocmd("BufWritePost", {
group = "aprzn", group = "aprzn",
pattern = "*.ua", pattern = "*.ua",
callback = function(ev) callback = function(ev)
vim.cmd("silent !uiua fmt " .. vim.fn.expand("<amatch>")) vim.cmd("silent !uiua fmt " .. vim.fn.expand("<amatch>"))
end, end,
}) -- format uiua on save }) -- format uiua on save
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
group = "aprzn", group = "aprzn",
pattern = "*", pattern = "*",
callback = function(ev) callback = function(ev)
if vim.g.neovide then if vim.g.neovide then
if ev.match == "uiua" then if ev.match == "uiua" then -- use uiua386 when editing uiua
vim.o.guifont = "Uiua386:h14" vim.o.guifont = "Uiua386:h14"
vim.opt_local.commentstring = "# %s" vim.opt_local.commentstring = "# %s"
else else
@ -52,6 +53,5 @@ vim.api.nvim_create_autocmd("FileType", {
end end
end end
end, end,
}) })
end
return false

@ -1,42 +1,43 @@
local map = vim.api.nvim_set_keymap return function()
local opts = { noremap = true, silent = true } local map = vim.api.nvim_set_keymap
vim.g.mapleader = ' ' local opts = { noremap = true, silent = true }
map('n', '<m-n>', '"zdd"zp', opts) -- Move line down vim.g.mapleader = ' '
map('n', '<m-e>', '"zdd"zkP', opts) -- Move line up map('n', '<m-n>', '"zdd"zp', opts) -- Move line down
map('i', '<c-t>', '<esc>', opts) -- return to normalcy map('n', '<m-e>', '"zdd"zkP', opts) -- Move line up
map('n', '<c-d>', ':q<cr>', opts) -- c-d to close file map('i', '<c-t>', '<esc>', opts) -- return to normalcy
map('i', '<tab>', 'coc#pum#visible() ? coc#pum#next(1) : "\\<Tab>"', map('n', '<c-d>', ':q<cr>', opts) -- c-d to close file
map('i', '<tab>', 'coc#pum#visible() ? coc#pum#next(1) : "\\<Tab>"',
{noremap = true, silent = true, expr = true}) -- next item in coc list {noremap = true, silent = true, expr = true}) -- next item in coc list
map('i', '<s-tab>', 'coc#pum#visible() ? coc#pum#prev(1) : "\\<C-h>"', map('i', '<s-tab>', 'coc#pum#visible() ? coc#pum#prev(1) : "\\<C-h>"',
{noremap = true, silent = true, expr = true}) -- prev item in coc list {noremap = true, silent = true, expr = true}) -- prev item in coc list
map('n', '<F2>', '<Plug>(coc-rename)', opts) -- rename map('n', '<F2>', '<Plug>(coc-rename)', opts) -- rename
map('n', '<F8>', '<Cmd>TagbarToggle<cr>', opts) -- show ctags map('n', '<F8>', '<Cmd>TagbarToggle<cr>', opts) -- show ctags
vim.keymap.set('n', 'zR', require('ufo').openAllFolds) -- ufo vim.keymap.set('n', 'zR', require('ufo').openAllFolds) -- ufo
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds) -- ufo vim.keymap.set('n', 'zM', require('ufo').closeAllFolds) -- ufo
vim.keymap.set('t', '<c-d><c-d>', '<c-\\><c-n>') -- close term vim.keymap.set('t', '<c-t>', '<c-\\><c-n>') -- close term
vim.keymap.set('n', '<c-->', function() vim.keymap.set('n', '<c-->', function()
vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * 0.9 vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * 0.9
end) end)
vim.keymap.set('n', '<c-=>', function() vim.keymap.set('n', '<c-=>', function()
vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * 1.1 vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * 1.1
end) end)
vim.g.tagbar_map_showproto = '<C-Space>' -- remove tagbar space bar conflict vim.g.tagbar_map_showproto = '<C-Space>' -- remove tagbar space bar conflict
-- whichkey -- whichkey
local wk = require('whichkey_setup') local wk = require('whichkey_setup')
wk.config{ wk.config{
hide_statusline = true, hide_statusline = true,
default_keymap_settings = { default_keymap_settings = {
silent=true, silent=true,
noremap=true, noremap=true,
}, },
default_mode='n' default_mode='n'
} }
wk.register_keymap('leader', { wk.register_keymap('leader', {
s = { s = {
name = '+jump', name = '+jump',
d = {'<Plug>(coc-definition)', 'definition'}, d = {'<Plug>(coc-definition)', 'definition'},
@ -76,6 +77,6 @@ wk.register_keymap('leader', {
t = {'<cmd>Telescope buffers<cr>', 'goto fuzzy'}, t = {'<cmd>Telescope buffers<cr>', 'goto fuzzy'},
}, },
}) })
return false end

@ -1,34 +1,117 @@
vim.opt.expandtab = true -- tabs to spaces -- base64 encode and decode from http://lua-users.org/wiki/BaseSixtyFour
vim.opt.shiftwidth = 2 -- 4 spaces for < and > TODO: change back to 4 local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'
vim.opt.softtabstop = 2 -- 4 spaces in a tab TODO: change back to 4 -- encoding
vim.opt.number = true -- Show line numbers function enc(data)
vim.opt.relativenumber = true -- Show other line numbers as relative return ((data:gsub('.', function(x)
vim.opt.smartindent = true -- Smart indent local r,b='',x:byte()
vim.g.airline_powerline_fonts = 1 -- nice icons for airline for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
vim.g.wrap = false -- don't wrap lines return r;
vim.g.termguicolors = true -- better colors end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
vim.g.gruvbox_italic = 1 -- gruvbox can use italic font if (#x < 6) then return '' end
vim.g.material_style = 'oceanic' -- material theme local c=0
vim.g.bf_array_mode = 2 -- cyclic brainfuck memory for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
vim.g.bf_value_mode = 2 -- cyclic brainfuck values return b:sub(c+1,c+1)
end)..({ '', '==', '=' })[#data%3+1])
-- load colorscheme end
local file = io.open(vim.fn.stdpath('config') .. "/colorscheme", "r")
local cs = file:read("l") -- decoding
file:close() function dec(data)
vim.cmd("colorscheme " .. cs) data = string.gsub(data, '[^'..b..'=]', '')
return (data:gsub('.', function(x)
-- ufo if (x == '=') then return '' end
vim.o.foldcolumn = '1' local r,f='',(b:find(x)-1)
vim.o.foldlevel = 99 for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
vim.o.foldlevelstart = 99 return r;
vim.o.foldenable = true end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
require('ufo').setup() if (#x ~= 8) then return '' end
local c=0
-- vimtex for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
vim.g.vimtex_view_general_viewer = 'evince' return string.char(c)
end))
-- autoclose end
require('autoclose').setup({})
return function()
return false vim.opt.expandtab = true -- tabs to spaces
vim.opt.shiftwidth = 2 -- 4 spaces for < and > TODO: change back to 4
vim.opt.softtabstop = 2 -- 4 spaces in a tab TODO: change back to 4
vim.opt.number = true -- Show line numbers
vim.opt.relativenumber = true -- Show other line numbers as relative
vim.opt.smartindent = true -- Smart indent
vim.g.airline_powerline_fonts = 1 -- nice icons for airline
vim.g.wrap = false -- don't wrap lines
vim.g.termguicolors = true -- better colors
vim.g.gruvbox_italic = 1 -- gruvbox can use italic font
vim.g.material_style = 'oceanic' -- material theme
vim.g.bf_array_mode = 2 -- cyclic brainfuck memory
vim.g.bf_value_mode = 2 -- cyclic brainfuck values
-- load colorscheme
local file = io.open(vim.fn.stdpath('config') .. "/colorscheme", "r")
local cs = file:read("l")
file:close()
vim.cmd("colorscheme " .. cs)
-- ufo
vim.o.foldcolumn = '1'
vim.o.foldlevel = 99
vim.o.foldlevelstart = 99
vim.o.foldenable = true
require('ufo').setup()
-- vimtex
vim.g.vimtex_view_general_viewer = 'evince'
-- -- autoclose
-- require('autoclose').setup({})
-- uiua pad
vim.api.nvim_create_user_command('UiuaPad', function(opts)
math.randomseed(os.time())
-- pad file
if vim.g.pad_file == nil then
vim.g.pad_file = vim.fn.stdpath('cache') .. '/pad_' .. math.random(100, 999) .. '.ua'
io.open(vim.g.pad_file, 'w'):close()
end
local pad_file = vim.g.pad_file
-- open relevant buffers
vim.cmd.edit(pad_file)
vim.cmd.vsplit()
local pad_buf = vim.fn.bufnr('%')
local pad_win = vim.fn.win_getid();
vim.cmd.wincmd('l')
vim.cmd.term('cd ' .. vim.fn.stdpath('cache') .. '; uiua watch --clear ' .. pad_file)
local term_buf = vim.fn.bufnr('%')
local term_win = vim.fn.win_getid();
vim.cmd.wincmd('h')
-- close either one when the other closes
vim.api.nvim_create_augroup("uiuapad", {clear = true})
vim.api.nvim_create_autocmd("WinClosed", {
group = "uiuapad",
pattern = {tostring(pad_win), tostring(term_win)}, --pad_file, --{"*" .. pad_file, pad_file},
callback = function(ev)
-- print(pad_buf)
-- print(term_buf)
-- print(vim.fn.bufexists( pad_buf ))
-- print(vim.fn.bufexists( term_buf ))
-- if vim.fn.bufexists(pad_buf) then vim.cmd("bdelete! " .. pad_buf) end
if vim.fn.bufexists(pad_buf) then vim.cmd("bdelete! " .. pad_buf) end
if vim.fn.bufexists(term_buf) then vim.cmd("bdelete! " .. term_buf) end
end,
})
end, {})
-- generate uiua pad link
vim.api.nvim_create_user_command('UiuaLink', function(opts)
local uiua_version_raw = vim.fn.system({"uiua", "--version"})
print(uiua_version_raw)
local uiua_version = uiua_version_raw:sub(6, -2):gsub('%p', '_')
local buf_text = vim.fn.join(vim.fn.getline(0, '$'), '\n')
local url = "https://uiua.org/pad?src=" .. uiua_version .. "__" .. enc(buf_text)
print(url)
vim.fn.setreg('+', url)
end, {})
end

@ -1,5 +1,6 @@
vim.opt.termguicolors = true return function()
require('packer').startup(function(use) vim.opt.termguicolors = true
require('packer').startup(function(use)
use 'wbthomason/packer.nvim' -- Ensure that Packer stays updated use 'wbthomason/packer.nvim' -- Ensure that Packer stays updated
-- Color Schemes -- Color Schemes
@ -42,13 +43,13 @@ require('packer').startup(function(use)
use 'tpope/vim-commentary' -- Comment things use 'tpope/vim-commentary' -- Comment things
use 'preservim/nerdtree' -- NERDTree: File Viewer use 'preservim/nerdtree' -- NERDTree: File Viewer
use 'vim-airline/vim-airline' -- status bar use 'vim-airline/vim-airline' -- status bar
use 'm4xshen/autoclose.nvim' -- autoclosing brackets, not sure if I'll keep it -- use 'm4xshen/autoclose.nvim' -- autoclosing brackets, not sure if I'll keep it
use 'tpope/vim-surround' -- surround text with brackets use 'tpope/vim-surround' -- surround text with brackets
use {'kevinhwang91/nvim-ufo', requires = 'kevinhwang91/promise-async'} -- better folding use {'kevinhwang91/nvim-ufo', requires = 'kevinhwang91/promise-async'} -- better folding
use 'tpope/vim-fugitive' -- git use 'tpope/vim-fugitive' -- git
use 'junegunn/goyo.vim' -- focus mode use 'junegunn/goyo.vim' -- focus mode
use 'ryanoasis/vim-devicons' -- icons for NERDTree (must be loaded last) use 'ryanoasis/vim-devicons' -- icons for NERDTree (must be loaded last)
end) end)
return false end

@ -79,11 +79,6 @@ _G.packer_plugins = {
path = "/home/aprzn/.local/share/nvim/site/pack/packer/start/arduino-helper.nvim", path = "/home/aprzn/.local/share/nvim/site/pack/packer/start/arduino-helper.nvim",
url = "https://github.com/vlelo/arduino-helper.nvim" url = "https://github.com/vlelo/arduino-helper.nvim"
}, },
["autoclose.nvim"] = {
loaded = true,
path = "/home/aprzn/.local/share/nvim/site/pack/packer/start/autoclose.nvim",
url = "https://github.com/m4xshen/autoclose.nvim"
},
["brainfuck-vim"] = { ["brainfuck-vim"] = {
loaded = true, loaded = true,
path = "/home/aprzn/.local/share/nvim/site/pack/packer/start/brainfuck-vim", path = "/home/aprzn/.local/share/nvim/site/pack/packer/start/brainfuck-vim",

Loading…
Cancel
Save