usability improvements
- add autocmds to highlight yanking and disabling line numbers in Oil - lsp-zero: fix 'gd' command by setting 'preserve_mappings' to false - lualine: show clock, simplify statusline, shorten mode name - oil: decrease float window size, add 'q' hotkey to close window - prefs: show line numbers again, disable additional mode showing - add todo-comments.nvim - remap: add keymap to find all TODOs/FIXME/XXX etc.
This commit is contained in:
parent
ccbe053f88
commit
480a5c2fff
10 changed files with 96 additions and 21 deletions
|
|
@ -101,6 +101,7 @@
|
||||||
- `cc` replace whole line
|
- `cc` replace whole line
|
||||||
- `C` replace to the end of the line
|
- `C` replace to the end of the line
|
||||||
- `yy` copy the current line
|
- `yy` copy the current line
|
||||||
|
- `yap` "yank-around-paragraph"
|
||||||
- `p` paste yanked line below
|
- `p` paste yanked line below
|
||||||
- `P` paste yanked line above
|
- `P` paste yanked line above
|
||||||
|
|
||||||
|
|
|
||||||
BIN
CHEATSHEET.pdf
BIN
CHEATSHEET.pdf
Binary file not shown.
18
lua/weeheavy/autocmd.lua
Normal file
18
lua/weeheavy/autocmd.lua
Normal file
|
|
@ -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,
|
||||||
|
})
|
||||||
|
|
@ -9,3 +9,6 @@ require("weeheavy.lazy")
|
||||||
|
|
||||||
-- Other preferences
|
-- Other preferences
|
||||||
require("weeheavy.prefs")
|
require("weeheavy.prefs")
|
||||||
|
|
||||||
|
-- Auto commands
|
||||||
|
require("weeheavy.autocmd")
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,7 @@ return {
|
||||||
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
||||||
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
||||||
["<C-l>"] = cmp.mapping.confirm({ select = true }), -- accept LSP autocompletion
|
["<C-l>"] = cmp.mapping.confirm({ select = true }), -- accept LSP autocompletion
|
||||||
--["<C-p>"] = cmp.mapping.select_prev_item(cmp_select),
|
|
||||||
["<C-k>"] = cmp.mapping.select_prev_item(cmp_select),
|
["<C-k>"] = cmp.mapping.select_prev_item(cmp_select),
|
||||||
--["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
|
|
||||||
["<C-j>"] = cmp.mapping.select_next_item(cmp_select),
|
["<C-j>"] = cmp.mapping.select_next_item(cmp_select),
|
||||||
["<C-f>"] = cmp_action.luasnip_jump_forward(),
|
["<C-f>"] = cmp_action.luasnip_jump_forward(),
|
||||||
["<C-b>"] = cmp_action.luasnip_jump_backward(),
|
["<C-b>"] = cmp_action.luasnip_jump_backward(),
|
||||||
|
|
@ -67,7 +65,8 @@ return {
|
||||||
lsp_zero.on_attach(function(client, bufnr)
|
lsp_zero.on_attach(function(client, bufnr)
|
||||||
-- see :help lsp-zero-keybindings
|
-- see :help lsp-zero-keybindings
|
||||||
-- to learn the available actions
|
-- 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)
|
end)
|
||||||
|
|
||||||
require("mason").setup({
|
require("mason").setup({
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,11 @@ local function hide_in_width()
|
||||||
return vim.fn.winwidth(0) > 80
|
return vim.fn.winwidth(0) > 80
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function clock()
|
||||||
|
local time = tostring(os.date()):sub(12, 16)
|
||||||
|
return time
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"nvim-lualine/lualine.nvim",
|
"nvim-lualine/lualine.nvim",
|
||||||
lazy = true,
|
lazy = true,
|
||||||
|
|
@ -29,21 +34,44 @@ return {
|
||||||
|
|
||||||
opts = {
|
opts = {
|
||||||
options = {
|
options = {
|
||||||
|
globalstatus = false, -- true == single statusline
|
||||||
icons_enabled = true,
|
icons_enabled = true,
|
||||||
theme = "auto",
|
theme = "auto",
|
||||||
--component_separators = '⋮',
|
component_separators = "⋮",
|
||||||
component_separators = "⁞",
|
--section_separators = { left = "", right = "" },
|
||||||
--section_separators = { left = '', right = '' },
|
section_separators = { left = "", right = "" },
|
||||||
--section_separators = { left = '', right = '' },
|
|
||||||
section_separators = { left = "", right = "" },
|
|
||||||
},
|
},
|
||||||
sections = {
|
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 = {
|
lualine_x = {
|
||||||
-- specify full list of elements when adding custom things
|
-- specify full list of elements when adding custom things
|
||||||
{ "encoding" },
|
{ "encoding" },
|
||||||
{ "fileformat" },
|
{ "fileformat" },
|
||||||
{ "filetype" },
|
{ "filetype" },
|
||||||
{ lsp_clients, cond = hide_in_width },
|
{ lsp_clients, cond = hide_in_width },
|
||||||
|
{ clock, cond = hide_in_width },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,19 @@ return {
|
||||||
["<leader>e"] = "actions.close",
|
["<leader>e"] = "actions.close",
|
||||||
["<C-v>"] = "actions.select_vsplit",
|
["<C-v>"] = "actions.select_vsplit",
|
||||||
["<C-x>"] = "actions.select_split",
|
["<C-x>"] = "actions.select_split",
|
||||||
|
["<C-c>"] = "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,
|
end,
|
||||||
|
|
|
||||||
16
lua/weeheavy/plugins/todo-comments.lua
Normal file
16
lua/weeheavy/plugins/todo-comments.lua
Normal file
|
|
@ -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 },
|
||||||
|
}
|
||||||
|
|
@ -10,7 +10,7 @@ vim.opt.ignorecase = true
|
||||||
vim.opt.smartcase = true
|
vim.opt.smartcase = true
|
||||||
|
|
||||||
-- Show line numbers default
|
-- Show line numbers default
|
||||||
--vim.opt.number = true
|
vim.opt.number = true
|
||||||
|
|
||||||
-- Show relative line numbers
|
-- Show relative line numbers
|
||||||
vim.opt.relativenumber = true
|
vim.opt.relativenumber = true
|
||||||
|
|
@ -66,3 +66,6 @@ vim.opt.splitbelow = true
|
||||||
|
|
||||||
-- Split windows appear to the right instead of left
|
-- Split windows appear to the right instead of left
|
||||||
vim.opt.splitright = true
|
vim.opt.splitright = true
|
||||||
|
|
||||||
|
-- Mode is shown in lualine, so we don't need it one line below
|
||||||
|
vim.opt.showmode = false
|
||||||
|
|
|
||||||
|
|
@ -3,24 +3,17 @@
|
||||||
-- Leader key set to space, base for any key combo
|
-- Leader key set to space, base for any key combo
|
||||||
vim.g.mapleader = " "
|
vim.g.mapleader = " "
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>r", vim.cmd.Ex, { noremap = true, desc = "netrw File Browser" }) -- netrw file explorer
|
--vim.keymap.set("n", "<leader>r", vim.cmd.Ex, { noremap = true, desc = "netrw File Browser" }) -- netrw file explorer
|
||||||
|
--vim.keymap.set("n", "<leader>e", ":Oil<CR>", { desc = "File navigation" })
|
||||||
|
vim.keymap.set("n", "<leader>e", ":Oil --float<CR>", { desc = "File navigation" })
|
||||||
--vim.keymap.set("n", "<leader>e", "<cmd>lua require('oil').toggle_float('.')<CR>", { noremap = true, silent = true })
|
--vim.keymap.set("n", "<leader>e", "<cmd>lua require('oil').toggle_float('.')<CR>", { noremap = true, silent = true })
|
||||||
vim.keymap.set("n", "<leader>e", ":Oil<CR>", { desc = "File navigation" })
|
|
||||||
|
|
||||||
--vim.keymap.set(
|
|
||||||
-- "n",
|
|
||||||
-- "<leader>e",
|
|
||||||
-- ":Telescope file_browser hidden=true no_ignore=true previewer=false display_stat=false<CR>",
|
|
||||||
-- { noremap = true, desc = "Directory browser" }
|
|
||||||
--)
|
|
||||||
|
|
||||||
-- List recently opened files
|
-- List recently opened files
|
||||||
vim.keymap.set("n", "<leader>fo", ":Telescope oldfiles<CR>", { noremap = true, desc = "File history" })
|
vim.keymap.set("n", "<leader>fo", ":Telescope oldfiles<CR>", { noremap = true, desc = "File history" })
|
||||||
vim.keymap.set(
|
vim.keymap.set(
|
||||||
"n",
|
"n",
|
||||||
"<leader>ff",
|
"<leader>ff",
|
||||||
":Telescope find_files hidden=true no_ignore=false <CR>",
|
":Telescope find_files hidden=true no_ignore=true<CR>",
|
||||||
{ noremap = true, desc = "File search" }
|
{ noremap = true, desc = "File search" }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -32,6 +25,8 @@ vim.keymap.set(
|
||||||
{ noremap = true, desc = "Search text under cursor in cwd/grep search string" }
|
{ noremap = true, desc = "Search text under cursor in cwd/grep search string" }
|
||||||
)
|
)
|
||||||
vim.keymap.set("n", "<leader><leader>", ":Telescope buffers<CR>", { noremap = true, desc = "Show open buffers" })
|
vim.keymap.set("n", "<leader><leader>", ":Telescope buffers<CR>", { noremap = true, desc = "Show open buffers" })
|
||||||
|
-- todo-comments.nvim
|
||||||
|
vim.keymap.set("n", "<leader>ft", ":TodoTelescope<CR>", { noremap = true, desc = "Find TODOs" })
|
||||||
vim.keymap.set("n", "<leader>gst", ":Telescope git_status<CR>", { noremap = true, desc = "Git status" })
|
vim.keymap.set("n", "<leader>gst", ":Telescope git_status<CR>", { noremap = true, desc = "Git status" })
|
||||||
vim.keymap.set(
|
vim.keymap.set(
|
||||||
"n",
|
"n",
|
||||||
|
|
@ -41,7 +36,6 @@ vim.keymap.set(
|
||||||
)
|
)
|
||||||
vim.keymap.set("n", "<leader>glf", ":Telescope git_bcommits<CR>", { noremap = true, desc = "Git log (this file)" })
|
vim.keymap.set("n", "<leader>glf", ":Telescope git_bcommits<CR>", { noremap = true, desc = "Git log (this file)" })
|
||||||
vim.keymap.set("n", "<leader>gdp", ":Gitsigns diffthis<CR>", { noremap = true, desc = "Git diff previous (this file)" })
|
vim.keymap.set("n", "<leader>gdp", ":Gitsigns diffthis<CR>", { noremap = true, desc = "Git diff previous (this file)" })
|
||||||
vim.keymap.set("n", "<leader>gg", ":LazyGitCurrentFile<CR>", { noremap = true, desc = "LazyGit" })
|
|
||||||
|
|
||||||
-- Remapping of existing Vim key binds
|
-- Remapping of existing Vim key binds
|
||||||
vim.keymap.set("n", "w", "W") -- skip punctuation when moving to start of next word
|
vim.keymap.set("n", "w", "W") -- skip punctuation when moving to start of next word
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue