diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 5cabdc6..701c688 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -115,9 +115,9 @@ M.general = { }, [""] = {" close ", "close window"}, - -- yank from cusor to eol to system and primary clipboard - ["y"] = {'"*y$"+y$'}, + -- yank from cusor to eol to system and primary clipboard + ["y"] = {'"*y$"+y$', "yank from cursor to eol to primary and clipboard"}, -- folding levels ["f0"] = {":set foldlevel=0", "set fold level"}, @@ -147,7 +147,15 @@ M.general = { os.execute("echo do >" .. fifo_patch ) end, "notify " - } + }, + + + -- config files + -- ["ev"] = { + -- function() + -- local vim_config_files = {""} + -- end + -- , "edit vim config"}, }, t = { [""] = { termcodes "", "escape terminal mode" } }, @@ -365,6 +373,31 @@ M.nvimtree = { }, } +M.fzf_lua = { + plugin = true, + + n = { + -- find + [""] = { " FzfLua files ", "find files" }, + + -- grep + ["fw"] = { " FzfLua grep_cword ", "grep cword" }, + ["f."] = { " FzfLua live_grep_native ", "grep live native" }, + ["f*"] = { " FzfLua live_grep_glob ", "grep with glob (SPACE-- globs)"}, + + -- continue + ["ff"] = { " FzfLua resume ", "resume last search"}, + + [";"] = { " FzfLua buffers ", "find buffers" }, + ["fb"] = { " FzfLua builtins ", "FzfLua builtins" }, + ["fh"] = { " FzfLua help_tags ", "find help pages" }, + ["fo"] = { " FzfLua oldfiles ", "find oldfiles" }, + ["tk"] = { " lua require'custom.plugins.fzflua'.keymaps() ", "show keymaps" }, + + } +} + + M.telescope = { plugin = true, diff --git a/lua/custom/init.lua b/lua/custom/init.lua index d888197..5b840de 100644 --- a/lua/custom/init.lua +++ b/lua/custom/init.lua @@ -1,12 +1,17 @@ +-- vim modeline +-- vim: foldmarker={,} foldmethod=marker + -- local augroup = vim.api.nvim_create_augroup -- local autocmd = vim.api.nvim_create_autocmd + +-- highlights { vim.cmd [[ hi CursorLine gui=underline ]] +--} - --- Shift key typos +-- Shift key typos{ vim.cmd [[ command! -bang -nargs=* -complete=file E e command! -bang -nargs=* -complete=file W w @@ -19,7 +24,9 @@ vim.cmd [[ command! -bang QA qa command! -bang Qa qa ]] +--} +-- suckless { vim.cmd [[ " Autocompile suckless let dwm_file_patterns = expand("$HOME/.local/src/suckless/*/{config.h,*.c}") @@ -32,11 +39,32 @@ vim.cmd [[ "au BufWrite */src/*/dwm*/{*.h,dwm.c} :AsyncRun! make clean && make && sudo make install augroup END ]] +--} --- Make asyncrun work with fugitive +-- Make asyncrun work with fugitive { vim.cmd [[ augroup asyncrun au! command -bang -nargs=* -complete=file Make AsyncRun -program=make @ augroup END ]] +--} + +-- gopass{ +vim.cmd [[ + augroup gopass + au! + au BufNewFile,BufRead /dev/shm/gopass* setlocal noswapfile nobackup noundofile + augroup END +]] +--} + +-- plantuml { +vim.cmd [[ + au FileType plantuml let g:plantuml_previewer#plantuml_jar_path = get( + \ matchlist(system('cat `which plantuml` | grep plantuml.jar'), '\v.*\s[''"]?(\S+plantuml\.jar).*'), + \ 1, + \ 0 + \) +]] +-- } diff --git a/lua/custom/plugins/configs/fzflua.lua b/lua/custom/plugins/configs/fzflua.lua new file mode 100644 index 0000000..83775bd --- /dev/null +++ b/lua/custom/plugins/configs/fzflua.lua @@ -0,0 +1,70 @@ +local present, fzf = pcall(require, "fzf-lua") + +if not present then + return +end + +fzf.register_ui_select() + +local options = { + + fzf_opts = { + ['--layout'] = 'default', + ['--padding'] = '3%,1%' + }, + + winopts = { + fullscreen = false + }, + + previewers = { + man = { + cmd = "man %s | col -bx", + } + }, + + files = { + previewer = "bat_native", + file_icons = true, + color_icons = false, + winopts = { + fullscreen = true + }, + + }, + oldfiles = { + color_icons = false, + }, + + grep = { + previewer = "bat_native", + file_icons = false, + color_icons = false, + winopts = { + fullscreen = true + }, + }, + + buffers = { + color_icons = false + }, + + lines = { + color_icons = false + }, + + git = { + status = { + preview_pager = "delta --width=$FZF_PREVIEW_COLUMNS", + }, + + files = { + color_icons = false, + winopts = { + fullscreen = true + }, + } + }, +} + +fzf.setup(options) diff --git a/lua/custom/plugins/fzflua.lua b/lua/custom/plugins/fzflua.lua new file mode 100644 index 0000000..73f39f6 --- /dev/null +++ b/lua/custom/plugins/fzflua.lua @@ -0,0 +1,53 @@ +local core = require "fzf-lua.core" +local utils = require "fzf-lua.utils" +local config = require "fzf-lua.config" + +M = {} + +M.keymaps = function(opts) + + opts = config.normalize_opts(opts, config.globals.nvim.keymaps) + if not opts then return end + + local modes = { + n = "blue", + i = "red", + c = "yellow" + } + local keymaps = {} + + local add_keymap = function(keymap) + -- hijack fields + local keymap_desc = keymap.desc == nil and keymap.rhs or keymap.desc + keymap.str = string.format("%s │ %-40s │ %s", + utils.ansi_codes[modes[keymap.mode] or "blue"](keymap.mode), + keymap.lhs:gsub("%s", ""), + keymap_desc) + + local k = string.format("[%s:%s:%s]", + keymap.buffer, keymap.mode, keymap.lhs) + keymaps[k] = keymap + end + + for mode, _ in pairs(modes) do + local global = vim.api.nvim_get_keymap(mode) + for _, keymap in pairs(global) do + add_keymap(keymap) + end + local buf_local = vim.api.nvim_buf_get_keymap(0, mode) + for _, keymap in pairs(buf_local) do + add_keymap(keymap) + end + end + + local entries = {} + for _, v in pairs(keymaps) do + table.insert(entries, v.str) + end + + opts.fzf_opts['--no-multi'] = '' + + core.fzf_exec(entries, opts) +end + +return M diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 930e218..6349a96 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -11,6 +11,19 @@ return { ["folke/which-key.nvim"] = { disable = false, }, + ["nvim-telescope/telescope.nvim"] = { + disable = true + }, + ["ibhagwan/fzf-lua"] = { + after = "ui", + config = function() + require("custom.plugins.configs.fzflua") + require("plugins.configs.others").devicons() + end, + setup = function() + require("core.utils").load_mappings "fzf_lua" + end + }, -- Run async commands (make & errors) ["skywind3000/asyncrun.vim"] = { config = function() @@ -18,6 +31,16 @@ return { vim.g.asyncrun_open = 8 end }, + -- restore view + ["vim-scripts/restore_view.vim"] = {}, + + -- Read info files + ["https://gitlab.com/HiPhish/info.vim.git"] = { + cmd = "Info", + setup = function() + require("custom.plugins.info").set_mappings() + end + }, ["L3MON4D3/LuaSnip"] = { config = function() -- load default config first