diff --git a/init.lua b/init.lua index 96a7f05..46cb33d 100644 --- a/init.lua +++ b/init.lua @@ -24,4 +24,7 @@ if fn.empty(fn.glob(install_path)) > 0 then vim.cmd "PackerSync" end -pcall(require, "custom") +-- pcall(require, "custom") + +local vimscriptsfolder = vim.env.XDG_CONFIG_HOME .. "/nvim/myvimscript" -- relative to .config/nvim dir +vim.opt.runtimepath:prepend(vimscriptsfolder) diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index b33b0e6..ca5dc6b 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -366,6 +366,12 @@ M.general = { --{{{ -- "enable Treesitter folding"} }, --}}} + + -- operator pending + o = { + ["S"] = {"(leap-forward-to)"}, + }, + -- visual exclusive mode (ignore select) x = { -- {{{ @@ -662,7 +668,7 @@ M.fzf_lua = { --{{{ -- grep -- ["fw"] = { " FzfLua grep_cword ", "FzfLua grep cword" }, - -- ["f."] = { " FzfLua live_grep_native ", "FzfLua grep live native" }, + ["ff"] = { " FzfLua live_grep_native ", "FzfLua grep live native" }, -- ["ff"] = { " FzfLua grep_project ", "FzfLua grep live project" }, ["f*"] = { " FzfLua live_grep_glob ", "FzfLua grep with glob (SPACE-- globs)" }, @@ -693,7 +699,8 @@ M.telescope = { --{{{ local ignored_bufs = { "qf", "guihua", - "NvimT*" + "NvimT*", + "aerial*", } for _, ignored in ipairs(ignored_bufs) do if vim.o.filetype:match(ignored) then @@ -839,7 +846,7 @@ M.blankline = { --{{{ M.aerial = { plugin = true, n = { - [""] = { " AerialToggle! right" }, + [""] = { " AerialOpen right" }, } } @@ -916,6 +923,14 @@ M.golang = { } } +M["todo-comments"] = { + plugin = true, + n = { + ["]t"] = {" lua require'todo-comments'.jump_next()", "jump to next todo"}, + ["[t"] = {" lua require'todo-comments'.jump_prev()", "jump to prev todo"} + } +} + -- git M.gitsigns = { plugin = true, diff --git a/lua/custom/chadrc.lua b/lua/custom/chadrc.lua index d51f400..fa3fffb 100644 --- a/lua/custom/chadrc.lua +++ b/lua/custom/chadrc.lua @@ -14,8 +14,8 @@ local colors = { -- vim.tbl_deep_extend("force", M.ui.hl_add, custom_theme) M.ui = { - theme = "monekai", - theme_toggle = { "monekai", "gruvbox_light" }, + theme = "gruvbox_material", + theme_toggle = { "gruvbox_material", "gruvbox_light" }, hl_override = { Comment = { fg = "light_grey" diff --git a/lua/custom/init.lua b/lua/custom/init.lua index 0f6b0d1..2abc5b2 100644 --- a/lua/custom/init.lua +++ b/lua/custom/init.lua @@ -9,8 +9,8 @@ -- if character under cursor is number -- use normal C-x or close window -local vimscriptsfolder = vim.env.XDG_CONFIG_HOME .. "/nvim/myvimscript" -- relative to .config/nvim dir -vim.opt.runtimepath:prepend(vimscriptsfolder) +-- local vimscriptsfolder = vim.env.XDG_CONFIG_HOME .. "/nvim/myvimscript" -- relative to .config/nvim dir +-- vim.opt.runtimepath:prepend(vimscriptsfolder) -- highlights { @@ -20,18 +20,18 @@ vim.opt.runtimepath:prepend(vimscriptsfolder) --} -- Shift key typos{ -vim.cmd [[ - command! -bang -nargs=* -complete=file E e - command! -bang -nargs=* -complete=file W w - command! -bang -nargs=* -complete=file Wq wq - command! -bang -nargs=* -complete=file WQ wq - command! -nargs=* -complete=help H h - command! -bang Wa wa - command! -bang WA wa - command! -bang Q q - command! -bang QA qa - command! -bang Qa qa -]] +-- vim.cmd [[ +-- command! -bang -nargs=* -complete=file E e +-- command! -bang -nargs=* -complete=file W w +-- command! -bang -nargs=* -complete=file Wq wq +-- command! -bang -nargs=* -complete=file WQ wq +-- command! -nargs=* -complete=help H h +-- command! -bang Wa wa +-- command! -bang WA wa +-- command! -bang Q q +-- command! -bang QA qa +-- command! -bang Qa qa +-- ]] --} @@ -53,29 +53,29 @@ vim.cmd [[ --} -- Make asyncrun work with fugitive { -vim.cmd [[ - augroup asyncrun - au! - command -bang -nargs=* -complete=file Make AsyncRun -program=make @ - augroup END -]] +-- 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 -]] +-- 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 - \) -]] +-- 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/aerial.lua b/lua/custom/plugins/configs/aerial.lua new file mode 100644 index 0000000..17be6b1 --- /dev/null +++ b/lua/custom/plugins/configs/aerial.lua @@ -0,0 +1,241 @@ +local M = {} + +local opts = { + -- Priority list of preferred backends for aerial. + -- This can be a filetype map (see :help aerial-filetype-map) + backends = { "treesitter", "lsp", "markdown", "man" }, + + layout = { + -- These control the width of the aerial window. + -- They can be integers or a float between 0 and 1 (e.g. 0.4 for 40%) + -- min_width and max_width can be a list of mixed types. + -- max_width = {40, 0.2} means "the lesser of 40 columns or 20% of total" + max_width = { 40, 0.2 }, + width = nil, + min_width = 10, + + -- Determines the default direction to open the aerial window. The 'prefer' + -- options will open the window in the other direction *if* there is a + -- different buffer in the way of the preferred direction + -- Enum: prefer_right, prefer_left, right, left, float + default_direction = "prefer_right", + + -- Determines where the aerial window will be opened + -- edge - open aerial at the far right/left of the editor + -- window - open aerial to the right/left of the current window + placement = "edge", + }, + + -- Determines how the aerial window decides which buffer to display symbols for + -- window - aerial window will display symbols for the buffer in the window from which it was opened + -- global - aerial window will display symbols for the current window + attach_mode = "global", + + -- List of enum values that configure when to auto-close the aerial window + -- unfocus - close aerial when you leave the original source window + -- switch_buffer - close aerial when you change buffers in the source window + -- unsupported - close aerial when attaching to a buffer that has no symbol source + close_automatic_events = {}, + + -- Set to false to remove the default keybindings for the aerial buffer + default_bindings = true, + + -- Disable aerial on files with this many lines + disable_max_lines = 10000, + + -- Disable aerial on files this size or larger (in bytes) + disable_max_size = 2000000, -- Default 2MB + + -- A list of all symbols to display. Set to false to display all symbols. + -- This can be a filetype map (see :help aerial-filetype-map) + -- To see all available values, see :help SymbolKind + filter_kind = { + "Class", + "Constructor", + "Enum", + "Function", + "Interface", + "Module", + "Method", + "Struct", + }, + + -- Determines line highlighting mode when multiple splits are visible. + -- split_width Each open window will have its cursor location marked in the + -- aerial buffer. Each line will only be partially highlighted + -- to indicate which window is at that location. + -- full_width Each open window will have its cursor location marked as a + -- full-width highlight in the aerial buffer. + -- last Only the most-recently focused window will have its location + -- marked in the aerial buffer. + -- none Do not show the cursor locations in the aerial window. + highlight_mode = "split_width", + + -- Highlight the closest symbol if the cursor is not exactly on one. + highlight_closest = true, + + -- Highlight the symbol in the source buffer when cursor is in the aerial win + highlight_on_hover = false, + + -- When jumping to a symbol, highlight the line for this many ms. + -- Set to false to disable + highlight_on_jump = 300, + + -- Define symbol icons. You can also specify "Collapsed" to change the + -- icon when the tree is collapsed at that symbol, or "Collapsed" to specify a + -- default collapsed icon. The default icon set is determined by the + -- "nerd_font" option below. + -- If you have lspkind-nvim installed, it will be the default icon set. + -- This can be a filetype map (see :help aerial-filetype-map) + icons = {}, + + -- Control which windows and buffers aerial should ignore. + -- If attach_mode is "global", focusing an ignored window/buffer will + -- not cause the aerial window to update. + -- If open_automatic is true, focusing an ignored window/buffer will not + -- cause an aerial window to open. + -- If open_automatic is a function, ignore rules have no effect on aerial + -- window opening behavior; it's entirely handled by the open_automatic + -- function. + ignore = { + -- Ignore unlisted buffers. See :help buflisted + unlisted_buffers = true, + + -- List of filetypes to ignore. + filetypes = {}, + + -- Ignored buftypes. + -- Can be one of the following: + -- false or nil - No buftypes are ignored. + -- "special" - All buffers other than normal buffers are ignored. + -- table - A list of buftypes to ignore. See :help buftype for the + -- possible values. + -- function - A function that returns true if the buffer should be + -- ignored or false if it should not be ignored. + -- Takes two arguments, `bufnr` and `buftype`. + buftypes = "special", + + -- Ignored wintypes. + -- Can be one of the following: + -- false or nil - No wintypes are ignored. + -- "special" - All windows other than normal windows are ignored. + -- table - A list of wintypes to ignore. See :help win_gettype() for the + -- possible values. + -- function - A function that returns true if the window should be + -- ignored or false if it should not be ignored. + -- Takes two arguments, `winid` and `wintype`. + wintypes = "special", + }, + + -- When you fold code with za, zo, or zc, update the aerial tree as well. + -- Only works when manage_folds = true + link_folds_to_tree = true, + + -- Fold code when you open/collapse symbols in the tree. + -- Only works when manage_folds = true + link_tree_to_folds = true, + + -- Use symbol tree for folding. Set to true or false to enable/disable + -- 'auto' will manage folds if your previous foldmethod was 'manual' + manage_folds = true, + + -- Set default symbol icons to use patched font icons (see https://www.nerdfonts.com/) + -- "auto" will set it to true if nvim-web-devicons or lspkind-nvim is installed. + nerd_font = "auto", + + -- Call this function when aerial attaches to a buffer. + -- Useful for setting keymaps. Takes a single `bufnr` argument. + on_attach = nil, + + -- Call this function when aerial first sets symbols on a buffer. + -- Takes a single `bufnr` argument. + on_first_symbols = nil, + + -- Automatically open aerial when entering supported buffers. + -- This can be a function (see :help aerial-open-automatic) + open_automatic = false, + + -- Run this command after jumping to a symbol (false will disable) + post_jump_cmd = "normal! zz", + + -- When true, aerial will automatically close after jumping to a symbol + close_on_select = false, + + -- Show box drawing characters for the tree hierarchy + show_guides = false, + + -- The autocmds that trigger symbols update (not used for LSP backend) + update_events = "TextChanged,InsertLeave", + + -- Customize the characters used when show_guides = true + guides = { + -- When the child item has a sibling below it + mid_item = "├─", + -- When the child item is the last in the list + last_item = "└─", + -- When there are nested child guides to the right + nested_top = "│ ", + -- Raw indentation + whitespace = " ", + }, + + -- Options for opening aerial in a floating win + float = { + -- Controls border appearance. Passed to nvim_open_win + border = "rounded", + + -- Determines location of floating window + -- cursor - Opens float on top of the cursor + -- editor - Opens float centered in the editor + -- win - Opens float centered in the window + relative = "cursor", + + -- These control the height of the floating window. + -- They can be integers or a float between 0 and 1 (e.g. 0.4 for 40%) + -- min_height and max_height can be a list of mixed types. + -- min_height = {8, 0.1} means "the greater of 8 rows or 10% of total" + max_height = 0.9, + height = nil, + min_height = { 8, 0.1 }, + + override = function(conf, source_winid) + -- This is the config that will be passed to nvim_open_win. + -- Change values here to customize the layout + return conf + end, + }, + + lsp = { + -- Fetch document symbols when LSP diagnostics update. + -- If false, will update on buffer changes. + diagnostics_trigger_update = true, + + -- Set to false to not update the symbols when there are LSP errors + update_when_errors = true, + + -- How long to wait (in ms) after a buffer change before updating + -- Only used when diagnostics_trigger_update = false + update_delay = 300, + }, + + treesitter = { + -- How long to wait (in ms) after a buffer change before updating + update_delay = 300, + }, + + markdown = { + -- How long to wait (in ms) after a buffer change before updating + update_delay = 300, + }, + + man = { + -- How long to wait (in ms) after a buffer change before updating + update_delay = 300, + }, +} + +M.setup = function() + require("aerial").setup(opts) +end + +return M diff --git a/lua/custom/plugins/configs/gitsigns.lua b/lua/custom/plugins/configs/gitsigns.lua index 49db3f5..5170d7d 100644 --- a/lua/custom/plugins/configs/gitsigns.lua +++ b/lua/custom/plugins/configs/gitsigns.lua @@ -2,7 +2,7 @@ local M = {} local on_attach = function(bufnr) - require("custom.utils").set_plugin_mappings "gitsigns" + require("spike.utils").set_plugin_mappings "gitsigns" end M.setup = function() diff --git a/lua/custom/plugins/configs/plantuml.lua b/lua/custom/plugins/configs/plantuml.lua new file mode 100644 index 0000000..c5daacc --- /dev/null +++ b/lua/custom/plugins/configs/plantuml.lua @@ -0,0 +1,35 @@ +local autocmd = vim.api.nvim_create_autocmd +local M = {} + +M.lazy_load_module = function() + + + autocmd({"BufRead", "BufNewFile"},{ + group = vim.api.nvim_create_augroup("plantuml", {}), + callback = function() + plantuml_patterns = { + "%.pu", "%.uml", "%.plantuml", "%.puml", "%.iuml" + } + + local bufname = vim.api.nvim_buf_get_name(0) + for _,ft in ipairs(plantuml_patterns) do + if vim.fn.fnamemodify(bufname, ":t"):match(ft) then + vim.defer_fn(function() + require("packer").loader("plantuml-syntax") + end,0) + end + end + + firstline = vim.api.nvim_buf_get_lines(0,0,1,true)[1] + P(firstline) + if firestline ~= "" and firstline:match("^@startuml%s*") then + vim.defer_fn(function() + require("packer").loader("plantuml-syntax") + end,0) + end + end + }) + +end + +return M diff --git a/lua/custom/plugins/configs/todo-comments.lua b/lua/custom/plugins/configs/todo-comments.lua index 1160d3e..74c3b6a 100644 --- a/lua/custom/plugins/configs/todo-comments.lua +++ b/lua/custom/plugins/configs/todo-comments.lua @@ -8,15 +8,23 @@ M = {} local config = { keywords = { - ["_TODO"] = { color = "warning"}, - ["LEARN"] = { color = "hint" }, - ["WIP"] = { color = "default"}, + ["_TODO"] = { + color = "warning", + alt = {"TODO!"}, -- a set of other keywords that all map to this FIX keywords + }, + LEARN = { color = "hint" }, + WIP = { color = "default"}, + NOTE = { alt = { "TIP", "INFO", "TRICK" }}, + DEBUG = {} }, colors = { info = {"#2563EB"}, hint = {"#10B981"}, default = {"#8C3AED" }, }, + highlight = { + after = "fg", + } } M.setup = function() diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 458bda7..14394ed 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -150,6 +150,10 @@ return { ["folke/todo-comments.nvim"] = { -- {{{ after = "nvim-treesitter", + setup = function() + -- require("core.lazy_load").on_file_open "todo-comments" + require("core.utils").load_mappings "todo-comments" + end, config = function() require("custom.plugins.configs.todo-comments").setup() end @@ -327,6 +331,9 @@ return { end }, -- }}} + -- TODO: asynctsks vs overseer: task runner and job management + -- ["stevarc/overseer.nvim"] = {}, + -- Git ["lewis6991/gitsigns.nvim"] = { ft = "gitcommit", @@ -463,7 +470,7 @@ return { end, }, ["ray-x/guihua.lua"] = { - lock = false, + lock = true, module = { "navigator" }, run = "cd lua/fzy && make", config = function() @@ -515,12 +522,13 @@ return { -- ['stevearc/aerial.nvim'] = { + lock = true, after = { "base46" }, keys = { "" }, cmd = { "Aerial*" }, config = function() require("core.utils").load_mappings "aerial" - require('aerial').setup({}) + require("custom.plugins.configs.aerial").setup() end }, @@ -624,7 +632,22 @@ return { config = function() require("custom.plugins.configs.rust-tools").setup() end - } -- }}} + }, -- }}} + + + -- PlantUML + ["aklt/plantuml-syntax"] = { + opt = true, + setup = function() + require("custom.plugins.configs.plantuml").lazy_load_module() + end + }, + ["weirongxu/plantuml-previewer.vim"] = { + ft = {"plantuml"}, + }, + ["scrooloose/vim-slumlord"] = { + ft = {"plantuml"}, + } -- sql tools -- https://github.com/tpope/vim-dadbod diff --git a/lua/custom/plugins/nvchadui.lua b/lua/custom/plugins/nvchadui.lua index 68f02a1..5dc6d7f 100644 --- a/lua/custom/plugins/nvchadui.lua +++ b/lua/custom/plugins/nvchadui.lua @@ -4,6 +4,7 @@ local fn = vim.fn local sep_style = vim.g.statusline_sep_style local separators = (type(sep_style) == "table" and sep_style) or require("nvchad_ui.icons").statusline_separators[sep_style] +local sep_l = separators["left"] local sep_r = separators["right"] local myicons = require("custom.chadrc").ui.myicons @@ -71,7 +72,7 @@ return { filename = " " .. filename .. " " end - return "%#St_file_info#" .. icon .. filename .. modified .. "%#St_file_sep#" .. sep_r + return "%#St_file_info#" .. icon .. filename .. "[%n] " .. modified .. "%#St_file_sep#" .. sep_r end, LSP_Diagnostics = function() @@ -138,4 +139,11 @@ return { return lsp_status .. dap_status end, + + cwd = function() + local dir_icon = "%#St_cwd_icon#" .. " " + local dir_name = "%#St_cwd_text#" .. " " .. fn.fnamemodify(fn.getcwd(), ":p:~") .. " " + return (vim.o.columns > 85 and ("%#St_cwd_sep#" .. sep_l .. dir_icon .. dir_name)) or "" + end, + } diff --git a/lua/custom/utils.lua b/lua/custom/utils.lua deleted file mode 100644 index a4ee939..0000000 --- a/lua/custom/utils.lua +++ /dev/null @@ -1,23 +0,0 @@ -local M = {} - - M.set_plugin_mappings = function(plugin_name, mapping_opt) - mappings = require("core.utils").load_config().mappings[plugin_name] - mappings.plugin = nil - - for mode, mode_values in pairs(mappings) do - local default_opts = vim.tbl_deep_extend("force", { mode = mode }, mapping_opt or {}) - for keybind, mapping_info in pairs(mode_values) do - -- merge default + user opts - local opts = vim.tbl_deep_extend("force", default_opts, mapping_info.opts or {}) - - mapping_info.opts, opts.mode = nil, nil - opts.desc = mapping_info[2] - - P(keybind) - vim.keymap.set(mode, keybind, mapping_info[1], opts) - end - end -end - - -return M diff --git a/lua/spike/utils.lua b/lua/spike/utils.lua index 4632d23..dfc1e95 100644 --- a/lua/spike/utils.lua +++ b/lua/spike/utils.lua @@ -1,4 +1,5 @@ local M = {} + M["unload_lua_ns"] = function (prefix) local prefix_with_dot = prefix .. '.' for key, _ in pairs(package.loaded) do @@ -25,4 +26,22 @@ M.reload_theme = function() require("base46").load_theme() end + M.set_plugin_mappings = function(plugin_name, mapping_opt) + mappings = require("core.utils").load_config().mappings[plugin_name] + mappings.plugin = nil + + for mode, mode_values in pairs(mappings) do + local default_opts = vim.tbl_deep_extend("force", { mode = mode }, mapping_opt or {}) + for keybind, mapping_info in pairs(mode_values) do + -- merge default + user opts + local opts = vim.tbl_deep_extend("force", default_opts, mapping_info.opts or {}) + + mapping_info.opts, opts.mode = nil, nil + opts.desc = mapping_info[2] + + vim.keymap.set(mode, keybind, mapping_info[1], opts) + end + end +end + return M diff --git a/mysnippets/lua.lua b/mysnippets/lua.lua index 3f51c0f..fdceb45 100644 --- a/mysnippets/lua.lua +++ b/mysnippets/lua.lua @@ -6,6 +6,15 @@ return { t"Hello lua snippet" }), + s({ trig = "lm", dscr = "local lua module"}, + fmt([[ +local M = {{}} + +{} + +return M + ]], { i(0) }) + ), -- repeat nodes -- TODO: split dot and pull last name @@ -30,5 +39,4 @@ return { ), - } diff --git a/mysnippets/lua.snippets b/mysnippets/lua.snippets index dd8d806..7cf0ba4 100644 --- a/mysnippets/lua.snippets +++ b/mysnippets/lua.snippets @@ -2,7 +2,3 @@ snippet fn function() $0 end - -snippet lm - local M = {} - $0 diff --git a/notes/TODO b/notes/TODO index d5c70d8..76486e7 100644 --- a/notes/TODO +++ b/notes/TODO @@ -1,3 +1,5 @@ +- [ ] Replacement to asyncrun ! + - Event when command is over to close quickfix window - [ ] setup task runner overseer.nvim - [ ] setup dadbod nvim for database work - [diffview.nvim] learn to use instead of fugitive ? diff --git a/plugin/spike/autocmd.vim b/plugin/spike/autocmd.vim index d6abfed..3903aa9 100644 --- a/plugin/spike/autocmd.vim +++ b/plugin/spike/autocmd.vim @@ -3,3 +3,22 @@ augroup DWM au BufWritePost */suckless/*/{*.c,*.h} :AsyncRun! make && doas make install " au BufWritePost */suckless/*/{*.h,*.c} :AsyncRun! make clean && make && doas make install" augroup END + +augroup PlantUml + 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 + \) +augroup END + + +augroup gopass + au! + au BufNewFile,BufRead /dev/shm/gopass* setlocal noswapfile nobackup noundofile +augroup END + +augroup asyncrun + au! + command -bang -nargs=* -complete=file Make AsyncRun -program=make @ +augroup END diff --git a/plugin/spike/commands.vim b/plugin/spike/commands.vim new file mode 100644 index 0000000..a7dff91 --- /dev/null +++ b/plugin/spike/commands.vim @@ -0,0 +1,11 @@ +"Shift key typos +command! -bang -nargs=* -complete=file E e +command! -bang -nargs=* -complete=file W w +command! -bang -nargs=* -complete=file Wq wq +command! -bang -nargs=* -complete=file WQ wq +command! -nargs=* -complete=help H h +command! -bang Wa wa +command! -bang WA wa +command! -bang Q q +command! -bang QA qa +command! -bang Qa qa