From fb0a118741a6bf44f5a1305429552291d9679abf Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Thu, 14 Oct 2021 17:46:19 +0800 Subject: [PATCH] Update scripts, Emacs, and Neovim config --- bin/parse-barcodes | 2 +- bin/split-album | 6 +- emacs/modules/tools/wiki/README.org | 5 +- emacs/modules/tools/wiki/config.el | 4 +- nvim/init.lua | 201 ++++++++++++++-------------- 5 files changed, 107 insertions(+), 111 deletions(-) diff --git a/bin/parse-barcodes b/bin/parse-barcodes index ea7423a..1a67d20 100755 --- a/bin/parse-barcodes +++ b/bin/parse-barcodes @@ -12,5 +12,5 @@ set -o pipefail notify-send "Select a region for the barcode (QR codes, ISBN, bar codes)" -maim --select --hidecursor | zbarimg - --quiet | perl -pe 's|(.+?):||' +maim --select --hidecursor --quiet | zbarimg - --quiet --oneshot --raw | xclip -selection clipboard diff --git a/bin/split-album b/bin/split-album index cfbd0ee..229398d 100755 --- a/bin/split-album +++ b/bin/split-album @@ -249,9 +249,9 @@ proc main { # We'll also fill up the rest of the chapter-related data into the output data. for index in @(seq $[chapter_len]) { var index = Int(index) - var chapter = output_data['chapters'][index - 1] + setvar chapter = output_data['chapters'][index - 1] var start = chapter['timestamp'] - var end = output_data['chapters'][index]['timestamp'] if index != chapter_len else null + var end = output_data['chapters'][index]['timestamp'] if index !== chapter_len else null var filename = $(printf "%.2d-%s.%s" $index $(kebab-case ${chapter['title']}) $EXTENSION) setvar output_data['chapters'][index - 1]['file'] = filename @@ -262,7 +262,7 @@ proc main { setvar has_error = true } - append :job_queue ">&2 printf '[%d/%d] %s\\n' $[index] $[chapter_len] \"$[output_data['chapters'][index - 1]['title']]\"; ffmpeg -loglevel quiet -nostdin -i '${audio_file}' -ss ${start} $['-to ' + end if index != chapter_len else ''] ${title_slug}/${filename}" + append :job_queue ">&2 printf '[%d/%d] %s\\n' $[index] $[chapter_len] \"$[output_data['chapters'][index - 1]['title']]\"; ffmpeg -loglevel quiet -nostdin -i '${audio_file}' -ss ${start} $['-to ' + end if index !== chapter_len else ''] ${title_slug}/${filename}" } # Exit the process if an error detected. diff --git a/emacs/modules/tools/wiki/README.org b/emacs/modules/tools/wiki/README.org index 5f19878..a1001bb 100755 --- a/emacs/modules/tools/wiki/README.org +++ b/emacs/modules/tools/wiki/README.org @@ -1,6 +1,6 @@ #+title: tools/wiki -#+date: "2021-05-05 00:27:26 +08:00" -#+date_modified: "2021-05-21 11:12:10 +08:00" +#+date: 2021-05-05 00:27:26 +08:00 +#+date_modified: 2021-05-21 11:12:10 +08:00 #+language: en @@ -40,4 +40,3 @@ This module has a handful of requirements to work properly. - SQLite v3 binary is installed in order for org-roam to work. - The ~+anki~ feature requires Anki and the setup described from the [[https://github.com/louietan/anki-editor][project README]]. -- ~+graph~ feature needs [[https://github.com/briandowns/simple-httpd][simple-httpd]] for the server to work. diff --git a/emacs/modules/tools/wiki/config.el b/emacs/modules/tools/wiki/config.el index 680e5d8..1689160 100755 --- a/emacs/modules/tools/wiki/config.el +++ b/emacs/modules/tools/wiki/config.el @@ -21,7 +21,7 @@ :hook (org-load . org-roam-mode) :commands (org-roam-buffer - org-roam-setup + org-roam-db-autosync-mode org-roam-capture org-roam-node-find) :preface @@ -36,8 +36,6 @@ :desc "Go to a random node and split" "R" #'+org-roam-split-to-random-node :desc "Find node" "f" #'org-roam-node-find :desc "Org Roam capture" "c" #'org-roam-capture - :desc "Org Roam setup" "s" #'org-roam-setup - :desc "Org Roam teardown" "S" #'org-roam-teardown :desc "Open backlinks buffer" "b" #'org-roam-buffer-toggle (:prefix ("d" . "dailies") diff --git a/nvim/init.lua b/nvim/init.lua index bd861d8..05b3a35 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -22,8 +22,8 @@ end cmd [[packadd packer.nvim]] -- Plugins require("packer").startup(function() - -- Let the package manager manage itself. - use { "wbthomason/packer.nvim", opt = true } + -- Let the package manager manage itself. + use { "wbthomason/packer.nvim", opt = true } -- THEMES! use { "chriskempson/base16-vim" } @@ -31,11 +31,11 @@ require("packer").startup(function() -- Custom color themes! use { "rktjmp/lush.nvim" } - -- EditorConfig plugin - use { "editorconfig/editorconfig-vim" } - - -- Colorize common color strings - use { + -- EditorConfig plugin + use { "editorconfig/editorconfig-vim" } + + -- Colorize common color strings + use { "norcalli/nvim-colorizer.lua", config = function() require"colorizer".setup() @@ -46,21 +46,21 @@ require("packer").startup(function() -- Our custom theme use { "~/.config/nvim/lua/lush_theme/fds-theme.lua" } - -- A snippets engine. - -- One of the must-haves for me. - use { + -- A snippets engine. + -- One of the must-haves for me. + use { "sirver/ultisnips", config = function() vim.g.UltiSnipsEditSplit = "context" vim.g.UltiSnipsSnippetDirectories = {vim.env.HOME .. "/.config/nvim/own-snippets", ".snippets"} end, - -- Contains various snippets for UltiSnips. + -- Contains various snippets for UltiSnips. requires = "honza/vim-snippets" } - -- Text editor integration for the browser - use {"subnut/nvim-ghost.nvim", run = ":call nvim_ghost#installer#install()"} + -- Text editor integration for the browser + use {"subnut/nvim-ghost.nvim", run = ":call nvim_ghost#installer#install()"} -- Fuzzy finder of lists use { @@ -68,7 +68,7 @@ require("packer").startup(function() requires = { {"nvim-lua/popup.nvim"}, {"nvim-lua/plenary.nvim"} } } - -- A completion engine. + -- A completion engine. -- nvim-cmp is mostly explicit by making the configuration process manual unlike bigger plugins like CoC use { "hrsh7th/nvim-cmp", @@ -107,109 +107,108 @@ require("packer").startup(function() mapping = { [""] = cmp.mapping(function(fallback) - if fn.pumvisible() == 1 then + if cmp.visible() then if fn["UltiSnips#CanExpandSnippet"]() == 1 then return fn.feedkeys(t("=UltiSnips#ExpandSnippet()")) end - fn.feedkeys(t(""), "n") + cmp.select_next_item() elseif check_back_space() then fn.feedkeys(t(""), "n") else fallback() end - end, { - "i", - "s", - }), - - [""] = cmp.mapping(function(fallback) - if fn.complete_info()["selected"] == -1 and fn["UltiSnips#CanExpandSnippet"]() == 1 then - fn.feedkeys(t("=UltiSnips#ExpandSnippet()")) - elseif fn["UltiSnips#CanJumpForwards"]() == 1 then - fn.feedkeys(t(":call UltiSnips#JumpForwards()")) - elseif fn.pumvisible() == 1 then - fn.feedkeys(t(""), "n") - elseif check_back_space() then - fn.feedkeys(t(""), "n") - else - fallback() - end end, { - "i", - "s", - }), + "i", + "s", + }), - [""] = cmp.mapping(function(fallback) - if fn["UltiSnips#CanJumpBackwards"]() == 1 then - return fn.feedkeys(t("=UltiSnips#JumpBackwards()")) - elseif fn.pumvisible() == 1 then - fn.feedkeys(t(""), "n") - else - fallback() - end - end, { - "i", - "s", - }), - } - }) - end + [""] = cmp.mapping(function(fallback) + if fn.complete_info()["selected"] == -1 and fn["UltiSnips#CanExpandSnippet"]() == 1 then + fn.feedkeys(t("=UltiSnips#ExpandSnippet()")) + elseif fn["UltiSnips#CanJumpForwards"]() == 1 then + fn.feedkeys(t(":call UltiSnips#JumpForwards()")) + elseif cmp.visible() then + cmp.select_next_item() + elseif check_back_space() then + fn.feedkeys(t(""), "n") + else + fallback() + end + end, { + "i", + "s", + }), + + [""] = cmp.mapping(function(fallback) + if fn["UltiSnips#CanJumpBackwards"]() == 1 then + return fn.feedkeys(t("=UltiSnips#JumpBackwards()")) + elseif cmp.visible() then + cmp.select_previous_item() + else + fallback() + end + end, { + "i", + "s", + }), + }}) + end } - -- A linting engine, a DAP client, and an LSP client entered into a bar. - use { "dense-analysis/ale" } - use { "neovim/nvim-lspconfig" } - use { "mfussenegger/nvim-dap" } + -- A linting engine, a DAP client, and an LSP client entered into a bar. + use { "dense-analysis/ale" } + use { "neovim/nvim-lspconfig" } + use { "mfussenegger/nvim-dap" } - -- One of the most popular plugins. - -- Allows to create more substantial status bars. - use { "vim-airline/vim-airline" } + -- One of the most popular plugins. + -- Allows to create more substantial status bars. + use { "vim-airline/vim-airline" } - -- Fuzzy finder for finding files freely and fastly. - use { + -- Fuzzy finder for finding files freely and fastly. + use { "junegunn/fzf", requires = "junegunn/fzf.vim" } - -- A full LaTeX toolchain plugin for Vim. - -- Also a must-have for me since writing LaTeX can be a PITA. - -- Most of the snippets and workflow is inspired from Gilles Castel's posts (at https://castel.dev/). - use { - "lervag/vimtex", - cmd = "ALEEnable", - config = function() - -- Vimtex configuration - g["tex_flavor"] = "latex" - g["vimtex_view_method"] = "zathura" - g["vimtex_quickfix_mode"] = 0 - g["tex_conceal"] = "abdmg" - g["vimtex_compiler_latexmk"] = { - options = { - "-bibtex", - "-shell-escape", - "-verbose", - "-file-line-error", - } - } + -- A full LaTeX toolchain plugin for Vim. + -- Also a must-have for me since writing LaTeX can be a PITA. + -- Most of the snippets and workflow is inspired from Gilles Castel's posts (at https://castel.dev/). + use { + "lervag/vimtex", + cmd = "ALEEnable", + config = function() + -- Vimtex configuration + g["tex_flavor"] = "latex" + g["vimtex_view_method"] = "zathura" + g["vimtex_quickfix_mode"] = 0 + g["tex_conceal"] = "abdmg" + g["vimtex_compiler_latexmk"] = { + options = { + "-bibtex", + "-shell-escape", + "-verbose", + "-file-line-error", + } + } - -- I use LuaLaTeX for my documents so let me have it as the default, please? - g["vimtex_compiler_latexmk_engines"] = { - _ = "-lualatex", - pdflatex = "-pdf", - dvipdfex = "-pdfdvi", - lualatex = "-lualatex", - xelatex = "-xelatex", - } - end - } + -- I use LuaLaTeX for my documents so let me have it as the default, please? + g["vimtex_compiler_latexmk_engines"] = { + _ = "-lualatex", + pdflatex = "-pdf", + dvipdfex = "-pdfdvi", + lualatex = "-lualatex", + xelatex = "-xelatex", + } + end + } - -- Enable visuals for addition/deletion of lines in the gutter (side) similar to Visual Studio Code. - use { "airblade/vim-gitgutter" } + -- Enable visuals for addition/deletion of lines in the gutter (side) similar to Visual Studio Code. + use { "airblade/vim-gitgutter" } - -- Language plugins. - use { "LnL7/vim-nix" } - use { "vmchale/dhall-vim" } + -- Language plugins. + use { "LnL7/vim-nix" } + use { "vmchale/dhall-vim" } end) -- g['UltiSnipsExpandTrigger'] = "" @@ -219,12 +218,12 @@ local t = function(str) end local check_back_space = function() - local col = fn.col('.') - 1 - if col == 0 or fn.getline('.'):sub(col, col):match('%s') then - return true - else - return false - end + local col = fn.col('.') - 1 + if col == 0 or fn.getline('.'):sub(col, col):match('%s') then + return true + else + return false + end end -- Editor configuration