From 73acdc3af0a54e175ccaab7db981f82cdf2dca5f Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 12 Feb 2023 17:11:26 +0200 Subject: Changed name to mods.lua --- lua/user/utils.lua | 125 ----------------------------------------------------- 1 file changed, 125 deletions(-) delete mode 100644 lua/user/utils.lua diff --git a/lua/user/utils.lua b/lua/user/utils.lua deleted file mode 100644 index f70fac5..0000000 --- a/lua/user/utils.lua +++ /dev/null @@ -1,125 +0,0 @@ -local M = {} - ---- Shorten Function Names -local fn = vim.fn -function M.executable(name) - if fn.executable(name) > 0 then - return true - end - - return false -end - - --------------------------------------------------- - ---- Check whether a feature exists in Nvim ---- @feat: string ---- the feature name, like `nvim-0.7` or `unix`. ---- return: bool -M.has = function(feat) - if fn.has(feat) == 1 then - return true - end - - return false -end - - --------------------------------------------------- - ----Determine if a value of any type is empty ----@param item any ----@return boolean? -function M.empty(item) - if not item then return true end - local item_type = type(item) - if item_type == 'string' then return item == '' end - if item_type == 'number' then return item <= 0 end - if item_type == 'table' then return vim.tbl_isempty(item) end - return item ~= nil -end - --------------------------------------------------- - ---- Create a dir if it does not exist -function M.may_create_dir(dir) - local res = fn.isdirectory(dir) - - if res == 0 then - fn.mkdir(dir, "p") - end -end - - --------------------------------------------------- - ---- Toggle cmp completion -vim.g.cmp_toggle_flag = false -- initialize -local normal_buftype = function() - return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt" -end -M.toggle_completion = function() - local ok, cmp = pcall(require, "cmp") - if ok then - local next_cmp_toggle_flag = not vim.g.cmp_toggle_flag - if next_cmp_toggle_flag then - print("completion on") - else - print("completion off") - end - cmp.setup({ - enabled = function() - vim.g.cmp_toggle_flag = next_cmp_toggle_flag - if next_cmp_toggle_flag then - return normal_buftype - else - return next_cmp_toggle_flag - end - end, - }) - else - print("completion not available") - end -end - - --------------------------------------------------- - ---- Make sure using latest neovim version -function M.get_nvim_version() - local actual_ver = vim.version() - - local nvim_ver_str = string.format("%d.%d.%d", actual_ver.major, actual_ver.minor, actual_ver.patch) - return nvim_ver_str -end - -function M.add_pack(name) - local status, error = pcall(vim.cmd, "packadd " .. name) - - return status -end - - --------------------------------------------------- - ---- Toggle autopairs on/off (requires "windwp/nvim-autopairs") -function M.Toggle_autopairs() - local ok, autopairs = pcall(require, "nvim-autopairs") - if ok then - if autopairs.state.disabled then - autopairs.enable() - print("autopairs on") - else - autopairs.disable() - print("autopairs off") - end - else - print("autopairs not available") - end -end - -return M - - --------------------------------------------------- -- cgit v1.2.3 From 71cee7e21c8ee739380c07d28bbe5c3143bba456 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 12 Feb 2023 17:11:41 +0200 Subject: Changed name to mods.lua --- lua/user/mods.lua | 263 ++++++++++++++++++++++++++---------------------------- 1 file changed, 125 insertions(+), 138 deletions(-) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index c36d9e2..f70fac5 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -1,138 +1,125 @@ ---vim.cmd([[ --- function RandomColorScheme() --- let mycolors = split(globpath(&rtp,"**/colors/*.vim"),"\n") --- exe 'so ' . mycolors[localtime() % len(mycolors)] --- unlet mycolors --- endfunction --- --- call RandomColorScheme() --- --- :command NewColor call RandomColorScheme() ---]]) - ---vim.cmd([[ --- function RandomColorSchemeMyPicks() --- let mypicks = ["pyte", "fokus", "github", "peachpuff", "morning", "simple256", "xcode", "gruvbox"] --- let mypick = mypicks[localtime() % len(mypicks)] --- echom mypick --- execute 'colo' mypick --- endfunction --- --- command NewColor call RandomColorSchemeMyPicks() --- --- let s:use_gui = exists('g:neovide') || has('gui_running') || (has('termguicolors') && &termguicolors) --- if (s:use_gui) --- call RandomColorSchemeMyPicks() --- endif ---]]) - ---vim.cmd([[ --- let g:fzf_history_dir = '~/.local/share/fzf-history' --- map z :FZF --- map a :Files --- map l :Lines --- map L :BLines --- map B :Buffers --- map h :History: --- nnoremap g :Rg --- "nnoremap t :Tags --- nnoremap m :Marks --- " This is the default extra key bindings --- let g:fzf_action = { --- \ 'ctrl-t': 'tab split', --- \ 'ctrl-x': 'split', --- \ 'ctrl-y': 'vsplit' } --- let g:fzf_tags_command = 'ctags -R' --- " Border color --- let g:fzf_layout = {'up':'~90%', 'window': { 'width': 0.8, 'height': 0.8,'yoffset':0.5,'xoffset': 0.5, 'highlight': 'Todo', 'border': 'sharp' } } --- let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline' --- let $FZF_DEFAULT_COMMAND="rg --files --hidden" --- " Customize fzf colors to match your color scheme --- let g:fzf_colors = --- \ { 'fg': ['fg', 'Normal'], --- \ 'bg': ['bg', 'Normal'], --- \ 'hl': ['fg', 'Comment'], --- \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], --- \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], --- \ 'hl+': ['fg', 'Statement'], --- \ 'info': ['fg', 'PreProc'], --- \ 'border': ['fg', 'Ignore'], --- \ 'prompt': ['fg', 'Conditional'], --- \ 'pointer': ['fg', 'Exception'], --- \ 'marker': ['fg', 'Keyword'], --- \ 'spinner': ['fg', 'Label'], --- \ 'header': ['fg', 'Comment'] } --- " Get Files --- command! -bang -nargs=? -complete=dir Files --- \ call fzf#vim#files(, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), 0) --- " Get text in files with Rg --- command! -bang -nargs=* Rg --- \ call fzf#vim#grep( --- \ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(), 1, --- \ fzf#vim#with_preview(), 0) --- " Ripgrep advanced --- function! RipgrepFzf(query, fullscreen) --- let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true' --- let initial_command = printf(command_fmt, shellescape(a:query)) --- let reload_command = printf(command_fmt, '{q}') --- let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]} --- call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen) --- endfunction --- command! -nargs=* -bang RG call RipgrepFzf(, 0) --- " Git grep --- command! -bang -nargs=* GGrep --- \ call fzf#vim#grep( --- \ 'git grep --line-number '.shellescape(), 0, --- \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), 0) --- command! -bang FM call fzf#run(fzf#wrap({'source': 'cat ~/.fzf-marks | sed "s/.*: \(.*\)$/\1/" | sed "s#~#${HOME}#"', 'sink': 'lcd'}, 0)) ---]]) --- ---vim.cmd([[ --- " Enable mouse scrollback --- set mouse=a --- tnoremap --- tnoremap --- function! ClearTerminal() --- set scrollback=1 --- let &g:scrollback=1 --- echo &scrollback --- call feedkeys("\i") --- call feedkeys("clear\") --- call feedkeys("\\") --- call feedkeys("\i") --- sleep 100m --- let &scrollback=s:scroll_value --- endfunction ---]]) --- ---vim.cmd([[ --- " :Rename {newname} --- function! RenameFile() --- let old_name = expand('%') --- let new_name = input('New file name: ', expand('%'), 'file') --- if new_name != '' && new_name != old_name --- exec ':saveas ' . new_name --- exec ':silent !rm ' . old_name --- redraw! --- endif --- endfunction --- map re :call RenameFile() ---]]) - ---vim.cmd([[ --- " Markdown Settings --- autocmd BufNewFile,BufReadPost *.md set filetype=markdown --- let g:markdown_fenced_languages = ['html', 'python', 'bash=sh', 'sql', 'pug'] --- let g:markdown_minlines = 100 --- let g:instant_markdown_autostart = 0 ---]]) --- ---vim.cmd([[ --- " On The Fly Table mode --- function! s:isAtStartOfLine(mapping) --- let text_before_cursor = getline('.')[0 : col('.')-1] --- let mapping_pattern = '\V' . escape(a:mapping, '\') --- let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\') --- return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$') --- endfunction ---]]) +local M = {} + +--- Shorten Function Names +local fn = vim.fn +function M.executable(name) + if fn.executable(name) > 0 then + return true + end + + return false +end + + +-------------------------------------------------- + +--- Check whether a feature exists in Nvim +--- @feat: string +--- the feature name, like `nvim-0.7` or `unix`. +--- return: bool +M.has = function(feat) + if fn.has(feat) == 1 then + return true + end + + return false +end + + +-------------------------------------------------- + +---Determine if a value of any type is empty +---@param item any +---@return boolean? +function M.empty(item) + if not item then return true end + local item_type = type(item) + if item_type == 'string' then return item == '' end + if item_type == 'number' then return item <= 0 end + if item_type == 'table' then return vim.tbl_isempty(item) end + return item ~= nil +end + +-------------------------------------------------- + +--- Create a dir if it does not exist +function M.may_create_dir(dir) + local res = fn.isdirectory(dir) + + if res == 0 then + fn.mkdir(dir, "p") + end +end + + +-------------------------------------------------- + +--- Toggle cmp completion +vim.g.cmp_toggle_flag = false -- initialize +local normal_buftype = function() + return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt" +end +M.toggle_completion = function() + local ok, cmp = pcall(require, "cmp") + if ok then + local next_cmp_toggle_flag = not vim.g.cmp_toggle_flag + if next_cmp_toggle_flag then + print("completion on") + else + print("completion off") + end + cmp.setup({ + enabled = function() + vim.g.cmp_toggle_flag = next_cmp_toggle_flag + if next_cmp_toggle_flag then + return normal_buftype + else + return next_cmp_toggle_flag + end + end, + }) + else + print("completion not available") + end +end + + +-------------------------------------------------- + +--- Make sure using latest neovim version +function M.get_nvim_version() + local actual_ver = vim.version() + + local nvim_ver_str = string.format("%d.%d.%d", actual_ver.major, actual_ver.minor, actual_ver.patch) + return nvim_ver_str +end + +function M.add_pack(name) + local status, error = pcall(vim.cmd, "packadd " .. name) + + return status +end + + +-------------------------------------------------- + +--- Toggle autopairs on/off (requires "windwp/nvim-autopairs") +function M.Toggle_autopairs() + local ok, autopairs = pcall(require, "nvim-autopairs") + if ok then + if autopairs.state.disabled then + autopairs.enable() + print("autopairs on") + else + autopairs.disable() + print("autopairs off") + end + else + print("autopairs not available") + end +end + +return M + + +-------------------------------------------------- -- cgit v1.2.3 From 8ed20780fba2b833c3db8cb3295e578d2e597211 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 12 Feb 2023 17:14:00 +0200 Subject: Changed 'utils.lua' and 'local utils' to 'mods.lua' and 'local mods' respectively --- init.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 622e5e9..108890a 100644 --- a/init.lua +++ b/init.lua @@ -52,8 +52,7 @@ local modules = { "user.pack", -- Packer plugin manager "user.opts", -- Options "user.keys", -- Keymaps - "user.utils", -- Utilities - --"user.mods", -- Modules/functions + "user.mods", -- Modules/functions --"user.deps", -- Plugins --"user.scripts", "plugins.treesitter", @@ -89,9 +88,9 @@ end -- Check if we have the latest stable version of nvim -local utils = require("user.utils") +local mods = require("user.mods") local expected_ver = "0.9.0" -local nvim_ver = utils.get_nvim_version() +local nvim_ver = mods.get_nvim_version() if nvim_ver ~= expected_ver then local msg = string.format("Unsupported nvim version: expect %s, but got %s instead!", expected_ver, nvim_ver) -- cgit v1.2.3 From 6a68f257996e01f12a88a735cf949e9f07e8a198 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 12 Feb 2023 17:14:15 +0200 Subject: Changed 'utils.lua' and 'local utils' to 'mods.lua' and 'local mods' respectively --- lua/plugins/cmp.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 829a448..edf57de 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -98,11 +98,11 @@ cmp.setup({ i = function() if cmp.visible() then cmp.abort() - require("user.utils").toggle_completion() + require("user.mods").toggle_completion() require("notify")("completion off") else cmp.complete() - require("user.utils").toggle_completion() + require("user.mods").toggle_completion() require("notify")("completion on") end end, @@ -111,7 +111,7 @@ cmp.setup({ -- i = function(fallback) -- if cmp.visible() then -- cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) - -- require("user.utils").toggle_completion() + -- require("user.mods").toggle_completion() -- else -- fallback() -- end -- cgit v1.2.3 From 522b51ecca10ade3de8ddf9b11f9800f8ad38fde Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 12 Feb 2023 17:14:25 +0200 Subject: Changed 'utils.lua' and 'local utils' to 'mods.lua' and 'local mods' respectively --- lua/plugins/lsp.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 548df74..4bcfeea 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,7 +1,7 @@ -- Shorten Function Names local fn = vim.fn local keymap = vim.keymap -local utils = require("user.utils") +local mods = require("user.mods") -- Setup mason so it can manage external tooling @@ -156,7 +156,7 @@ capabilities.offsetEncoding = { "utf-16" } local lspconfig = require("lspconfig") -if utils.executable("pylsp") then +if mods.executable("pylsp") then lspconfig.pylsp.setup({ settings = { pylsp = { @@ -179,7 +179,7 @@ else vim.notify("pylsp not found!", vim.log.levels.WARN, { title = "Server?" }) end -if utils.executable('pyright') then +if mods.executable('pyright') then lspconfig.pyright.setup{ on_attach = on_attach, capabilities = capabilities @@ -188,7 +188,7 @@ else vim.notify("pyright not found!", vim.log.levels.WARN, {title = 'Server?'}) end -if utils.executable("clangd") then +if mods.executable("clangd") then lspconfig.clangd.setup({ on_attach = on_attach, capabilities = capabilities, @@ -202,7 +202,7 @@ else end -- Set up vim-language-server -if utils.executable("vim-language-server") then +if mods.executable("vim-language-server") then lspconfig.vimls.setup({ on_attach = on_attach, flags = { @@ -215,14 +215,14 @@ else end -- Set up bash-language-server -if utils.executable("bash-language-server") then +if mods.executable("bash-language-server") then lspconfig.bashls.setup({ on_attach = on_attach, capabilities = capabilities, }) end -if utils.executable("lua-language-server") then +if mods.executable("lua-language-server") then lspconfig.lua_ls.setup({ on_attach = on_attach, settings = { @@ -251,7 +251,7 @@ if utils.executable("lua-language-server") then end -if utils.executable("rust-language-server") then +if mods.executable("rust-language-server") then require("lspconfig").rust_analyzer.setup{ cmd = { "rustup", "run", "nightly", "rust-analyzer" }, on_attach = on_attach, -- cgit v1.2.3 From 4e10a389727bfe6fbbc5d0864e1216068e262fd8 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 12 Feb 2023 17:14:37 +0200 Subject: Changed 'utils.lua' and 'local utils' to 'mods.lua' and 'local mods' respectively --- lua/plugins/toggleterm.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua index 024c2f6..5875fc6 100644 --- a/lua/plugins/toggleterm.lua +++ b/lua/plugins/toggleterm.lua @@ -55,10 +55,10 @@ toggleterm.setup({ }, }, }) -local utils = require("user.utils") +local mods = require("user.mods") local float_handler = function(term) - if not utils.empty(vim.fn.mapcheck('jj', 't')) then + if not mods.empty(vim.fn.mapcheck('jj', 't')) then vim.keymap.del('t', 'jj', { buffer = term.bufnr }) vim.keymap.del('t', '', { buffer = term.bufnr }) end -- cgit v1.2.3 From e98b080b264495869f9f097e8c9bde6c04c41863 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 12 Feb 2023 17:14:49 +0200 Subject: Changed 'utils.lua' and 'local utils' to 'mods.lua' and 'local mods' respectively --- lua/user/keys.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 4556510..1eb8c80 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -1,6 +1,6 @@ --[[ key.lua ]] -local utils = require("user.utils") +local mods = require("user.mods") ------------- Shorten Function Names -------------- local keymap = vim.keymap local map = function(mode, l, r, opts) @@ -155,7 +155,7 @@ map('n', 'o', ':!xdg-open %') --map("n", "", "!silent :noh") -- Toggle completion -map("n", "tc", ":lua require('user.utils').toggle_completion()") +map("n", "tc", ":lua require('user.mods').toggle_completion()") -- Disable default completion. map('i', '', '') @@ -275,4 +275,4 @@ map("n", "md", ":Glow") --map("n", "md", "MarkdownPreviewToggle") -- Autopairs -map("n", "ww", "lua require('user.utils').Toggle_autopairs()") +map("n", "ww", "lua require('user.mods').Toggle_autopairs()") -- cgit v1.2.3 From 2bfb856dcedea0747a1da8c930d77e74d9e00d3a Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 12 Feb 2023 17:15:57 +0200 Subject: Changed old mods file to func file, NOTE: Not currently being used/sourced --- lua/user/func.lua | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 lua/user/func.lua diff --git a/lua/user/func.lua b/lua/user/func.lua new file mode 100644 index 0000000..c36d9e2 --- /dev/null +++ b/lua/user/func.lua @@ -0,0 +1,138 @@ +--vim.cmd([[ +-- function RandomColorScheme() +-- let mycolors = split(globpath(&rtp,"**/colors/*.vim"),"\n") +-- exe 'so ' . mycolors[localtime() % len(mycolors)] +-- unlet mycolors +-- endfunction +-- +-- call RandomColorScheme() +-- +-- :command NewColor call RandomColorScheme() +--]]) + +--vim.cmd([[ +-- function RandomColorSchemeMyPicks() +-- let mypicks = ["pyte", "fokus", "github", "peachpuff", "morning", "simple256", "xcode", "gruvbox"] +-- let mypick = mypicks[localtime() % len(mypicks)] +-- echom mypick +-- execute 'colo' mypick +-- endfunction +-- +-- command NewColor call RandomColorSchemeMyPicks() +-- +-- let s:use_gui = exists('g:neovide') || has('gui_running') || (has('termguicolors') && &termguicolors) +-- if (s:use_gui) +-- call RandomColorSchemeMyPicks() +-- endif +--]]) + +--vim.cmd([[ +-- let g:fzf_history_dir = '~/.local/share/fzf-history' +-- map z :FZF +-- map a :Files +-- map l :Lines +-- map L :BLines +-- map B :Buffers +-- map h :History: +-- nnoremap g :Rg +-- "nnoremap t :Tags +-- nnoremap m :Marks +-- " This is the default extra key bindings +-- let g:fzf_action = { +-- \ 'ctrl-t': 'tab split', +-- \ 'ctrl-x': 'split', +-- \ 'ctrl-y': 'vsplit' } +-- let g:fzf_tags_command = 'ctags -R' +-- " Border color +-- let g:fzf_layout = {'up':'~90%', 'window': { 'width': 0.8, 'height': 0.8,'yoffset':0.5,'xoffset': 0.5, 'highlight': 'Todo', 'border': 'sharp' } } +-- let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline' +-- let $FZF_DEFAULT_COMMAND="rg --files --hidden" +-- " Customize fzf colors to match your color scheme +-- let g:fzf_colors = +-- \ { 'fg': ['fg', 'Normal'], +-- \ 'bg': ['bg', 'Normal'], +-- \ 'hl': ['fg', 'Comment'], +-- \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], +-- \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], +-- \ 'hl+': ['fg', 'Statement'], +-- \ 'info': ['fg', 'PreProc'], +-- \ 'border': ['fg', 'Ignore'], +-- \ 'prompt': ['fg', 'Conditional'], +-- \ 'pointer': ['fg', 'Exception'], +-- \ 'marker': ['fg', 'Keyword'], +-- \ 'spinner': ['fg', 'Label'], +-- \ 'header': ['fg', 'Comment'] } +-- " Get Files +-- command! -bang -nargs=? -complete=dir Files +-- \ call fzf#vim#files(, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), 0) +-- " Get text in files with Rg +-- command! -bang -nargs=* Rg +-- \ call fzf#vim#grep( +-- \ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(), 1, +-- \ fzf#vim#with_preview(), 0) +-- " Ripgrep advanced +-- function! RipgrepFzf(query, fullscreen) +-- let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true' +-- let initial_command = printf(command_fmt, shellescape(a:query)) +-- let reload_command = printf(command_fmt, '{q}') +-- let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]} +-- call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen) +-- endfunction +-- command! -nargs=* -bang RG call RipgrepFzf(, 0) +-- " Git grep +-- command! -bang -nargs=* GGrep +-- \ call fzf#vim#grep( +-- \ 'git grep --line-number '.shellescape(), 0, +-- \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), 0) +-- command! -bang FM call fzf#run(fzf#wrap({'source': 'cat ~/.fzf-marks | sed "s/.*: \(.*\)$/\1/" | sed "s#~#${HOME}#"', 'sink': 'lcd'}, 0)) +--]]) +-- +--vim.cmd([[ +-- " Enable mouse scrollback +-- set mouse=a +-- tnoremap +-- tnoremap +-- function! ClearTerminal() +-- set scrollback=1 +-- let &g:scrollback=1 +-- echo &scrollback +-- call feedkeys("\i") +-- call feedkeys("clear\") +-- call feedkeys("\\") +-- call feedkeys("\i") +-- sleep 100m +-- let &scrollback=s:scroll_value +-- endfunction +--]]) +-- +--vim.cmd([[ +-- " :Rename {newname} +-- function! RenameFile() +-- let old_name = expand('%') +-- let new_name = input('New file name: ', expand('%'), 'file') +-- if new_name != '' && new_name != old_name +-- exec ':saveas ' . new_name +-- exec ':silent !rm ' . old_name +-- redraw! +-- endif +-- endfunction +-- map re :call RenameFile() +--]]) + +--vim.cmd([[ +-- " Markdown Settings +-- autocmd BufNewFile,BufReadPost *.md set filetype=markdown +-- let g:markdown_fenced_languages = ['html', 'python', 'bash=sh', 'sql', 'pug'] +-- let g:markdown_minlines = 100 +-- let g:instant_markdown_autostart = 0 +--]]) +-- +--vim.cmd([[ +-- " On The Fly Table mode +-- function! s:isAtStartOfLine(mapping) +-- let text_before_cursor = getline('.')[0 : col('.')-1] +-- let mapping_pattern = '\V' . escape(a:mapping, '\') +-- let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\') +-- return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$') +-- endfunction +--]]) -- cgit v1.2.3 From 5d49d0b18a34360e65b4910877fe5a8fee43a7be Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 13 Feb 2023 16:28:19 +0200 Subject: Moved autocommand of "Toggle DiagnosticsOpenFloat" to from util.vim to lsp.lua --- autoload/utils.vim | 5 ----- 1 file changed, 5 deletions(-) diff --git a/autoload/utils.vim b/autoload/utils.vim index d4a1298..81d1604 100644 --- a/autoload/utils.vim +++ b/autoload/utils.vim @@ -16,11 +16,6 @@ endfunction "------------------------------------------------- " Toggle DiagnosticsOpenFloat -augroup OpenFloat - autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,}) - -augroup END - function! utils#ToggleDiagnosticsOpenFloat() " Switch the toggle variable let g:DiagnosticsOpenFloat = !get(g:, 'DiagnosticsOpenFloat', 1) -- cgit v1.2.3 From 53bab088cfb1ef4e60a08bbd9941d4d9fc5bcc5a Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 13 Feb 2023 16:28:29 +0200 Subject: │Moved autocommand of "Toggle DiagnosticsOpenFloat" to from util.vim to lsp.lua MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/plugins/lsp.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 4bcfeea..c551b48 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -147,6 +147,14 @@ function _G.toggle_diagnostics() end end +-- Open float for diagnostics automatically +vim.cmd([[ +augroup OpenFloat + autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,}) + +augroup END +]]) + -- Suppress error messages from lang servers vim.lsp.set_log_level("debug") local capabilities = vim.lsp.protocol.make_client_capabilities() -- cgit v1.2.3 From 78ee32e9a859aa1df2e296b54f9eed4ec4420a3e Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 13 Feb 2023 16:29:28 +0200 Subject: Removed "local mods = require("user.mods") --- lua/user/keys.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 1eb8c80..c9bd0fa 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -1,6 +1,5 @@ --[[ key.lua ]] -local mods = require("user.mods") ------------- Shorten Function Names -------------- local keymap = vim.keymap local map = function(mode, l, r, opts) -- cgit v1.2.3 From a5912f55a267d40416546223c11de3843e2306fc Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 13 Feb 2023 16:42:33 +0200 Subject: Add folke/trouble.nvim --- lua/user/pack.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 918ab41..b96f753 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -148,7 +148,18 @@ return packer.startup(function(use) use("folke/which-key.nvim") -- use("folke/zen-mode.nvim") -- use("romainl/vim-cool") -- - use "antoinemadec/FixCursorHold.nvim" -- + use("antoinemadec/FixCursorHold.nvim") -- + use({ + "folke/trouble.nvim", + requires = "nvim-tree/nvim-web-devicons", + config = function() + require("trouble").setup { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + } + end + }) use("airblade/vim-rooter") -- --use("vim-test/vim-test") -- --use({ -- cgit v1.2.3 From 5f4c652e491528f82052937d9b99aa981bd3a2f7 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 13 Feb 2023 17:02:34 +0200 Subject: Add telescope buffers keybinding --- lua/user/keys.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index c9bd0fa..267dd60 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -249,12 +249,13 @@ map("n", "gm", ":Gmove") -- Telescope map("n", "ff", function() require("telescope.builtin").find_files { hidden = true, no_ignore = true } end) -- find all files map("n", "fF", "lua require('telescope.builtin').find_files()") -- find files with hidden option -map("n", "fb", "lua require('telescope.builtin').current_buffer_fuzzy_find()") -map("n", "fc", "lua require('telescope.builtin').commands()") +map("n", "fb", "lua require('telescope.builtin').buffers()") +map("n", "ffc", "lua require('telescope.builtin').current_buffer_fuzzy_find()") map("n", "fg", "lua require('telescope.builtin').live_grep()") +map("n", "fc", "lua require('telescope.builtin').commands()") +map("n", "cf", "Telescope changed_files") map("n", "fp", "Telescope pickers") map("n", "fr", "lua require('telescope.builtin').registers({})") -- registers picker -map("n", "cf", "Telescope changed_files") map("n", "fd", "lua require('telescope.builtin').diagnostics()") map("n", "fh", "lua require('telescope.builtin').help_tags()") map("n", "fk", "lua require('telescope.builtin').keymaps()") -- cgit v1.2.3 From 01cbc5319553d192ee05749a58de9a927035fc20 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 13 Feb 2023 17:03:41 +0200 Subject: Add Notifications section where nvim-notify is the default notification system --- init.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/init.lua b/init.lua index 108890a..f6b6ed5 100644 --- a/init.lua +++ b/init.lua @@ -102,6 +102,9 @@ end -- Snippets vim.g.snippets = "luasnip" +-- Notifications +vim.notify = require("notify") -- Requires plugin "rcarriga/nvim-notify" + -- Improve speed by disabling some default plugins/modules local builtins = { "gzip", -- cgit v1.2.3 From 49709219afa978ab219107d3b15dda3e81ffdfc4 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 13 Feb 2023 17:03:49 +0200 Subject: Clean config --- lua/user/opts.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/user/opts.lua b/lua/user/opts.lua index 468b7af..c1b5027 100644 --- a/lua/user/opts.lua +++ b/lua/user/opts.lua @@ -1,4 +1,5 @@ --[[ opts.lua ]] + -- " Load indent files, to automatically do language-dependent indenting. --vim.cmd([[ -- "filetype plugin indent on -- cgit v1.2.3 From 7509c203243c40f494a1c1bfb32f4317bf08f198 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 13 Feb 2023 17:24:46 +0200 Subject: Add Markdown-preview and Glow plugins keybindings --- lua/user/keys.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 267dd60..5f0da3a 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -249,15 +249,15 @@ map("n", "gm", ":Gmove") -- Telescope map("n", "ff", function() require("telescope.builtin").find_files { hidden = true, no_ignore = true } end) -- find all files map("n", "fF", "lua require('telescope.builtin').find_files()") -- find files with hidden option -map("n", "fb", "lua require('telescope.builtin').buffers()") -map("n", "ffc", "lua require('telescope.builtin').current_buffer_fuzzy_find()") map("n", "fg", "lua require('telescope.builtin').live_grep()") +map("n", "fb", "lua require('telescope.builtin').buffers()") +map("n", "fh", "lua require('telescope.builtin').help_tags()") map("n", "fc", "lua require('telescope.builtin').commands()") +map("n", "ffc", "lua require('telescope.builtin').current_buffer_fuzzy_find()") map("n", "cf", "Telescope changed_files") map("n", "fp", "Telescope pickers") map("n", "fr", "lua require('telescope.builtin').registers({})") -- registers picker map("n", "fd", "lua require('telescope.builtin').diagnostics()") -map("n", "fh", "lua require('telescope.builtin').help_tags()") map("n", "fk", "lua require('telescope.builtin').keymaps()") map("n", "fn", [[lua require'plugins.telescope'.find_notes()]]) -- find notes map("n", "fgn", [[lua require'plugins.telescope'.grep_notes()]]) -- search notes @@ -271,8 +271,8 @@ map("n", "fz", "lua require('fzf-lua').files()") map("n", "f", ":NvimTreeToggle", {}) -- Markdown-preview -map("n", "md", ":Glow") ---map("n", "md", "MarkdownPreviewToggle") +map("n", "md", "MarkdownPreviewToggle") +map("n", "mg", "Glow") -- Autopairs map("n", "ww", "lua require('user.mods').Toggle_autopairs()") -- cgit v1.2.3 From 3d56e1819d3fb211b239fe97f4768be56cd48a85 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 13 Feb 2023 17:36:15 +0200 Subject: Add telescope mapping for notification history --- lua/user/keys.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 5f0da3a..32a4160 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -263,6 +263,7 @@ map("n", "fn", [[lua require'plugins.telescope'.find_notes()]]) map("n", "fgn", [[lua require'plugins.telescope'.grep_notes()]]) -- search notes map("n", "f.", [[lua require'plugins.telescope'.find_configs()]]) -- find configs map("n", "fm", "lua require('telescope').extensions.media_files.media_files({})") -- find media files +map("n", "fi", "lua require('telescope').extensions.notify.notify({})") -- find media files -- FZF map("n", "fz", "lua require('fzf-lua').files()") -- cgit v1.2.3 From 45720571d7e97b10a96285962f7ac979b7b0dfc3 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 13 Feb 2023 17:36:40 +0200 Subject: Add extension for notification history --- lua/plugins/telescope.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 9459a3e..70eae7a 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -260,6 +260,8 @@ require('telescope').load_extension('ui-select') require("telescope").load_extension("file_browser") require('telescope').load_extension('changed_files') require('telescope').load_extension('media_files') +--require('telescope').extensions.notify.notify() +require('telescope').load_extension('notify') function M.find_configs() require("telescope.builtin").find_files { -- cgit v1.2.3 From 8b5a3e73e4c00f5761fe54eaac9a4753c5a061f7 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 13 Feb 2023 18:30:32 +0200 Subject: Reinstall "iamcco/markdown-preview.nvim" --- lua/user/pack.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index b96f753..92366dd 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -218,14 +218,16 @@ return packer.startup(function(use) require("crates").setup() end, }) - --use({ - -- "iamcco/markdown-preview.nvim", -- Markdown Preview - -- run = function() vim.fn["mkdp#util#install"]() end, - --}) + use({ + "iamcco/markdown-preview.nvim", -- Markdown Preview + run = function() vim.fn["mkdp#util#install"]() end, + }) use({ "ellisonleao/glow.nvim", -- Markdown Preview config = function() - require("glow").setup() + require("glow").setup({ + style = "dark", + }) end }) -- cgit v1.2.3 From 7880213702dcba614f11f5bc82885469bbe7e5ad Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 13 Feb 2023 20:00:42 +0200 Subject: Add Zen-mode toggle --- lua/user/keys.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 32a4160..c97321d 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -189,6 +189,7 @@ map('n', 'tb', ':call utils#Toggle_transparent_background()') -- Toggle zoom map("n", "z", ":call utils#ZoomToggle()") +map("n", "z", "|_") -- Toggle statusline map('n', '', ':call ToggleHiddenAll()') @@ -277,3 +278,6 @@ map("n", "mg", "Glow") -- Autopairs map("n", "ww", "lua require('user.mods').Toggle_autopairs()") + +-- Zen-mode toggle +map("n", "zm", "ZenMode") -- cgit v1.2.3 From 989c2c88786020b9e83f25c41459a6e59ea6e962 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 14 Feb 2023 20:46:31 +0200 Subject: Modified Zen-mode mapping to not show messages after being called, mostly caused by vim-rooter --- lua/user/keys.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index c97321d..9d0ab73 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -280,4 +280,4 @@ map("n", "mg", "Glow") map("n", "ww", "lua require('user.mods').Toggle_autopairs()") -- Zen-mode toggle -map("n", "zm", "ZenMode") +map("n", "zm", "ZenMode | :echom ('Zen Mode') | :sl! | echo ('')") -- cgit v1.2.3 From 577c1f98f065e6d9be4cf658b4f60572af6a1811 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 14 Feb 2023 20:50:28 +0200 Subject: Mapping for vim-rooter --- lua/user/keys.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 9d0ab73..759fec3 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -281,3 +281,6 @@ map("n", "ww", "lua require('user.mods').Toggle_autopairs()") -- Zen-mode toggle map("n", "zm", "ZenMode | :echom ('Zen Mode') | :sl! | echo ('')") + +-- Vim-rooter +map("n", "ro", "Rooter") -- cgit v1.2.3 From 1b4a09fdf637ccfa7eba80c48350d68720fc93ec Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 14 Feb 2023 23:27:59 +0200 Subject: Commented out "Make vim-rooter message disappear after making it's changes" since it's much slower --- lua/user/mods.lua | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index f70fac5..0be0783 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -10,7 +10,6 @@ function M.executable(name) return false end - -------------------------------------------------- --- Check whether a feature exists in Nvim @@ -119,7 +118,26 @@ function M.Toggle_autopairs() end end -return M + +-------------------------------------------------- + +--- Make vim-rooter message disappear after making it's changes +--vim.cmd([[ +--let timer = timer_start(1000, 'LogTrigger', {}) +--func! LogTrigger(timer) +-- silent! +--endfunc +--]]) +-- +--vim.cmd([[ +--function! ConfigureChDir() +-- echo ('') +--endfunction +--" Call after vim-rooter changes the root dir +--autocmd User RooterChDir :sleep! | call LogTrigger(timer) | call ConfigureChDir() +--]]) -------------------------------------------------- + +return M -- cgit v1.2.3 From eb67fcd338a62ea2681949fb3ab3f058473425d1 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 14 Feb 2023 23:29:13 +0200 Subject: Fixed Zen-mode toggle from saying "Press ENTER or type command to contiune" --- lua/user/keys.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 759fec3..429604a 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -280,7 +280,7 @@ map("n", "mg", "Glow") map("n", "ww", "lua require('user.mods').Toggle_autopairs()") -- Zen-mode toggle -map("n", "zm", "ZenMode | :echom ('Zen Mode') | :sl! | echo ('')") +map("n", "zm", "ZenMode | :echom ('Zen Mode') | :sl! | echo ('')") -- Vim-rooter -map("n", "ro", "Rooter") +map("n", "ro", "Rooter | :sl! | echo ('')", term_opts) -- cgit v1.2.3 From b1462ed270bedf5e85f6bf4951194abccadfb528 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 14 Feb 2023 23:30:22 +0200 Subject: Fixed ToggleDiagnosticOpenFloat mapping from saying "Press enter or type command to continue" --- lua/plugins/lsp.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index c551b48..07c5c83 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -62,7 +62,7 @@ local on_attach = function(client, bufnr) map("n", "ga", "lua vim.lsp.buf.code_action()") map("n", "gf", "lua vim.lsp.buf.formatting()") --map("n", "go", "lua vim.diagnostic.open_float()") - map("n", "go", ":call utils#ToggleDiagnosticsOpenFloat() | :echom ('Toggle Diagnostics Float open/close...') | :sl! | echo ('')") + map("n", "go", ":call utils#ToggleDiagnosticsOpenFloat() | :echom ('Toggle Diagnostics Float open/close...') | :sl! | echo ('')") map("n", "[d", "lua vim.diagnostic.goto_prev()") map("n", "]d", "lua vim.diagnostic.goto_next()") map("n", "gs", "lua vim.lsp.buf.document_symbol()") @@ -72,10 +72,10 @@ local on_attach = function(client, bufnr) map("n", "wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end) - --map("n", "q", function() - -- vim.diagnostic.setqflist({ open = true }) - --end) - --map.('n', 'q', vim.diagnostic.setloclist) + map("n", "q", function() + vim.diagnostic.setqflist({ open = true }) + end) + map("n", "q", "lua vim.diagnostic.setloclist()") --map("n", "gk", "Lspsaga diagnostic_jump_prev") --map("n", "gj", "Lspsaga diagnostic_jump_next") @@ -150,7 +150,8 @@ end -- Open float for diagnostics automatically vim.cmd([[ augroup OpenFloat - autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,}) + " autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,}) + autocmd CursorHold * lua vim.diagnostic.open_float(nil, {focusable = false,}) augroup END ]]) -- cgit v1.2.3 From 9e8183c3566221476d96033c6ad2a997a7fa96a5 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 14 Feb 2023 23:31:09 +0200 Subject: Fixed DiagnosticOpenFloat toggle to not show in insert mode --- autoload/utils.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/utils.vim b/autoload/utils.vim index 81d1604..1f10423 100644 --- a/autoload/utils.vim +++ b/autoload/utils.vim @@ -28,7 +28,8 @@ function! utils#ToggleDiagnosticsOpenFloat() " Enable if toggled on if g:DiagnosticsOpenFloat augroup OpenFloat - autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,}) + autocmd! CursorHold * lua vim.diagnostic.open_float(nil, {focusable = false,}) + "autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,}) "autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,}) print ("vim.diagnostic.open_float enabled...") augroup END endif -- cgit v1.2.3