diff options
Diffstat (limited to '')
-rw-r--r-- | lua/conf/binds.lua (renamed from lua/core/binds.lua) | 28 | ||||
-rw-r--r-- | lua/conf/opts.lua (renamed from lua/core/opts.lua) | 4 | ||||
-rw-r--r-- | lua/conf/plugins.lua (renamed from lua/core/plugins.lua) | 47 | ||||
-rw-r--r-- | lua/core/auto.lua | 30 | ||||
-rw-r--r-- | lua/core/cmds.lua | 8 | ||||
-rw-r--r-- | lua/core/conf.lua | 81 | ||||
-rw-r--r-- | lua/core/handler.lua | 5 | ||||
-rw-r--r-- | lua/core/misc.lua | 30 | ||||
-rw-r--r-- | lua/core/statusbar/components.lua (renamed from lua/components.lua) | 0 | ||||
-rw-r--r-- | lua/core/theme.lua | 76 |
10 files changed, 236 insertions, 73 deletions
diff --git a/lua/core/binds.lua b/lua/conf/binds.lua index b1e98be..5fc8055 100644 --- a/lua/core/binds.lua +++ b/lua/conf/binds.lua @@ -1,3 +1,5 @@ +local conf = require('core.conf') + local function map(mode, bind, cmd, opts) opts = opts or {} opts['noremap'] = true @@ -52,6 +54,9 @@ map('n', '][', '<cmd>tabc<CR>') map('n', '[[', '<cmd>tabp<CR>') map('n', ']]', '<cmd>tabN<CR>') +-- config binds --------------------------------------------------------------- +map('n', '<leader>m', conf.configmenu, { desc = 'Neovim config manager menu', }) + -- plugin binds --------------------------------------------------------------- -- pretty lsp view @@ -78,7 +83,7 @@ if pcall(require, "telescope") then { desc = 'Find LSP Symbols.' }) -- search for keybinds map('n', '<leader>sk', telebuilt.keymaps, - { desc = 'Find nvim Highlights.' }) + { desc = 'Find nvim Keymaps.' }) -- search for highlights map('n', '<leader>sh', telebuilt.highlights, { desc = 'Find nvim Highlights.' }) @@ -89,7 +94,13 @@ if pcall(require, "telescope") then map('n', '<leader>sv', telebuilt.vim_options, { desc = 'Find vim options.' }) -- search for string in project map('n', '<leader>sp', function() - telebuilt.grep_string({ search = vim.fn.input('Find string in project > ')}) + vim.ui.input({ prompt = 'Find string in project' }, function(input) + if not input or input == '' then + vim.notify('No query!', vim.log.levels.WARN, { title = misc.appid }) + return nil + end + telebuilt.grep_string({ search = input }) + end) end, { desc = 'Find string in project.' }) -- Code Actions (requires telescope) if pcall(require, "actions-preview") then @@ -141,17 +152,18 @@ end -- venn function _G.Toggle_venn() + local mapb = vim.api.nvim_buf_set_keymap local venn_enabled = vim.inspect(vim.b.venn_enabled) if venn_enabled == "nil" then vim.b.venn_enabled = true vim.cmd([[setlocal ve=all]]) -- draw a line on HJKL keystokes - vim.api.nvim_buf_set_keymap(0, "n", "J", "<C-v>j:VBox<CR>", {noremap = true}) - vim.api.nvim_buf_set_keymap(0, "n", "K", "<C-v>k:VBox<CR>", {noremap = true}) - vim.api.nvim_buf_set_keymap(0, "n", "L", "<C-v>l:VBox<CR>", {noremap = true}) - vim.api.nvim_buf_set_keymap(0, "n", "H", "<C-v>h:VBox<CR>", {noremap = true}) + mapb(0, "n", "J", "<C-v>j:VBox<CR>", { noremap = true }) + mapb(0, "n", "K", "<C-v>k:VBox<CR>", { noremap = true }) + mapb(0, "n", "L", "<C-v>l:VBox<CR>", { noremap = true }) + mapb(0, "n", "H", "<C-v>h:VBox<CR>", { noremap = true }) -- draw a box by pressing "f" with visual selection - vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", {noremap = true}) + mapb(0, "v", "f", ":VBox<CR>", { noremap = true }) else vim.cmd[[setlocal ve=]] vim.cmd[[mapclear <buffer>]] @@ -159,4 +171,4 @@ function _G.Toggle_venn() end end -- toggle keymappings for venn using <leader>v -vim.api.nvim_set_keymap('n', '<leader>v', ":lua Toggle_venn()<CR>", { noremap = true}) +map('n', '<leader>v', ":lua Toggle_venn()<CR>") diff --git a/lua/core/opts.lua b/lua/conf/opts.lua index 82d88bd..3997b5f 100644 --- a/lua/core/opts.lua +++ b/lua/conf/opts.lua @@ -31,11 +31,11 @@ o.softtabstop = tabwidth -- colorscheme o.termguicolors = true -vim.cmd('colorscheme mellow') -- mellow -vim.cmd('colorscheme mellow+') -- some changes +misc.colorscheme('mellow') -- better editing ------------------------------------------------------------- o.clipboard = 'unnamedplus' -- system clipboard +o.splitkeep = "screen" -- keep same text on screen when spliting -- file saving ---------------------------------------------------------------- o.swapfile = false diff --git a/lua/core/plugins.lua b/lua/conf/plugins.lua index db20075..23be6c6 100644 --- a/lua/core/plugins.lua +++ b/lua/conf/plugins.lua @@ -1,15 +1,11 @@ -require 'dep' { - sync = "always", +require('dep') { -- dep manages dep ---------------------------------------------------------- { 'squibid/dep', url = 'https://git.squi.bid/dep', + pin = true, -- branch = 'dev' }, - { 'squibid/git-yodel', - url = 'https://git.squi.bid/git-yodel' - }, - -- colorschemes ------------------------------------------------------------- { 'kvrohit/mellow.nvim', requires = 'nvim-treesitter/nvim-treesitter' @@ -20,19 +16,24 @@ require 'dep' { { 'folke/which-key.nvim' }, -- key map help { 'rcarriga/nvim-notify' }, -- notifications { 'tjdevries/express_line.nvim', -- status bar - requires = 'nvim-lua/plenary.nvim', + requires = 'nvim-lua/plenary.nvim' }, { 'goolord/alpha-nvim' }, -- start page { 'dinhhuy258/sfm.nvim', -- tree view - deps = 'dinhhuy258/sfm-git.nvim', + deps = 'dinhhuy258/sfm-git.nvim' }, { 'matbme/JABS.nvim' }, -- buffer switcher - { 'tomiis4/Hypersonic.nvim' }, -- regex helper/displayer + { 'stevearc/dressing.nvim', -- nice ui selectors + requires = 'nvim-telescope/telescope.nvim' + }, + { 'lukas-reineke/headlines.nvim', + requires = 'nvim-neorg/neorg' + }, -- functional plugins ------------------------------------------------------- { 'lewis6991/gitsigns.nvim' }, -- very helpful git things { 'squibid/git-yodel', -- git cache diff preview when in commit buffer - url = 'https://git.squi.bid/git-yodel' + url = 'https://git.squi.bid/git-yodel', }, { 'chentoast/marks.nvim' }, -- marks in gutter { 'vidocqh/auto-indent.nvim' }, -- better tabbing into indents @@ -65,23 +66,28 @@ require 'dep' { requires = 'nvim-lua/plenary.nvim', deps = { 'nvim-telescope/telescope-file-browser.nvim', - 'nvim-telescope/telescope-ui-select.nvim', 'nvim-telescope/telescope-symbols.nvim', - 'axieax/urlview.nvim', + 'axieax/urlview.nvim' } }, + { 'nvim-telescope/telescope-fzf-native.nvim', + config = function() + vim.cmd('make') + end, + requires = 'nvim-telescope/telescope.nvim' + }, -- treesitter + colorizing -------------------------------------------------- { 'nvim-treesitter/nvim-treesitter', deps = { 'm-demare/hlargs.nvim', 'Wansmer/treesj', - 'nvim-treesitter/nvim-treesitter-context', + 'nvim-treesitter/nvim-treesitter-context' } }, { 'NvChad/nvim-colorizer.lua' }, { 'folke/todo-comments.nvim', - requires = 'nvim-lua/plenary.nvim', + requires = 'nvim-lua/plenary.nvim' }, -- cmp ---------------------------------------------------------------------- @@ -91,23 +97,24 @@ require 'dep' { 'hrsh7th/cmp-buffer', -- buffers 'FelipeLema/cmp-async-path', -- path 'hrsh7th/cmp-calc', -- calculator - 'saadparwaiz1/cmp_luasnip', -- snippets 'hrsh7th/cmp-nvim-lsp', -- lsp 'uga-rosa/cmp-dictionary', -- dictionary 'hrsh7th/cmp-nvim-lua', -- nvim lua api + { 'doxnit/cmp-luasnip-choice', -- luasnip + requires = 'L3MON4D3/LuaSnip' + } }, }, -- snippets ----------------------------------------------------------------- { 'L3MON4D3/LuaSnip', - deps = 'rafamadriz/friendly-snippets', + deps = 'rafamadriz/friendly-snippets' }, - { 'doxnit/cmp-luasnip-choice' }, -- lsp ---------------------------------------------------------------------- { 'neovim/nvim-lspconfig' }, -- setup lsp { 'j-hui/fidget.nvim', -- shows lsp progress - branch = 'legacy', + branch = 'legacy' }, { 'ray-x/lsp_signature.nvim' }, -- see information about the current function @@ -121,14 +128,14 @@ require 'dep' { }, { 'whynothugo/lsp_lines.nvim', - url = 'https://git.sr.ht/~whynothugo/lsp_lines.nvim', + url = 'https://git.sr.ht/~whynothugo/lsp_lines.nvim' }, -- mason -------------------------------------------------------------------- { 'williamboman/mason.nvim', deps = { 'WhoIsSethDaniel/mason-tool-installer.nvim', - 'williamboman/mason-lspconfig.nvim', + 'williamboman/mason-lspconfig.nvim' } } } diff --git a/lua/core/auto.lua b/lua/core/auto.lua deleted file mode 100644 index 170f2d7..0000000 --- a/lua/core/auto.lua +++ /dev/null @@ -1,30 +0,0 @@ -local function auto(event, opts) - a.nvim_create_autocmd(event, opts) -end - -a.nvim_create_augroup('bufcheck', { clear = true }) - -auto('TextYankPost', { -- highlight yanks - group = 'bufcheck', - pattern = '*', - desc = 'Highlight on yank.', - callback = function() - vim.highlight.on_yank{ timeout = 250 } - end -}) - -auto('BufRead', { -- return to last place - pattern = '*', - command = [[call setpos(".", getpos("'\""))]], - desc = 'Return to the last place the buffer was closed in.', -}) - -auto('BufWritePre', { -- make dirs when they don't exist - pattern = '*', - group = vim.api.nvim_create_augroup('auto_create_dir', { clear = true }), - desc = 'Basically mkdir -p.', - callback = function(ctx) - local dir = vim.fn.fnamemodify(ctx.file, ':p:h') - vim.fn.mkdir(dir, 'p') - end -}) diff --git a/lua/core/cmds.lua b/lua/core/cmds.lua deleted file mode 100644 index 3cc78e1..0000000 --- a/lua/core/cmds.lua +++ /dev/null @@ -1,8 +0,0 @@ -local function cmd(name, exec, opts) - opts = opts or {} - vim.api.nvim_create_user_command(name, exec, opts) -end - -cmd('Colorscheme', function() - require('telescope.builtin').colorscheme() -end) diff --git a/lua/core/conf.lua b/lua/core/conf.lua new file mode 100644 index 0000000..72dd9bf --- /dev/null +++ b/lua/core/conf.lua @@ -0,0 +1,81 @@ +local pickers = require("telescope.pickers") +local finders = require("telescope.finders") +local previewers = require("telescope.previewers") +local conf = require("telescope.config").values +local actions = require("telescope.actions") +local action_state = require("telescope.actions.state") + +local M = {} + +local function genmenu() + local list = {} + local function add(name, plug) + if not plug then + table.insert(list, name) + elseif package.loaded[plug] then + table.insert(list, name) + end + end + + add('Edit Config', nil) + add('Update Plugins', 'dep') + add('Keybinds', 'telescope') + add('Colorscheme', 'telescope') + + return list +end + +function M.configmenu() + pickers.new({ + prompt_title = "Nvim Config Menu", + finder = finders.new_table { results = genmenu() }, + sorter = conf.generic_sorter(), + previewer = previewers.new_buffer_previewer { + define_preview = function(self, entry) + local lines = { + 'a' + } + if entry.value == "Edit Config" then + lines = misc.readf(os.getenv('XDG_CONFIG_HOME')..'/nvim/init.lua') + local ft = vim.filetype.match({ + filename = os.getenv('XDG_CONFIG_HOME')..'/nvim/init.lua' }) + require("telescope.previewers.utils").highlighter(self.state.bufnr, ft) + elseif entry.value == "Colorscheme" then + lines = vim.fn.getcompletion('', 'color') + for k, v in pairs(lines) do + if v.find(v, '.ext') then + table.remove(lines, k) + break + end + end + end + vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, lines) + end + }, + + attach_mappings = function(bufnr, map) + actions.select_default:replace(function() + actions.close(bufnr) + local selection = action_state.get_selected_entry() + if selection[1] == 'Edit Config' then + vim.cmd('e $XDG_CONFIG_HOME/nvim/init.lua') + elseif selection[1] == 'Update Plugins' then + require('dep').sync() + if package.loaded['nvim-treesitter'] then + vim.cmd('TSUpdate') + end + if package.loaded['mason'] then + require('mason.api.command').MasonUpdate() + end + elseif selection[1] == 'Keybinds' then + require('telescope.builtin').keymaps() + elseif selection[1] == 'Colorscheme' then + require('core.theme').switcher() + end + end) + return true + end, + }):find() +end + +return M diff --git a/lua/core/handler.lua b/lua/core/handler.lua deleted file mode 100644 index 0038146..0000000 --- a/lua/core/handler.lua +++ /dev/null @@ -1,5 +0,0 @@ -require('core.plugins') -- load plugins first to allow colorscheme to be set in opts -require('core.opts') -require('core.binds') -require('core.auto') -require('core.cmds') diff --git a/lua/core/misc.lua b/lua/core/misc.lua new file mode 100644 index 0000000..41cbf93 --- /dev/null +++ b/lua/core/misc.lua @@ -0,0 +1,30 @@ +local M = {} + +M.appid = "Nvim Config" + +function M.colorscheme(name) + vim.cmd('colorscheme '..name) + for k, v in pairs(vim.fn.getcompletion('', 'color')) do + if v == name..'.ext' then + vim.cmd('colorscheme '..name..'.ext') + end + end +end + +function M.include(fn) + if not pcall(require, fn) then + vim.notify('Could not find '..fn, vim.log.levels.WARN, { title = M.appid }) + end +end + +function M.readf(fn) + local f = io.open(fn, "r") + if not f then return nil end + local tab = {} + for l in f:lines() do + table.insert(tab, l) + end + return tab +end + +return M diff --git a/lua/components.lua b/lua/core/statusbar/components.lua index cce3127..cce3127 100644 --- a/lua/components.lua +++ b/lua/core/statusbar/components.lua diff --git a/lua/core/theme.lua b/lua/core/theme.lua new file mode 100644 index 0000000..9d508f2 --- /dev/null +++ b/lua/core/theme.lua @@ -0,0 +1,76 @@ +local pickers = require("telescope.pickers") +local finders = require("telescope.finders") +local previewers = require("telescope.previewers") +local conf = require("telescope.config").values +local actions = require("telescope.actions") +local action_set = require("telescope.actions.set") +local action_state = require("telescope.actions.state") +local misc = require('core.misc') + +local M = {} + +function M.switcher() + local bufnr = vim.api.nvim_get_current_buf() + + -- show current buffer content in previewer + local colors = vim.fn.getcompletion('', 'color') + for k, v in pairs(colors) do + if v.find(v, '.ext') then + table.remove(colors, k) + break + end + end + + -- our picker function: colors + pickers.new({ + prompt_title = "Set Nvim Colorscheme", + finder = finders.new_table { results = colors }, + sorter = conf.generic_sorter(), + previewer = previewers.new_buffer_previewer { + define_preview = function(self, entry) + -- add content + local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) + vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, lines) + + -- add syntax highlighting in previewer + local ft = (vim.filetype.match { buf = bufnr } or "diff"):match "%w+" + require("telescope.previewers.utils").highlighter(self.state.bufnr, ft) + end + }, + + attach_mappings = function(prompt_bufnr, map) + -- reload theme while typing + vim.schedule(function() + vim.api.nvim_create_autocmd("TextChangedI", { + buffer = prompt_bufnr, + callback = function() + if action_state.get_selected_entry() then + misc.colorscheme(action_state.get_selected_entry()[1]) + end + end, + }) + end) + + -- reload theme on cycling + actions.move_selection_previous:replace(function() + action_set.shift_selection(prompt_bufnr, -1) + misc.colorscheme(action_state.get_selected_entry()[1]) + end) + actions.move_selection_next:replace(function() + action_set.shift_selection(prompt_bufnr, 1) + misc.colorscheme(action_state.get_selected_entry()[1]) + end) + + -- reload theme on selection + actions.select_default:replace(function() + if action_state.get_selected_entry() then + actions.close(prompt_bufnr) + misc.colorscheme(action_state.get_selected_entry()[1]) + end + end) + return true + end, + }):find() +end + +return M |