From 64d9d82afbe9fcdabc9e4b9c5f02bf12c093645c Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 11 Jul 2024 20:42:43 +0200 Subject: checkpoint --- config/essentials/vis/backup.lua | 6 +++++- config/essentials/vis/format.lua | 18 +++++++++--------- config/essentials/vis/fzf-mru.lua | 2 +- config/essentials/vis/visrc.lua | 8 ++++---- 4 files changed, 19 insertions(+), 15 deletions(-) (limited to 'config/essentials') diff --git a/config/essentials/vis/backup.lua b/config/essentials/vis/backup.lua index 7c44c60..2c8f0b8 100644 --- a/config/essentials/vis/backup.lua +++ b/config/essentials/vis/backup.lua @@ -20,6 +20,10 @@ end -- Before saving the file, copy the current contents of the file to a backup file vis.events.subscribe(vis.events.FILE_SAVE_PRE, function(file, path) + if file == nil then + return + end + if file.size > backup.byte_limit then return end @@ -46,7 +50,7 @@ vis.events.subscribe(vis.events.FILE_SAVE_PRE, function(file, path) end) -- Set defaults -backup.directory = os.getenv("XDG_DATA_HOME") .. "/Trash/vis-backups" +backup.directory = (os.getenv("XDG_DATA_HOME") or (os.getenv("HOME") .. "/.local/share")) .. "/Trash/vis-backups" backup.get_fname = backup.entire_path_with_double_percentage_signs diff --git a/config/essentials/vis/format.lua b/config/essentials/vis/format.lua index 67613a6..eefdc77 100644 --- a/config/essentials/vis/format.lua +++ b/config/essentials/vis/format.lua @@ -63,15 +63,15 @@ M.formatters = { end, }, luaformatter = M.stdio_formatter("lua-format"), - markdown = M.stdio_formatter(function(win) - if win.options and M.wrapwidth ~= 0 then - return "prettier --parser markdown --prose-wrap always " - .. ("--print-width " .. (M.wrapwidth - 1) .. " ") - .. M.with_filename(win, "--stdin-filepath ") - else - return "prettier --parser markdown " .. M.with_filename(win, "--stdin-filepath ") - end - end, { ranged = false }), + -- markdown = M.stdio_formatter(function(win) + -- if win.options and M.wrapwidth ~= 0 then + -- return "prettier --parser markdown --prose-wrap always " + -- .. ("--print-width " .. (M.wrapwidth - 1) .. " ") + -- .. M.with_filename(win, "--stdin-filepath ") + -- else + -- return "prettier --parser markdown " .. M.with_filename(win, "--stdin-filepath ") + -- end + -- end, { ranged = false }), powershell = M.stdio_formatter([[ "$( (command -v powershell.exe || command -v pwsh) 2>/dev/null )" -c ' Invoke-Formatter -ScriptDefinition ` diff --git a/config/essentials/vis/fzf-mru.lua b/config/essentials/vis/fzf-mru.lua index 455d083..8408dd7 100644 --- a/config/essentials/vis/fzf-mru.lua +++ b/config/essentials/vis/fzf-mru.lua @@ -10,7 +10,7 @@ Changes made: --]] local M = {} -M.fzf_filepath = os.getenv("XDG_CACHE_HOME") .. "/vis-fzf-mru" +M.fzf_filepath = (os.getenv("XDG_CACHE_HOME") or (os.getenv("HOME") .. "/.local/share")).. "/vis-fzf-mru" M.fzf_path = "fzf" M.fzf_args = "--height=40%" M.fzf_history = 20 diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua index 577712a..b56b6af 100644 --- a/config/essentials/vis/visrc.lua +++ b/config/essentials/vis/visrc.lua @@ -25,7 +25,7 @@ local format = require("format") -- set height to 40% local fzfmru = require("fzf-mru") -fzfmru.fzfmru_path = 'grep "^' .. os.getenv("PWD") .. '" | fzf' +fzfmru.fzfmru_path = 'grep "^' .. io.popen("pwd"):read("*a"):gsub("\n$", "") .. '" | fzf' -- todo: -- c-scope @@ -120,9 +120,9 @@ end) vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused args -- automatically cd in parent dir of file vis:command_register("cdp", function() - if win.file and win.file.path then - local dir = win.file.path:match(".*/") - vis:command("cd " .. dir) + if win and win.file and win.file.path then + -- local dir = win.file.path:match(".*/") + -- vis:info("cd " .. tostring(dir)) end end, "Cd to parent dir of file") -- cgit v1.2.3