diff --git a/configs/nvim/coc-settings.json b/configs/nvim/coc-settings.json index 9fea980..29f3559 100644 --- a/configs/nvim/coc-settings.json +++ b/configs/nvim/coc-settings.json @@ -1,3 +1,11 @@ { - "rust-analyzer.checkOnSave.command": "clippy" + "rust-analyzer.checkOnSave.command": "clippy", + "clangd.path": "~/.config/coc/extensions/coc-clangd-data/install/16.0.2/clangd_16.0.2/bin/clangd", + "languageserver": { + "uiua": { + "command": "uiua", + "args": ["lsp"], + "filetypes": ["uiua"] + } + } } diff --git a/configs/nvim/lua/autocmds.lua b/configs/nvim/lua/autocmds.lua index 4129871..aa9ed8b 100644 --- a/configs/nvim/lua/autocmds.lua +++ b/configs/nvim/lua/autocmds.lua @@ -1,3 +1,6 @@ +-- detect filetype +vim.filetype.add({extension = {ua = "uiua" }}) + vim.api.nvim_create_augroup("aprzn", {clear = true}) vim.api.nvim_create_autocmd("BufWritePost", { group = "aprzn", @@ -28,4 +31,11 @@ vim.api.nvim_create_autocmd("ColorScheme", { end }) -- save colorscheme + vim.api.nvim_create_autocmd("BufWritePost", { + pattern = "*.ua", + callback = function(ev) + vim.cmd("silent !uiua fmt " .. vim.fn.expand("")) + end, + }) -- format uiua on save + return false diff --git a/configs/nvim/lua/nvcfg.lua b/configs/nvim/lua/nvcfg.lua index e6f57cd..faf5613 100644 --- a/configs/nvim/lua/nvcfg.lua +++ b/configs/nvim/lua/nvcfg.lua @@ -25,6 +25,9 @@ vim.o.foldlevelstart = 99 vim.o.foldenable = true require('ufo').setup() +-- vimtex +vim.g.vimtex_view_general_viewer = 'evince' + -- autoclose require('autoclose').setup({}) diff --git a/configs/nvim/syntax/uiua.vim b/configs/nvim/syntax/uiua.vim new file mode 100644 index 0000000..09ecc6f --- /dev/null +++ b/configs/nvim/syntax/uiua.vim @@ -0,0 +1,104 @@ +if exists("b:current_syntax") + finish +endif + +let b:current_syntax = "uiua" +syn iskeyword a-z + +syn keyword uiuaIdentifier e os family arch ExeExt DllExt sep +syn match uiuaIdentifier '[a-zA-Z]\+' + +" {{{ functions and modifiers +" constants +syn keyword uiuaNoadic eta pi tau inf[inity] rand[om] tag now +syn match uiuaNoadic '[ηπ∞τ⚂]' + +" monadic and dyadic pervasive functions +syn keyword uiuaPervasive not sig[n] abs[olute] sqr[t] sin[e] flo[or] cei[ling] rou[nd] add subtract multiply divide mod[ulus] pow[er] log[arithm] min[imum] max[imum] ata[ngent] +syn match uiuaPervasive '[¬±`¯⌵√○⌊⌈⁅]\|!=\|<=\|>=\|[=≠<≤>≥+\-×*÷%◿ⁿₙ↧↥∠]' + +" monadic array functions +syn keyword uiuaMonadic len[gth] sha[pe] rang[e] fir[st] rev[erse] des[hape] bit[s] tra[nspose] ris[e] fal[e] whe[re] cla[ssify] ded[uplicate] box unb[ox] bre[ak] rec[ur] wait call parse gen type sig +syn match uiuaMonadic '[⧻△⇡⊢⇌♭⋯⍉⍏⍖⊚⊛⊝□⊔!⎋↬]' + +" dyadic array functions +syn keyword uiuaDyadic joi[n] cou[ple] mat[ch] pic[k] sel[ect] resh[ape] tak[e] dro[p] rot[ate] win[dows] kee[p] fin[d] mem[ber] ind[exof] ass[ert] deal +syn match uiuaDyadic '[⊂⊟≅⊡⊏↯↙↘↻◫▽⌕∊⊗⍤]' + +" monadic modifiers +syn keyword uiuaMonadicMod di[p] ga[p] eac[h] row[s] dis[tribute] tab[le] cro[ss] rep[eat] reduce fol[d] scan gro[up] par[tition] inv[ert] bot[h] spawn +syn match uiuaMonadicMod '[⊙⋅∵≡∺⊞⊠⍥/∧⊕⊜\\⍘∩]' + +" dyadic and triadic modifiers +syn keyword uiuaOtherMod lev[el] und[er] fil[l] bind bra[cket] for[k] try if +syn match uiuaOtherMod /[⍚⍜⬚'⊓⊃⍣?]/ +" }}} + +" {{{ system functions +" defined in inverse order so precedence for e.g. +" &i and &ime, &s and &sc, etc. is correct + +" modules +syn keyword uiuaModuleSF use +syn match uiuaModuleSF '&i' + +syn match uiuaDyadicSF '\v\&(rs|rb|ru|w|fwa|ime|ae|tcpsrt|tcpswt|httpsw)' +syn match uiuaMonadicSF '\v\&(sl|s|pf|p|var|runi|runc|cd|cl|fo|fc|fe|fld|fif|fras|frab|fwa|imd|ims|gife|ad|ap|ast|tcpl|tcpa|tcpc|tcpsnb|tcpaddr)' +syn match uiuaNoadicSF '\v\&(sc|ts|args|asr)' +" }}} + +" {{{ literals +" numeric literal +syn match uiuaNum '[¯`]\?\d\+\(\.\d\+\)\?\(e[¯`]\?\d\+\)\?' + +" escape sequence and format placeholder +syn match uiuaEsc contained /\\[\\'"_0nrt]/ +syn match uiuaFmt contained '_' + +" character literal +syn match uiuaChar '@.' contains=uiuaEsc + +" string literal (plain, format, and multiline) +syn region uiuaStr start='"' end='"' skip='\\"' contains=uiuaEsc +syn region uiuaStr start='\$"' end='"' skip='\\"' contains=uiuaEsc,uiuaFmt +syn region uiuaStr start='\$ ' end='$' contains=uiuaEsc,uiuaFmt +" }}} + +" {{{ misc +" function signatures +syn match uiuaSignature '|\d\+\(\.\d\+\)\?' + +" scopes, <- assignments, and stranded arrays +syn match uiuaFaded '^---$\|[←_]' + +" debug functions +syn keyword uiuaDebug dump +syn match uiuaDebug '[~]' + +" comments +syn match uiuaComment '#.*$' +" }}} + +" {{{ highlight groups +hi def link uiuaNoadic Keyword +hi def link uiuaNoadicSF Keyword +hi def link uiuaPervasive Operator +hi def link uiuaMonadic Function +hi def link uiuaMonadicSF Function +hi def link uiuaDyadic Identifier +hi def link uiuaDyadicSF Identifier +hi def link uiuaMonadicMod Type +hi def link uiuaOtherMod Number +hi def link uiuaModuleSF Keyword + +hi def link uiuaNum Number +hi def link uiuaEsc SpecialChar +hi def link uiuaChar String +hi def link uiuaFmt Operator +hi def link uiuaStr String + +hi def link uiuaSignature Type +hi def link uiuaDebug Operator +hi def link uiuaFaded Comment +hi def link uiuaComment Comment +" }}}