# HG changeset patch # User Meredith Howard # Date 1714934371 18000 # Node ID 0e7310186a5747808ed2f8a2cc9c165c523f18c7 # Parent a237720efee9349486c04de961cb9d7b16f7fe3e luafy AutoFmtToggle diff --git a/.config/nvim/autoload/vimrc.vim b/.config/nvim/autoload/vimrc.vim deleted file mode 100644 --- a/.config/nvim/autoload/vimrc.vim +++ /dev/null @@ -1,21 +0,0 @@ -func! vimrc#AutoFmtToggle() abort - if &formatoptions =~# 'a' - setl formatoptions-=a | echo '-a' - else - setl formatoptions+=a | echo '+a' - endif -endfunc - -func! vimrc#SafeFilterFile(cmd) - let errors = tempname() - try - exec 'silent %!' . a:cmd . ' 2>' . shellescape(errors) - if v:shell_error - for line in readfile(errors) - echomsg line - endfor - endif - finally - call delete(errors) - endtry -endfunc diff --git a/.config/nvim/lua/config/maps.lua b/.config/nvim/lua/config/maps.lua --- a/.config/nvim/lua/config/maps.lua +++ b/.config/nvim/lua/config/maps.lua @@ -66,7 +66,16 @@ map("n", "te", ":Tabularize firs map("n", "tc", ":Tabularize first_colon") map("n", "tm", ":Tabularize methods") -map("n", "a", ":call vimrc#AutoFmtToggle()") +map("n", "a", function() + local fo = vim.bo.formatoptions + if fo:find("a") then + vim.bo.formatoptions = fo:gsub("a", "") + vim.print("-a") + else + vim.bo.formatoptions = fo .. "a" + vim.print("+a") + end +end) -- LSP features