diff options
Diffstat (limited to 'lua/user')
| -rw-r--r-- | lua/user/colorscheme.lua | 5 | ||||
| -rw-r--r-- | lua/user/keys.lua | 69 | ||||
| -rw-r--r-- | lua/user/opts.lua | 68 | ||||
| -rw-r--r-- | lua/user/reload.lua | 8 | ||||
| -rw-r--r-- | lua/user/utils.lua | 9 |
5 files changed, 143 insertions, 16 deletions
diff --git a/lua/user/colorscheme.lua b/lua/user/colorscheme.lua index dc0145d..e74d48c 100644 --- a/lua/user/colorscheme.lua +++ b/lua/user/colorscheme.lua @@ -10,14 +10,17 @@ end vim.api.nvim_command("syntax on") vim.api.nvim_command("highlight Normal guibg=none") vim.api.nvim_command("highlight SignColumn guibg=none") + vim.api.nvim_command("highlight TabLine guibg=#333842 gui=bold") +vim.api.nvim_command("highlight TabLineSel guibg=#333842 gui=bold") + --vim.api.nvim_command("highlight TabLine guibg=none gui=bold") --vim.api.nvim_command("highlight StatusLine guibg=#333842 gui=bold") --vim.api.nvim_command("highlight StatusLine guibg=#333842 guifg=#d6d3ea gui=bold") --vim.api.nvim_command("highlight StatusLine guibg=none gui=bold") --vim.api.nvim_command("highlight TabLineNC guibg=none gui=bold") --vim.api.nvim_command("highlight TabLineSel guibg=#bd93f9 gui=bold") -vim.api.nvim_command("highlight TabLineSel guibg=#333842 gui=bold") +vim.api.nvim_command("highlight Title guibg=none gui=bold") vim.api.nvim_command("highlight TabLineFill guibg=none gui=bold") vim.api.nvim_command("highlight WinBar guibg=none gui=bold") vim.api.nvim_command("highlight NormalFloat guibg=none") diff --git a/lua/user/keys.lua b/lua/user/keys.lua index bc1f874..8beb6d3 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -26,7 +26,14 @@ vim.g.mapleader = ";" --vim.g.maplocalleader = ";" -- "jj" to exit insert-mode -map("i", "kk", "<esc>") +map("i", "jk", "<esc>") + +map("n", "<leader>m", ":messages<CR>") + +-- Print last error message or use these commands | v:errmsgv | :statusmsg | :h execute() | +--nnoremap <silent><leader>x :put =trim(execute(input(':', '', 'command')))<CR> +-- Press <leader>x, then enter your command, such as 5mess and press <Enter>. The last five message lines will be added to the current buffer. +-- useful to copy error message when vim start -- save quickly --map("n", ";w", ":w<CR>", d("Save buffer")) @@ -38,8 +45,33 @@ map("i", "kk", "<esc>") --nnoremap <leader>so :source $my_vimrc<cr> --]]) +-- Toggle between folds +--utils.map("n", "<F2>", "&foldlevel ? 'zM' : 'zR'", { expr = true }) + +-- Move to the next and previous item in the quickfixlist +--utils.map("n", "]c", "<Cmd>cnext<CR>") +--utils.map("n", "[c", "<Cmd>cprevious<CR>") + +-- Use space to toggle fold +--utils.map("n", "<Space>", "za") + +-- Hitting ESC when inside a terminal to get into normal mode +--utils.map("t", "<Esc>", [[<C-\><C-N>]]) + +-- select last change +--nnoremap gV `[v`] + + +--map("n", "<leader><CR>", ":runtime! /lua/plugins/*.lua<CR> | :runtime! /lua/user/*.lua<CR> | :luafile ~/.config/nvim/init.lua<CR>", print ("Nvim reloaded")) +--map("n", "<leader><CR>", ":lua require('init').unload_lua_namespace()<CR>", print ("Nvim reloaded")) +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR>", vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO)) +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR> | :lua require("notify")("completion off")") +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR>", vim.api.nvim_echo({{'first chunk and ', 'None'}, {'second chunk to echo', 'None'}}, false, {})) +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR>", print ("Nvim config loading...")) +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR> | :echo ('hello') | <C-l><CR>") +map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR> | :echom ('Nvim config loading...') | :sl! | echo ('')<CR>") +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR>") --vim.api.nvim_set_keymap("n", "<leader><CR>", "<cmd>lua ReloadConfig()<CR>", { noremap = true, silent = false }) -map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR>", print ("Nvim configuration reloaded")) map("n", "<Leader>tc", ":lua require('user.utils').toggle_completion()<CR>") -- vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO) @@ -169,6 +201,39 @@ map("v", "p", '"_dP') -- visual mode to select text to swap with map("v", "<C-X>", "<Esc>`.``gvP``P") +-- Keep Visual mode selection when indenting text +--utils.map("x", ">", ">gv") +--utils.map("x", "<", "<gv") + +-- Make visual pasting a word to not update the unnamed register +-- Thus, allowing us to repeatedly paste the word. {"_ : black-hole register} +--utils.map("v", "p", [["_dP]]) + +-- Whole-word search +--utils.map("n", "<leader>/", ":/\\<\\><Left><Left>", { silent = false }) + +-- EasyAlign keybindings +-- 'vipga' starts interactive EasyAlign in visual mode +-- 'gaip' starts interactive EasyAlign for text/motion object +--utils.map({ "n", "x" }, "ga", "<Plug>(EasyAlign)") +--utils.map({ "n", "x" }, "<leader>ga", "<Plug>(LiveEasyAlign)") + +-- Set a mark when moving more than 5 lines upwards/downards +-- this will populate the jumplist enabling us to jump back with Ctrl-O +--utils.map("n", "k", [[(v:count > 5 ? "m'" . v:count : "") . 'k']], { expr = true }) +--utils.map("n", "j", [[(v:count > 5 ? "m'" . v:count : "") . 'j']], { expr = true }) + +-- Zoom toggle a buffer in a new tab +--utils.map("n", "<leader>z", function() +-- require("tt.helper").zoomToggleNewTab() +--end, { desc = "Zoom toggle a buffer in a new tab" }) + +-- Hitting ESC when inside a terminal to get into normal mode +--utils.map("t", "<Esc>", [[<C-\><C-N>]]) + + + + -- Search and replace map("v", "<leader>sr", 'y:%s/<C-r><C-r>"//g<Left><Left>c') --vnoremap ; :call Get_visual_selection()<cr> diff --git a/lua/user/opts.lua b/lua/user/opts.lua index 3200cd5..39cd2a4 100644 --- a/lua/user/opts.lua +++ b/lua/user/opts.lua @@ -19,9 +19,11 @@ vim.g.loaded_python3_provider = 1 -- vim.g.sh_noisk = 1 -- iskeyword word boundaries when editing a 'sh' file --vim.opt.sessionoptions = "buffers,curdir,folds,help,tabpages,winsize,resize,winpos,terminal,globals" -- +-- Colors vim.opt.termguicolors = true + -- Behaviour -vim.opt.clipboard:append({ "unnamedplus" }) -- +vim.opt.clipboard:append({ "unnamedplus" }) -- Install xclip or this will slowdown startup vim.opt.backspace = { "start", "eol", "indent" } -- Make backspace work as you would expect. vim.opt.hidden = true -- Switch between buffers without having to save first. vim.opt.splitbelow = true -- make split put the new buffer below the current buffer @@ -32,7 +34,7 @@ vim.opt.autoread = true -- reload files if changed externally vim.opt.display = "lastline" -- Show as much as possible of the last line. vim.opt.inccommand = "split" -- vim.opt.ttyfast = true -- Faster redrawing. -vim.opt.lazyredraw = true -- Only redraw when necessary +--vim.opt.lazyredraw = true -- Only redraw when necessary vim.opt.keywordprg = ":help" -- :help options vim.opt.ruler = true -- vim.opt.errorbells = false -- @@ -67,8 +69,9 @@ vim.opt.smartindent = true -- smart indent vim.opt.number = true -- --vim.opt.title = true -- --vim.opt.colorcolumn = "+1" -- ---vim.opt.signcolumn = "yes:1" -- always show the sign column -vim.opt.signcolumn = "number" +vim.opt.signcolumn = "yes:1" -- always show the sign column +--vim.opt.signcolumn = "yes:" .. vim.o.numberwidth +--vim.opt.signcolumn = "number" --vim.opt.signcolumn = "no" -- vim.opt.laststatus = 3 -- " Always show statusline. vim.opt.showmode = true -- Show current mode in command-line, example: -- INSERT -- mode @@ -87,6 +90,11 @@ vim.opt.report = 0 -- Always report changed lines. -- end -- end, --}) +---- With vertical splits, the statusline would still show up at the +---- bottom of the split. A quick fix is to just set the statusline +---- to empty whitespace (it can't be an empty string because then +---- it'll get replaced by the default stline). +vim.opt.stl = " " -- Backup/undo vim.opt.backup = false -- @@ -101,16 +109,53 @@ vim.cmd([[let &t_Ce = "\e[4:0m"]]) -- vim.opt.path:append({ "**" }) -- Finding files - Search down into subfolder vim.cmd("set whichwrap+=<,>,[,],h,l") -- vim.cmd([[set iskeyword+=-]]) -- -vim.cmd([[set formatoptions-=cro]]) -- TODO: this doesn't seem to work +--vim.cmd([[set formatoptions-=cro]]) -- TODO: this doesn't seem to work +vim.opt.formatoptions = vim.opt.formatoptions + - "t" -- wrap with text width + + "c" -- wrap comments + + "r" -- insert comment after enter + - "o" -- insert comment after o/O + - "q" -- allow formatting of comments with gq + - "a" -- format paragraphs + + "n" -- recognized numbered lists + - "2" -- use indent of second line for paragraph + + "l" -- long lines are not broken + + "j" -- remove comment when joining lines vim.opt.wrapscan = true -- " Searches wrap around end-of-file. --vim.wo.number = true -- --vim.opt.wrap = false -- No Wrap lines --vim.opt.foldmethod = 'manual' -- --vim.opt.foldmethod = "expr" -- +vim.opt.foldmethod = "manual" +vim.opt.foldlevel = 3 +vim.opt.confirm = true +vim.opt.shortmess:append("sI") +--vim.opt.shortmess = "a" +--vim.opt.shortmess = "sI" +--vim.o.shortmess = vim.o.shortmess:gsub('s', '') +vim.opt.fillchars = { + horiz = "━", + horizup = "┻", + horizdown = "┳", + vert = "┃", + vertleft = "┨", + vertright = "┣", + verthoriz = "╋", + fold = "⠀", + eob = " ", + diff = "┃", + msgsep = "‾", + foldopen = "▾", + foldsep = "│", + foldclose = "▸", +} +vim.opt.listchars = { tab = "▸ ", trail = "·" } -- +--vim.opt.fillchars:append({ eob = " " }) -- remove the ~ from end of buffer vim.opt.modeline = true -- vim.opt.modelines = 3 -- modelines (comments that set vim options on a per-file basis) +vim.opt.modelineexpr = true --vim.opt.nofoldenable = true -- turn folding off -vim.opt.foldenable = false -- turn folding off +--vim.opt.foldenable = false -- turn folding off -- Highlights vim.opt.incsearch = true -- Highlight while searching with / or ?. @@ -121,7 +166,8 @@ vim.opt.synmaxcol = 200 -- Only highlight the first 200 columns. vim.opt.winblend = 30 --vim.opt.winblend = 5 vim.opt.wildoptions = "pum" -- -vim.opt.pumblend = 5 -- +--vim.opt.pumblend = 5 -- +vim.opt.pumblend = 12 -- --vim.opt.pumblend=15 vim.opt.pumheight = 10 -- pop up menu height @@ -148,6 +194,12 @@ vim.opt.wildignore:append({ "*.pyc" }) -- Python byte code vim.opt.wildignore:append({ "*.orig" }) -- Merge resolution files vim.opt.wildignore:append({ "*/node_modules/*" }) -- +-- Shada +vim.opt.shada = "!,'1000,f1,<1000,s100,:1000,/1000,h" + +-- Sessions +vim.opt.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" + -- Cursorline vim.cmd([[ " Only show cursorline in the current window and in normal mode augroup cline @@ -167,8 +219,6 @@ vim.cmd([[ " Only show in insert mode au InsertLeave * :set listchars+=trail:⌴ augroup END ]]) -vim.opt.listchars = { tab = "▸ ", trail = "·" } -- -vim.opt.fillchars:append({ eob = " " }) -- remove the ~ from end of buffer -- Line Return vim.cmd([[ " Return to the same line when we reopen a file diff --git a/lua/user/reload.lua b/lua/user/reload.lua index ecf5dd0..c02ff7b 100644 --- a/lua/user/reload.lua +++ b/lua/user/reload.lua @@ -8,18 +8,18 @@ -- dofile(vim.env.MYVIMRC) -- vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO) --end -function _G.ReloadConfig() +--function _G.ReloadConfig() --dofile(vim.env.MYVIMRC) -- dofile(vim.fn.stdpath('config') .. '/init.lua') --dofile(vim.fn.stdpath('user') .. '/init.lua') - require("plenary.reload").reload_module("user", true) + -- require("plenary.reload").reload_module("user", true) --dofile("/home/sxrdusr/.config/nvim/lua/user/keys.lua") --dofile("/home/sxrdusr/.config/nvim/lua/user/mods.lua") --dofile("/home/sxrdusr/.config/nvim/lua/user/opts.lua") --dofile("/home/sxrdusr/.config/nvim/lua/user/pack.lua") --dofile("/home/sxrdusr/.config/nvim/lua/user/utils.lua") - vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO) -end + --vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO) +--end --P = function(v) -- print(vim.inspect(v)) -- return v diff --git a/lua/user/utils.lua b/lua/user/utils.lua index 3c6f89e..bfb5faa 100644 --- a/lua/user/utils.lua +++ b/lua/user/utils.lua @@ -31,6 +31,15 @@ function M.may_create_dir(dir) end end +M['unload_lua_namespace'] = function(prefix) + local prefix_with_dot = prefix .. '.' + for key, value in pairs(package.loaded) do + if key == prefix or key:sub(1, #prefix_with_dot) == prefix_with_dot then + package.loaded[key] = nil + end + end +end + -- toggle cmp completion vim.g.cmp_toggle_flag = false -- initialize local normal_buftype = function() |
