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,57 +1,57 @@
-- 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)
local file = io.open(vim.fn.stdpath('config') .. "/colorscheme", "w") local file = io.open(vim.fn.stdpath('config') .. "/colorscheme", "w")
local cs = ev.match local cs = ev.match
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
vim.o.guifont = "FiraCode Nerd Font:h14" vim.o.guifont = "FiraCode Nerd Font:h14"
end end
end end
end, end,
}) })
end
return false

@ -1,81 +1,82 @@
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
{noremap = true, silent = true, expr = true}) -- next item in coc list map('i', '<tab>', 'coc#pum#visible() ? coc#pum#next(1) : "\\<Tab>"',
map('i', '<s-tab>', 'coc#pum#visible() ? coc#pum#prev(1) : "\\<C-h>"', {noremap = true, silent = true, expr = true}) -- next item in coc list
{noremap = true, silent = true, expr = true}) -- prev item in coc list map('i', '<s-tab>', 'coc#pum#visible() ? coc#pum#prev(1) : "\\<C-h>"',
map('n', '<F2>', '<Plug>(coc-rename)', opts) -- rename {noremap = true, silent = true, expr = true}) -- prev item in coc list
map('n', '<F8>', '<Cmd>TagbarToggle<cr>', opts) -- show ctags map('n', '<F2>', '<Plug>(coc-rename)', opts) -- rename
vim.keymap.set('n', 'zR', require('ufo').openAllFolds) -- ufo map('n', '<F8>', '<Cmd>TagbarToggle<cr>', opts) -- show ctags
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds) -- ufo vim.keymap.set('n', 'zR', require('ufo').openAllFolds) -- ufo
vim.keymap.set('t', '<c-d><c-d>', '<c-\\><c-n>') -- close term vim.keymap.set('n', 'zM', require('ufo').closeAllFolds) -- ufo
vim.keymap.set('n', '<c-->', function() vim.keymap.set('t', '<c-t>', '<c-\\><c-n>') -- close term
vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * 0.9 vim.keymap.set('n', '<c-->', function()
end) vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * 0.9
vim.keymap.set('n', '<c-=>', function() end)
vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * 1.1 vim.keymap.set('n', '<c-=>', function()
end) 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 -- 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'},
r = {'<Plug>(coc-references)', 'references'}, r = {'<Plug>(coc-references)', 'references'},
t = {'<Plug>(coc-type-definition)', 'type definition'}, t = {'<Plug>(coc-type-definition)', 'type definition'},
s = {'<Cmd>BLines<cr>', 'fzf current buffer'}, s = {'<Cmd>BLines<cr>', 'fzf current buffer'},
S = {'<Cmd>Lines<cr>', 'fzf all buffers'}, S = {'<Cmd>Lines<cr>', 'fzf all buffers'},
}, },
nt = {'<Cmd>NERDTreeToggle<CR>', 'nerdtree'}, -- originally nt nt = {'<Cmd>NERDTreeToggle<CR>', 'nerdtree'}, -- originally nt
rc = {'<Cmd>tabedit $MYVIMRC<cr><Cmd>NERDTree ~/.config/nvim/<cr>', 'nvim config'}, -- originally rc rc = {'<Cmd>tabedit $MYVIMRC<cr><Cmd>NERDTree ~/.config/nvim/<cr>', 'nvim config'}, -- originally rc
c = { c = {
name = '+appearance', name = '+appearance',
d = {'<Cmd>set background=dark<cr>', 'dark'}, d = {'<Cmd>set background=dark<cr>', 'dark'},
l = {'<Cmd>set background=light<cr>', 'light'}, l = {'<Cmd>set background=light<cr>', 'light'},
}, },
e = {'<Cmd>CocDiagnostics<cr>', 'errors'}, e = {'<Cmd>CocDiagnostics<cr>', 'errors'},
h = {'<Cmd>call CocActionAsync("doHover")<cr>', 'hover'}, h = {'<Cmd>call CocActionAsync("doHover")<cr>', 'hover'},
q = { q = {
name = "+modify", name = "+modify",
q = {'<Plug>(coc-fix-current)', 'quick fix'}, q = {'<Plug>(coc-fix-current)', 'quick fix'},
c = {'<Plug>(coc-codeaction-selected)', 'code actions'}, c = {'<Plug>(coc-codeaction-selected)', 'code actions'},
}, },
l = { l = {
name = '+latex', name = '+latex',
c = {'<Cmd>VimtexCompile<cr>', 'toggle compile'}, c = {'<Cmd>VimtexCompile<cr>', 'toggle compile'},
}, },
b = { b = {
name = '+buffer', name = '+buffer',
m = {'<c-w>h', 'left'}, m = {'<c-w>h', 'left'},
n = {'<c-w>j', 'down'}, n = {'<c-w>j', 'down'},
e = {'<c-w>k', 'up'}, e = {'<c-w>k', 'up'},
i = {'<c-w>l', 'right'}, i = {'<c-w>l', 'right'},
M = {'<c-w>H', 'move left'}, M = {'<c-w>H', 'move left'},
N = {'<c-w>J', 'move down'}, N = {'<c-w>J', 'move down'},
E = {'<c-w>K', 'move up'}, E = {'<c-w>K', 'move up'},
I = {'<c-w>L', 'move right'}, 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 -- 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,54 +1,55 @@
vim.opt.termguicolors = true return function()
require('packer').startup(function(use) vim.opt.termguicolors = true
use 'wbthomason/packer.nvim' -- Ensure that Packer stays updated require('packer').startup(function(use)
use 'wbthomason/packer.nvim' -- Ensure that Packer stays updated
-- Color Schemes -- Color Schemes
use { 'dracula/vim', as = 'dracula' } use { 'dracula/vim', as = 'dracula' }
use 'arcticicestudio/nord-vim' use 'arcticicestudio/nord-vim'
use 'joshdick/onedark.vim' use 'joshdick/onedark.vim'
use 'morhetz/gruvbox' use 'morhetz/gruvbox'
use 'sainnhe/everforest' use 'sainnhe/everforest'
use 'sainnhe/edge' use 'sainnhe/edge'
use 'edeneast/nightfox.nvim' use 'edeneast/nightfox.nvim'
use 'catppuccin/vim' use 'catppuccin/vim'
use 'drewtempelmeyer/palenight.vim' use 'drewtempelmeyer/palenight.vim'
use 'ghifarit53/tokyonight-vim' use 'ghifarit53/tokyonight-vim'
use 'hzchirs/vim-material' use 'hzchirs/vim-material'
-- Language Support -- Language Support
use { 'neoclide/coc.nvim', branch = 'release' } -- LSPs use { 'neoclide/coc.nvim', branch = 'release' } -- LSPs
use 'preservim/tagbar' -- Ctags use 'preservim/tagbar' -- Ctags
use 'lervag/vimtex' -- LaTeX use 'lervag/vimtex' -- LaTeX
use 'sirtaj/vim-openscad' -- OpenSCAD syntax highlighting, etc. use 'sirtaj/vim-openscad' -- OpenSCAD syntax highlighting, etc.
use 'meatballs/vim-xonsh' -- xsh syntax highlighting use 'meatballs/vim-xonsh' -- xsh syntax highlighting
use 'vlelo/arduino-helper.nvim' -- Arduino use 'vlelo/arduino-helper.nvim' -- Arduino
use 'habamax/vim-godot' -- GDScript use 'habamax/vim-godot' -- GDScript
use 'fruit-in/brainfuck-vim' -- brainfuck use 'fruit-in/brainfuck-vim' -- brainfuck
use 'mattn/emmet-vim' -- html emmets use 'mattn/emmet-vim' -- html emmets
use { use {
'ModProg/cargo.nvim', 'ModProg/cargo.nvim',
run = 'makers release', run = 'makers release',
config = function() config = function()
require"cargo".setup() require"cargo".setup()
end end
} }
use { use {
'nvim-telescope/telescope.nvim', tag = '0.1.1', 'nvim-telescope/telescope.nvim', tag = '0.1.1',
requires = {{'nvim-lua/plenary.nvim'}} requires = {{'nvim-lua/plenary.nvim'}}
} }
use {'AckslD/nvim-whichkey-setup.lua', requires={ 'liuchengxu/vim-which-key' }} -- keybind helper popup use {'AckslD/nvim-whichkey-setup.lua', requires={ 'liuchengxu/vim-which-key' }} -- keybind helper popup
use 'junegunn/fzf.vim' -- fuzzy finder use 'junegunn/fzf.vim' -- fuzzy finder
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