uiua pad and link (plus some other stuff)

main
aprzn 1 year ago
parent a9d3bceb9f
commit 7d462d0294

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

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

@ -1,81 +1,82 @@
local map = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }
vim.g.mapleader = ' '
map('n', '<m-n>', '"zdd"zp', opts) -- Move line down
map('n', '<m-e>', '"zdd"zkP', opts) -- Move line up
map('i', '<c-t>', '<esc>', opts) -- return to normalcy
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
map('i', '<s-tab>', 'coc#pum#visible() ? coc#pum#prev(1) : "\\<C-h>"',
{noremap = true, silent = true, expr = true}) -- prev item in coc list
map('n', '<F2>', '<Plug>(coc-rename)', opts) -- rename
map('n', '<F8>', '<Cmd>TagbarToggle<cr>', opts) -- show ctags
vim.keymap.set('n', 'zR', require('ufo').openAllFolds) -- 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('n', '<c-->', function()
vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * 0.9
end)
vim.keymap.set('n', '<c-=>', function()
vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * 1.1
end)
return function()
local map = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }
vim.g.mapleader = ' '
map('n', '<m-n>', '"zdd"zp', opts) -- Move line down
map('n', '<m-e>', '"zdd"zkP', opts) -- Move line up
map('i', '<c-t>', '<esc>', opts) -- return to normalcy
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
map('i', '<s-tab>', 'coc#pum#visible() ? coc#pum#prev(1) : "\\<C-h>"',
{noremap = true, silent = true, expr = true}) -- prev item in coc list
map('n', '<F2>', '<Plug>(coc-rename)', opts) -- rename
map('n', '<F8>', '<Cmd>TagbarToggle<cr>', opts) -- show ctags
vim.keymap.set('n', 'zR', require('ufo').openAllFolds) -- ufo
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds) -- ufo
vim.keymap.set('t', '<c-t>', '<c-\\><c-n>') -- close term
vim.keymap.set('n', '<c-->', function()
vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * 0.9
end)
vim.keymap.set('n', '<c-=>', function()
vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * 1.1
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
local wk = require('whichkey_setup')
wk.config{
hide_statusline = true,
default_keymap_settings = {
silent=true,
noremap=true,
},
default_mode='n'
}
-- whichkey
local wk = require('whichkey_setup')
wk.config{
hide_statusline = true,
default_keymap_settings = {
silent=true,
noremap=true,
},
default_mode='n'
}
wk.register_keymap('leader', {
s = {
name = '+jump',
d = {'<Plug>(coc-definition)', 'definition'},
r = {'<Plug>(coc-references)', 'references'},
t = {'<Plug>(coc-type-definition)', 'type definition'},
s = {'<Cmd>BLines<cr>', 'fzf current buffer'},
S = {'<Cmd>Lines<cr>', 'fzf all buffers'},
},
nt = {'<Cmd>NERDTreeToggle<CR>', 'nerdtree'}, -- originally nt
rc = {'<Cmd>tabedit $MYVIMRC<cr><Cmd>NERDTree ~/.config/nvim/<cr>', 'nvim config'}, -- originally rc
c = {
name = '+appearance',
d = {'<Cmd>set background=dark<cr>', 'dark'},
l = {'<Cmd>set background=light<cr>', 'light'},
},
e = {'<Cmd>CocDiagnostics<cr>', 'errors'},
h = {'<Cmd>call CocActionAsync("doHover")<cr>', 'hover'},
q = {
name = "+modify",
q = {'<Plug>(coc-fix-current)', 'quick fix'},
c = {'<Plug>(coc-codeaction-selected)', 'code actions'},
},
l = {
name = '+latex',
c = {'<Cmd>VimtexCompile<cr>', 'toggle compile'},
},
b = {
name = '+buffer',
m = {'<c-w>h', 'left'},
n = {'<c-w>j', 'down'},
e = {'<c-w>k', 'up'},
i = {'<c-w>l', 'right'},
M = {'<c-w>H', 'move left'},
N = {'<c-w>J', 'move down'},
E = {'<c-w>K', 'move up'},
I = {'<c-w>L', 'move right'},
wk.register_keymap('leader', {
s = {
name = '+jump',
d = {'<Plug>(coc-definition)', 'definition'},
r = {'<Plug>(coc-references)', 'references'},
t = {'<Plug>(coc-type-definition)', 'type definition'},
s = {'<Cmd>BLines<cr>', 'fzf current buffer'},
S = {'<Cmd>Lines<cr>', 'fzf all buffers'},
},
nt = {'<Cmd>NERDTreeToggle<CR>', 'nerdtree'}, -- originally nt
rc = {'<Cmd>tabedit $MYVIMRC<cr><Cmd>NERDTree ~/.config/nvim/<cr>', 'nvim config'}, -- originally rc
c = {
name = '+appearance',
d = {'<Cmd>set background=dark<cr>', 'dark'},
l = {'<Cmd>set background=light<cr>', 'light'},
},
e = {'<Cmd>CocDiagnostics<cr>', 'errors'},
h = {'<Cmd>call CocActionAsync("doHover")<cr>', 'hover'},
q = {
name = "+modify",
q = {'<Plug>(coc-fix-current)', 'quick fix'},
c = {'<Plug>(coc-codeaction-selected)', 'code actions'},
},
l = {
name = '+latex',
c = {'<Cmd>VimtexCompile<cr>', 'toggle compile'},
},
b = {
name = '+buffer',
m = {'<c-w>h', 'left'},
n = {'<c-w>j', 'down'},
e = {'<c-w>k', 'up'},
i = {'<c-w>l', 'right'},
M = {'<c-w>H', 'move left'},
N = {'<c-w>J', 'move down'},
E = {'<c-w>K', 'move up'},
I = {'<c-w>L', 'move right'},
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
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({})
return false
-- base64 encode and decode from http://lua-users.org/wiki/BaseSixtyFour
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'
-- encoding
function enc(data)
return ((data:gsub('.', function(x)
local r,b='',x:byte()
for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
return r;
end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
if (#x < 6) then return '' end
local c=0
for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
return b:sub(c+1,c+1)
end)..({ '', '==', '=' })[#data%3+1])
end
-- decoding
function dec(data)
data = string.gsub(data, '[^'..b..'=]', '')
return (data:gsub('.', function(x)
if (x == '=') then return '' end
local r,f='',(b:find(x)-1)
for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
return r;
end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
if (#x ~= 8) then return '' end
local c=0
for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
return string.char(c)
end))
end
return function()
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,54 +1,55 @@
vim.opt.termguicolors = true
require('packer').startup(function(use)
use 'wbthomason/packer.nvim' -- Ensure that Packer stays updated
return function()
vim.opt.termguicolors = true
require('packer').startup(function(use)
use 'wbthomason/packer.nvim' -- Ensure that Packer stays updated
-- Color Schemes
use { 'dracula/vim', as = 'dracula' }
use 'arcticicestudio/nord-vim'
use 'joshdick/onedark.vim'
use 'morhetz/gruvbox'
use 'sainnhe/everforest'
use 'sainnhe/edge'
use 'edeneast/nightfox.nvim'
use 'catppuccin/vim'
use 'drewtempelmeyer/palenight.vim'
use 'ghifarit53/tokyonight-vim'
use 'hzchirs/vim-material'
-- Color Schemes
use { 'dracula/vim', as = 'dracula' }
use 'arcticicestudio/nord-vim'
use 'joshdick/onedark.vim'
use 'morhetz/gruvbox'
use 'sainnhe/everforest'
use 'sainnhe/edge'
use 'edeneast/nightfox.nvim'
use 'catppuccin/vim'
use 'drewtempelmeyer/palenight.vim'
use 'ghifarit53/tokyonight-vim'
use 'hzchirs/vim-material'
-- Language Support
use { 'neoclide/coc.nvim', branch = 'release' } -- LSPs
use 'preservim/tagbar' -- Ctags
use 'lervag/vimtex' -- LaTeX
use 'sirtaj/vim-openscad' -- OpenSCAD syntax highlighting, etc.
use 'meatballs/vim-xonsh' -- xsh syntax highlighting
use 'vlelo/arduino-helper.nvim' -- Arduino
use 'habamax/vim-godot' -- GDScript
use 'fruit-in/brainfuck-vim' -- brainfuck
use 'mattn/emmet-vim' -- html emmets
use {
'ModProg/cargo.nvim',
run = 'makers release',
config = function()
require"cargo".setup()
end
}
-- Language Support
use { 'neoclide/coc.nvim', branch = 'release' } -- LSPs
use 'preservim/tagbar' -- Ctags
use 'lervag/vimtex' -- LaTeX
use 'sirtaj/vim-openscad' -- OpenSCAD syntax highlighting, etc.
use 'meatballs/vim-xonsh' -- xsh syntax highlighting
use 'vlelo/arduino-helper.nvim' -- Arduino
use 'habamax/vim-godot' -- GDScript
use 'fruit-in/brainfuck-vim' -- brainfuck
use 'mattn/emmet-vim' -- html emmets
use {
'ModProg/cargo.nvim',
run = 'makers release',
config = function()
require"cargo".setup()
end
}
use {
'nvim-telescope/telescope.nvim', tag = '0.1.1',
requires = {{'nvim-lua/plenary.nvim'}}
}
use {'AckslD/nvim-whichkey-setup.lua', requires={ 'liuchengxu/vim-which-key' }} -- keybind helper popup
use 'junegunn/fzf.vim' -- fuzzy finder
use 'tpope/vim-commentary' -- Comment things
use 'preservim/nerdtree' -- NERDTree: File Viewer
use 'vim-airline/vim-airline' -- status bar
use 'm4xshen/autoclose.nvim' -- autoclosing brackets, not sure if I'll keep it
use 'tpope/vim-surround' -- surround text with brackets
use {'kevinhwang91/nvim-ufo', requires = 'kevinhwang91/promise-async'} -- better folding
use 'tpope/vim-fugitive' -- git
use 'junegunn/goyo.vim' -- focus mode
use {
'nvim-telescope/telescope.nvim', tag = '0.1.1',
requires = {{'nvim-lua/plenary.nvim'}}
}
use {'AckslD/nvim-whichkey-setup.lua', requires={ 'liuchengxu/vim-which-key' }} -- keybind helper popup
use 'junegunn/fzf.vim' -- fuzzy finder
use 'tpope/vim-commentary' -- Comment things
use 'preservim/nerdtree' -- NERDTree: File Viewer
use 'vim-airline/vim-airline' -- status bar
-- use 'm4xshen/autoclose.nvim' -- autoclosing brackets, not sure if I'll keep it
use 'tpope/vim-surround' -- surround text with brackets
use {'kevinhwang91/nvim-ufo', requires = 'kevinhwang91/promise-async'} -- better folding
use 'tpope/vim-fugitive' -- git
use 'junegunn/goyo.vim' -- focus mode
use 'ryanoasis/vim-devicons' -- icons for NERDTree (must be loaded last)
end)
use 'ryanoasis/vim-devicons' -- icons for NERDTree (must be loaded last)
end)
return false
end

@ -79,11 +79,6 @@ _G.packer_plugins = {
path = "/home/aprzn/.local/share/nvim/site/pack/packer/start/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"] = {
loaded = true,
path = "/home/aprzn/.local/share/nvim/site/pack/packer/start/brainfuck-vim",

Loading…
Cancel
Save