diff --git a/CHEATSHEET.md b/CHEATSHEET.md index d433135..fb9354e 100644 --- a/CHEATSHEET.md +++ b/CHEATSHEET.md @@ -101,6 +101,7 @@ - `cc` replace whole line - `C` replace to the end of the line - `yy` copy the current line +- `yap` "yank-around-paragraph" - `p` paste yanked line below - `P` paste yanked line above diff --git a/CHEATSHEET.pdf b/CHEATSHEET.pdf index 50ca921..dfea447 100644 Binary files a/CHEATSHEET.pdf and b/CHEATSHEET.pdf differ diff --git a/lua/weeheavy/autocmd.lua b/lua/weeheavy/autocmd.lua new file mode 100644 index 0000000..5657543 --- /dev/null +++ b/lua/weeheavy/autocmd.lua @@ -0,0 +1,18 @@ +-- Highlight yanked text on e.g. yy,yap etc. +vim.api.nvim_create_autocmd("TextYankPost", { + desc = "Highlight when yanking (copying) text", + group = vim.api.nvim_create_augroup("weeheavy-highlight-yank", { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) + +-- Disable (relative) line numbers on Oil windows +vim.api.nvim_create_autocmd("FileType", { + group = vim.api.nvim_create_augroup("weeheavy-no-line-numbers-in-oil", { clear = true }), + pattern = { "oil" }, + callback = function() + vim.opt.relativenumber = false + vim.opt.number = false + end, +}) diff --git a/lua/weeheavy/init.lua b/lua/weeheavy/init.lua index 8e0376e..c43f64c 100644 --- a/lua/weeheavy/init.lua +++ b/lua/weeheavy/init.lua @@ -9,3 +9,6 @@ require("weeheavy.lazy") -- Other preferences require("weeheavy.prefs") + +-- Auto commands +require("weeheavy.autocmd") diff --git a/lua/weeheavy/plugins/lsp/lsp-zero.lua b/lua/weeheavy/plugins/lsp/lsp-zero.lua index eddc2b3..ec8dfbb 100644 --- a/lua/weeheavy/plugins/lsp/lsp-zero.lua +++ b/lua/weeheavy/plugins/lsp/lsp-zero.lua @@ -38,9 +38,7 @@ return { [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.confirm({ select = true }), -- accept LSP autocompletion - --[""] = cmp.mapping.select_prev_item(cmp_select), [""] = cmp.mapping.select_prev_item(cmp_select), - --[""] = cmp.mapping.select_next_item(cmp_select), [""] = cmp.mapping.select_next_item(cmp_select), [""] = cmp_action.luasnip_jump_forward(), [""] = cmp_action.luasnip_jump_backward(), @@ -67,7 +65,8 @@ return { lsp_zero.on_attach(function(client, bufnr) -- see :help lsp-zero-keybindings -- to learn the available actions - lsp_zero.default_keymaps({ buffer = bufnr }) + -- https://www.reddit.com/r/neovim/comments/1ankiu1/lsp_zero_go_to_definition_stopped_working/ + lsp_zero.default_keymaps({ buffer = bufnr, preserve_mappings = false }) end) require("mason").setup({ diff --git a/lua/weeheavy/plugins/lualine.lua b/lua/weeheavy/plugins/lualine.lua index 20c99cf..d85c666 100644 --- a/lua/weeheavy/plugins/lualine.lua +++ b/lua/weeheavy/plugins/lualine.lua @@ -22,6 +22,11 @@ local function hide_in_width() return vim.fn.winwidth(0) > 80 end +local function clock() + local time = tostring(os.date()):sub(12, 16) + return time +end + return { "nvim-lualine/lualine.nvim", lazy = true, @@ -29,21 +34,44 @@ return { opts = { options = { + globalstatus = false, -- true == single statusline icons_enabled = true, theme = "auto", - --component_separators = '⋮', - component_separators = "⁞", - --section_separators = { left = '', right = '' }, - --section_separators = { left = '', right = '' }, - section_separators = { left = "", right = "" }, + component_separators = "⋮", + --section_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, }, sections = { + lualine_a = { + { + -- shorten mode names + -- https://github.com/nvim-lualine/lualine.nvim/issues/614#issuecomment-1072275099 + "mode", + fmt = function(res) + return res:sub(1, 1) + end, + }, + }, + lualine_c = { + { "searchcount" }, + { + "buffers", + show_filename_only = false, + --fmt = function(str) + -- return str:sub(1, 1) + --end, + --fmt = function() + -- return string.gsub(vim.api.nvim_buf_get_name(0), vim.loop.cwd(), "") + --end, + }, + }, lualine_x = { -- specify full list of elements when adding custom things { "encoding" }, { "fileformat" }, { "filetype" }, { lsp_clients, cond = hide_in_width }, + { clock, cond = hide_in_width }, }, }, }, diff --git a/lua/weeheavy/plugins/oil.lua b/lua/weeheavy/plugins/oil.lua index 9b69e35..9de3a3f 100644 --- a/lua/weeheavy/plugins/oil.lua +++ b/lua/weeheavy/plugins/oil.lua @@ -24,6 +24,19 @@ return { ["e"] = "actions.close", [""] = "actions.select_vsplit", [""] = "actions.select_split", + [""] = "actions.close", + ["q"] = "actions.close", + }, + + float = { + -- Padding around the floating window + padding = 2, + max_width = 80, + max_height = 50, + border = "rounded", + win_options = { + winblend = 0, + }, }, }) end, diff --git a/lua/weeheavy/plugins/todo-comments.lua b/lua/weeheavy/plugins/todo-comments.lua new file mode 100644 index 0000000..ff39073 --- /dev/null +++ b/lua/weeheavy/plugins/todo-comments.lua @@ -0,0 +1,16 @@ +-- Highlight, list and search todo comments in your projects +-- https://github.com/folke/todo-comments.nvim +return { + "folke/todo-comments.nvim", + lazy = true, + event = "VimEnter", + -- TODO: a todo + -- WARN: a warning + -- PERF: a performance remark + -- NOTE: a note + -- FIXME: a fixme + dependencies = { + "nvim-lua/plenary.nvim", + }, + opts = { signs = false }, +} diff --git a/lua/weeheavy/prefs.lua b/lua/weeheavy/prefs.lua index 1fd4cdd..0afe92b 100644 --- a/lua/weeheavy/prefs.lua +++ b/lua/weeheavy/prefs.lua @@ -10,7 +10,7 @@ vim.opt.ignorecase = true vim.opt.smartcase = true -- Show line numbers default ---vim.opt.number = true +vim.opt.number = true -- Show relative line numbers vim.opt.relativenumber = true @@ -66,3 +66,6 @@ vim.opt.splitbelow = true -- Split windows appear to the right instead of left vim.opt.splitright = true + +-- Mode is shown in lualine, so we don't need it one line below +vim.opt.showmode = false diff --git a/lua/weeheavy/remap.lua b/lua/weeheavy/remap.lua index 23c9860..a722952 100644 --- a/lua/weeheavy/remap.lua +++ b/lua/weeheavy/remap.lua @@ -3,24 +3,17 @@ -- Leader key set to space, base for any key combo vim.g.mapleader = " " -vim.keymap.set("n", "r", vim.cmd.Ex, { noremap = true, desc = "netrw File Browser" }) -- netrw file explorer - +--vim.keymap.set("n", "r", vim.cmd.Ex, { noremap = true, desc = "netrw File Browser" }) -- netrw file explorer +--vim.keymap.set("n", "e", ":Oil", { desc = "File navigation" }) +vim.keymap.set("n", "e", ":Oil --float", { desc = "File navigation" }) --vim.keymap.set("n", "e", "lua require('oil').toggle_float('.')", { noremap = true, silent = true }) -vim.keymap.set("n", "e", ":Oil", { desc = "File navigation" }) - ---vim.keymap.set( --- "n", --- "e", --- ":Telescope file_browser hidden=true no_ignore=true previewer=false display_stat=false", --- { noremap = true, desc = "Directory browser" } ---) -- List recently opened files vim.keymap.set("n", "fo", ":Telescope oldfiles", { noremap = true, desc = "File history" }) vim.keymap.set( "n", "ff", - ":Telescope find_files hidden=true no_ignore=false ", + ":Telescope find_files hidden=true no_ignore=true", { noremap = true, desc = "File search" } ) @@ -32,6 +25,8 @@ vim.keymap.set( { noremap = true, desc = "Search text under cursor in cwd/grep search string" } ) vim.keymap.set("n", "", ":Telescope buffers", { noremap = true, desc = "Show open buffers" }) +-- todo-comments.nvim +vim.keymap.set("n", "ft", ":TodoTelescope", { noremap = true, desc = "Find TODOs" }) vim.keymap.set("n", "gst", ":Telescope git_status", { noremap = true, desc = "Git status" }) vim.keymap.set( "n", @@ -41,7 +36,6 @@ vim.keymap.set( ) vim.keymap.set("n", "glf", ":Telescope git_bcommits", { noremap = true, desc = "Git log (this file)" }) vim.keymap.set("n", "gdp", ":Gitsigns diffthis", { noremap = true, desc = "Git diff previous (this file)" }) -vim.keymap.set("n", "gg", ":LazyGitCurrentFile", { noremap = true, desc = "LazyGit" }) -- Remapping of existing Vim key binds vim.keymap.set("n", "w", "W") -- skip punctuation when moving to start of next word