diff options
| author | srdusr <trevorgray@srdusr.com> | 2023-03-08 09:18:59 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2023-03-08 09:18:59 +0200 |
| commit | 25d5d4d39c9895702b01af56d14ca609cdd74fee (patch) | |
| tree | a7dcb3685768c7e55fa7c5972179259257a3ad15 /.config/nvim/lua/user | |
| parent | 4c6d385b35c9a9e84224d8705864a0f72f7d1f90 (diff) | |
| parent | 8c6b1a59acec18c2e4ec34fa586421b9ab7bd587 (diff) | |
| download | dotfiles-25d5d4d39c9895702b01af56d14ca609cdd74fee.tar.gz dotfiles-25d5d4d39c9895702b01af56d14ca609cdd74fee.zip | |
Merge commit 'ea9278c7ef76f36503029667f8ed9a29abea0655'
Diffstat (limited to '.config/nvim/lua/user')
| -rw-r--r-- | .config/nvim/lua/user/keys.lua | 40 | ||||
| -rw-r--r-- | .config/nvim/lua/user/opts.lua | 46 | ||||
| -rw-r--r-- | .config/nvim/lua/user/pack.lua | 18 |
3 files changed, 78 insertions, 26 deletions
diff --git a/.config/nvim/lua/user/keys.lua b/.config/nvim/lua/user/keys.lua index c957e05..689ff13 100644 --- a/.config/nvim/lua/user/keys.lua +++ b/.config/nvim/lua/user/keys.lua @@ -29,6 +29,22 @@ map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR> | :echom ('Nv --------------- Extended Operations --------------- +-- Conditional 'q' to quit on floating/quickfix/help windows otherwise still use it for macros +map('n', 'q', function() + local config = vim.api.nvim_win_get_config(0) + if config.relative ~= "" then -- is_floating_window? + return ":silent! close!<CR>" + elseif + vim.o.buftype == 'quickfix' then + return ":quit<CR>" + elseif + vim.o.buftype == 'help' then + return ":close<CR>" + else + return "q" + end +end, {expr = true, replace_keycodes = true}) + -- Combine buffers list with buffer name map("n", "<Leader>b", ":buffers<CR>:buffer<Space>") @@ -43,6 +59,17 @@ map("n", "<leader>d", ":bd<cr>") -- List marks map("n", "<Leader>m", ":marks<CR>") +-- Messages +map("n", "<Leader>M", ":messages<CR>") + +-- Clear messages + +-- Clear messages or just refresh/redraw the screen +map("n", "<leader>u", ":echo '' | redraw<CR>") + +-- Unsets the 'last search pattern' register by hitting return +--map("n", "<CR>", "!silent :noh<CR><CR>") + -- Toggle set number map("n", "<leader>$", ":NumbersToggle<CR>") map("n", "<leader>%", ":NumbersOnOff<CR>") @@ -125,6 +152,9 @@ map("n", "<A-j>", ':let save_a=@a<Cr>"add"ap:let @a=save_a<Cr>') -- Search and replace map("v", "<leader>sr", 'y:%s/<C-r><C-r>"//g<Left><Left>c') +-- Toggle Diff +map("n", "<leader>dt", "<Cmd>call utils#ToggleDiff()<CR>") + -- Map delete to Ctrl+l map("i", "<C-l>", "<Del>") @@ -141,18 +171,12 @@ map("v", "p", '"_dP') -- visual mode to select text to swap with map("v", "<C-X>", "<Esc>`.``gvP``P") --- Clear messages or just refresh/redraw the screen -map("n", "<leader>u", ":echo '' | redraw<CR>") - -- Change Working Directory to current project map("n", "<leader>cd", ":cd %:p:h<CR>:pwd<CR>") -- Open the current file in the default program (on Mac this should just be just `open`) map('n', '<leader>o', ':!xdg-open %<cr><cr>') --- Unsets the 'last search pattern' register by hitting return ---map("n", "<CR>", "!silent :noh<CR><CR>") - -- Toggle completion map("n", "<Leader>tc", ":lua require('user.mods').toggle_completion()<CR>") @@ -309,3 +333,7 @@ end, { desc = "Toggle quickfix window" }) -- Dashboard map("n", "<leader>db", "<CMD>Dashboard<CR>") + +-- +map("", "<Leader>l", require("lsp_lines").toggle, { desc = "Toggle lsp_lines" }) + diff --git a/.config/nvim/lua/user/opts.lua b/.config/nvim/lua/user/opts.lua index c1b5027..78a84a4 100644 --- a/.config/nvim/lua/user/opts.lua +++ b/.config/nvim/lua/user/opts.lua @@ -43,7 +43,7 @@ vim.g.python3_host_prog = "/usr/bin/python3" -- vim.g.loaded_python3_provider = 1 -- vim.g.sh_noisk = 1 -- iskeyword word boundaries when editing a 'sh' file vim.o.autochdir = true ---vim.opt.sessionoptions = "buffers,curdir,folds,help,tabpages,winsize,resize,winpos,terminal,globals" -- +--vim.o.writeany= true -- Colors vim.opt.termguicolors = true @@ -122,11 +122,23 @@ vim.opt.report = 0 -- Always report changed lines. ---- it'll get replaced by the default stline). --vim.opt.stl = " " --- Backup/undo +-- Backup/undo/swap +local prefix = vim.env.XDG_CONFIG_HOME or vim.fn.expand("~/.config") +vim.opt.undodir = { prefix .. "/nvim/tmp/.undo//" } +vim.opt.backupdir = { prefix .. "/nvim/tmp/.backup//" } +vim.opt.directory = { prefix .. "/nvim/tmp/.swp//" } vim.opt.backup = false -- ---vim.opt.noswapfile = true -- ---vim.opt.undofile = true -- -vim.opt.backupskip = { "/tmp/*", "/private/tmp/*" } -- +vim.opt.undofile = false -- +vim.opt.swapfile = true -- +-- Add timestamp as extension for backup files +vim.api.nvim_create_autocmd('BufWritePre', { + group = vim.api.nvim_create_augroup('timestamp_backupext', { clear = true }), + desc = 'Add timestamp to backup extension', + pattern = '*', + callback = function() + vim.opt.backupext = '-' .. vim.fn.strftime('%Y%m%d%H%M') + end, +}) -- Format --vim.opt.textwidth = 80 -- @@ -154,7 +166,7 @@ vim.opt.wrapscan = true -- " Searches wrap around end-of-file. --vim.opt.foldmethod = "expr" -- vim.opt.foldmethod = "manual" vim.opt.foldlevel = 3 -vim.opt.confirm = true +vim.opt.confirm = false vim.opt.shortmess:append("sI") --vim.opt.shortmess = "a" --vim.opt.shortmess = "sI" @@ -226,7 +238,11 @@ vim.opt.shada = "!,'1000,f1,<1000,s100,:1000,/1000,h" -- Sessions vim.opt.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" +--vim.opt.sessionoptions = "curdir,folds,help,options,tabpages,winsize,winpos,terminal,globals" -- +--vim.opt.sessionoptions = "buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" +--vim.opt.sessionoptions:remove({ "blank", "buffers", "globals" }) +vim.opt.clipboard:append({ "unnamedplus" }) -- Install xclip or this will slowdown startup -- Cursorline vim.cmd([[ " Only show cursorline in the current window and in normal mode augroup cline @@ -248,12 +264,12 @@ vim.cmd([[ " Only show in insert mode ]]) -- Line Return ---vim.cmd([[ " Return to the same line when we reopen a file --- augroup line_return --- au! --- au BufReadPost * --- \ if line("'\"") > 0 && line("'\"") <= line("$") | --- \ execute 'normal! g`"zvzz' | --- \ endif --- augroup END ---]]) +vim.cmd([[ " Return to the same line when we reopen a file + augroup line_return + au! + au BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ execute 'normal! g`"zvzz' | + \ endif + augroup END +]]) diff --git a/.config/nvim/lua/user/pack.lua b/.config/nvim/lua/user/pack.lua index 957fac8..0bcb006 100644 --- a/.config/nvim/lua/user/pack.lua +++ b/.config/nvim/lua/user/pack.lua @@ -65,6 +65,13 @@ return packer.startup(function(use) use("williamboman/mason.nvim") -- Package manager to install and manage LSP servers, DAP servers, linters and formatters use("williamboman/mason-lspconfig.nvim") -- Bridges mason.nvim with nvim-lspconfig to help use them together use("neovim/nvim-lspconfig") -- Collection of LSP configs + use({ + "https://git.sr.ht/~whynothugo/lsp_lines.nvim", + config = function() + require("lsp_lines").setup() + end, + }) + use("rmagatti/goto-preview") -- Debugger use("mfussenegger/nvim-dap") -- Debug Adapter Protocol client implementation for Neovim @@ -72,7 +79,7 @@ return packer.startup(function(use) use("gabrielpoca/replacer.nvim") -- Linters/Formatters - use("jayp0521/mason-null-ls.nvim") + use("jay-babu/mason-null-ls.nvim") --use({"jayp0521/mason-null-ls.nvim", -- config = function() -- require('mason-null-ls.nvim').setup({ @@ -82,7 +89,7 @@ return packer.startup(function(use) --}) use({ "jose-elias-alvarez/null-ls.nvim", -- Provides LSP: linters, formatters, diagnostics, code actions and etc... - requires = { "jayp0521/mason-null-ls.nvim" }, + requires = { "jay-babu/mason-null-ls.nvim" }, }) -- Completion @@ -111,6 +118,7 @@ return packer.startup(function(use) -- File explorer/fuzzy finder use("kyazdani42/nvim-tree.lua") -- File explorer use('ibhagwan/fzf-lua') -- Fuzzy finder + use('ThePrimeagen/harpoon') use("nvim-telescope/telescope.nvim") -- Fuzzy finder with lots of features/extendabilities use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" }) -- Support fzf syntax/algorithm use("nvim-telescope/telescope-ui-select.nvim") -- @@ -208,10 +216,10 @@ return packer.startup(function(use) use({ "kosayoda/nvim-lightbulb", -- requires = "antoinemadec/FixCursorHold.nvim", }) - use({ + use({ "SmiteshP/nvim-navic", -- Statusline/Winbar component that uses LSP to show current code context - requires = "neovim/nvim-lspconfig", - }) + requires = "neovim/nvim-lspconfig" + }) use({ 'rebelot/heirline.nvim', -- Statusline that is highly configurable requires = 'kyazdani42/nvim-web-devicons', |
