diff options
author | Squibid <me@zacharyscheiman.com> | 2024-01-30 21:52:24 -0500 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2024-01-30 21:52:24 -0500 |
commit | d94b454eb61a0d0a99f9939560506c2db24f3315 (patch) | |
tree | 52dd40a8d51a79896750fa0fd0ea85fd3445405f | |
parent | e669b3eb8e27069ed0c52ea269e3c27debb989b6 (diff) | |
download | nvim-d94b454eb61a0d0a99f9939560506c2db24f3315.tar.gz nvim-d94b454eb61a0d0a99f9939560506c2db24f3315.tar.bz2 nvim-d94b454eb61a0d0a99f9939560506c2db24f3315.zip |
way too lazy to sort this out, adding kitchen sink
-rw-r--r-- | after/plugin/autopairs.lua | 2 | ||||
-rw-r--r-- | after/plugin/cmp.lua | 5 | ||||
-rw-r--r-- | after/plugin/dressing.lua | 2 | ||||
-rw-r--r-- | after/plugin/git-yodel.lua | 7 | ||||
-rw-r--r-- | after/plugin/hlargs.lua | 6 | ||||
-rw-r--r-- | after/plugin/lsp.lua | 85 | ||||
-rw-r--r-- | after/plugin/lsplines.lua | 2 | ||||
-rw-r--r-- | after/plugin/statusline.lua | 2 | ||||
-rw-r--r-- | after/plugin/telescope.lua | 5 | ||||
-rw-r--r-- | after/plugin/ts.lua | 2 | ||||
-rw-r--r-- | colors/mellow.ext.lua | 35 | ||||
-rw-r--r-- | init.lua | 9 | ||||
-rw-r--r-- | lua/conf/binds.lua | 33 | ||||
-rw-r--r-- | lua/conf/opts.lua | 1 | ||||
-rw-r--r-- | lua/conf/plugins.lua | 22 | ||||
-rw-r--r-- | lua/core/misc.lua | 2 |
16 files changed, 101 insertions, 119 deletions
diff --git a/after/plugin/autopairs.lua b/after/plugin/autopairs.lua index c943733..4a5e138 100644 --- a/after/plugin/autopairs.lua +++ b/after/plugin/autopairs.lua @@ -1,4 +1,4 @@ -local status_ok, autopairs = pcall(require, "nvim-autopairs") +local status_ok, autopairs = pcall(require, "ultimate-autopair") if not status_ok then return end diff --git a/after/plugin/cmp.lua b/after/plugin/cmp.lua index 0e8de6b..7106aae 100644 --- a/after/plugin/cmp.lua +++ b/after/plugin/cmp.lua @@ -10,10 +10,6 @@ local has_words_before = function() [1]:sub(col, col):match("%s") == nil end --- insert '()' after completing a function -cmp.event:on('confirm_done', - require('nvim-autopairs.completion.cmp').on_confirm_done()) - local luasnip = require('luasnip') local neogen = require('neogen') require("luasnip.loaders.from_vscode").lazy_load() @@ -27,6 +23,7 @@ cmp.setup { sources = cmp.config.sources({ { name = 'nvim_lsp', keyword_length = 3 }, + { name = 'nvim_lua' }, { name = 'luasnip_choice' }, { name = 'async_path' }, { name = 'buffer', keyword_length = 3, max_item_count = 7 }, diff --git a/after/plugin/dressing.lua b/after/plugin/dressing.lua index 6beb0b7..bc21319 100644 --- a/after/plugin/dressing.lua +++ b/after/plugin/dressing.lua @@ -12,5 +12,5 @@ dressing.setup { }, select = { enabled = true, - } + } } diff --git a/after/plugin/git-yodel.lua b/after/plugin/git-yodel.lua index 434ce4f..8c814dc 100644 --- a/after/plugin/git-yodel.lua +++ b/after/plugin/git-yodel.lua @@ -4,9 +4,6 @@ if not status_ok then end yodel.setup { - diffpreview = { - border = 'shadow', - width = 'auto', - height = 'auto', - } + border = 'shadow', + position = 'auto' } diff --git a/after/plugin/hlargs.lua b/after/plugin/hlargs.lua deleted file mode 100644 index 85aa905..0000000 --- a/after/plugin/hlargs.lua +++ /dev/null @@ -1,6 +0,0 @@ -local status_ok, hlargs = pcall(require, "hlargs") -if not status_ok then - return -end - -hlargs.setup {} diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua index 9eab3f1..8610be0 100644 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -3,11 +3,21 @@ if not status_ok then return end -local function lsp_keymaps(bufnr) +-- configure lsp when attached +local function lsp_attach(client, bufnr) + -- helper functions + local function set_lsp_sign(name, text) + vim.fn.sign_define(name, { text = text, texthl = name }) + end + local map = function(m, lhs, rhs) - local opts = {remap = false, silent = true, buffer = bufnr} + local opts = { remap = false, silent = true, buffer = bufnr } vim.keymap.set(m, lhs, rhs, opts) end + set_lsp_sign("DiagnosticSignError", "x") + set_lsp_sign("DiagnosticSignWarn" , "!") + set_lsp_sign("DiagnosticSignInfo" , "i") + set_lsp_sign("DiagnosticSignHint" , "h") -- LSP actions map('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>') @@ -17,64 +27,43 @@ local function lsp_keymaps(bufnr) map('n', 'gY', '<cmd>lua vim.lsp.buf.type_definition()<cr>') map('n', 'gR', '<cmd>lua vim.lsp.buf.references()<cr>') map('n', '<S-Tab>', '<cmd>lua vim.lsp.buf.signature_help()<cr>') - map('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>') + map('n', '<leader>lr', '<cmd>lua vim.lsp.buf.rename()<cr>') map('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>') -- Diagnostics map('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>') map('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>') -end -local function set_lsp_sign(name, text) - vim.fn.sign_define(name, {text = text, texthl = name}) -end -set_lsp_sign("DiagnosticSignError", "x") -set_lsp_sign("DiagnosticSignWarn" , "!") -set_lsp_sign("DiagnosticSignInfo" , "i") -set_lsp_sign("DiagnosticSignHint" , "h") - -local function lsp_settings() - vim.diagnostic.config({ - virtual_text = false, - signs = true, - update_in_insert = false, - underline = true, - severity_sort = true, - }) - - vim.lsp.handlers['textDocument/hover'] = vim.lsp.with( vim.lsp.handlers.hover, - { border = 'shadow', } - ) - vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with( - vim.lsp.handlers.signature_help, - {border = 'shadow'} - ) - local command = vim.api.nvim_create_user_command - command('LspWorkspaceAdd', function() + vim.api.nvim_buf_create_user_command(bufnr, 'LspFormat', function() + vim.lsp.buf.format() + end, {desc = 'Format buffer with language server'}) + vim.api.nvim_buf_create_user_command('LspWorkspaceAdd', function() vim.lsp.buf.add_workspace_folder() - end, {desc = 'Add folder to workspace'}) - command('LspWorkspaceList', function() - vim.notify(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, {desc = 'List workspace folders'}) - command('LspWorkspaceRemove', function() + end, { desc = 'Add folder to workspace' }) + vim.api.nvim_buf_create_user_command('LspWorkspaceList', function() + vim.notify(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, { desc = 'List workspace folders' }) + vim.api.nvim_buf_create_user_command('LspWorkspaceRemove', function() vim.lsp.buf.remove_workspace_folder() - end, {desc = 'Remove folder from workspace'}) + end, { desc = 'Remove folder from workspace' }) end -local function lsp_attach(client, bufnr) - local buf_command = vim.api.nvim_buf_create_user_command - - lsp_keymaps(bufnr) - - buf_command(bufnr, 'LspFormat', function() - vim.lsp.buf.format() - end, {desc = 'Format buffer with language server'}) -end +vim.diagnostic.config({ + virtual_text = false, + signs = true, + update_in_insert = false, + underline = true, + severity_sort = true, +}) -lsp_settings() +vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, + { border = 'shadow', }) +vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with( + vim.lsp.handlers.signature_help, { border = 'shadow' }) -require('mason').setup({}) -require('mason-lspconfig').setup({}) +-- get servers and attach to them +require('mason').setup {} +require('mason-lspconfig').setup {} local get_servers = require('mason-lspconfig').get_installed_servers for _, server_name in ipairs(get_servers()) do diff --git a/after/plugin/lsplines.lua b/after/plugin/lsplines.lua index dcda047..5307c09 100644 --- a/after/plugin/lsplines.lua +++ b/after/plugin/lsplines.lua @@ -3,7 +3,7 @@ if not status_ok then return end -lines.setup {} +lines.setup() vim.diagnostic.config { virtual_lines = { diff --git a/after/plugin/statusline.lua b/after/plugin/statusline.lua index 936b464..eff407c 100644 --- a/after/plugin/statusline.lua +++ b/after/plugin/statusline.lua @@ -71,7 +71,7 @@ el.setup { hl_delete = hl("GitSignsDelete", true), }}, { { " " }, c.line { - fmt = "ʟ[%s]", + fmt = "[%s]", }, required = true }, } end diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua index 601a800..1f2d34a 100644 --- a/after/plugin/telescope.lua +++ b/after/plugin/telescope.lua @@ -48,7 +48,7 @@ telescope.setup { local extension = split_path[#split_path] return vim.tbl_contains(image_extensions, extension) end - if is_image(filepath) then + if is_image(filepath) and vim.fn.executable('chafa') == 1 then local term = vim.api.nvim_open_term(bufnr, {}) local function send_output(_, data, _) for _, d in ipairs(data) do @@ -57,7 +57,7 @@ telescope.setup { end vim.fn.jobstart({ 'chafa', '-C', 'on', '--animate', 'off', '-s', - (telescopew() - 10)..'x20', '--clear', filepath + '23x18', '--clear', filepath }, { on_stdout = send_output, stdout_buffered = true, pty = true }) a.nvim_set_option_value("number", false, { buf = bufnr }) else @@ -87,6 +87,7 @@ telescope.setup { telescope.load_extension('file_browser') telescope.load_extension('projects') telescope.load_extension('fzf') +telescope.load_extension('harpoon') a.nvim_create_autocmd('User', { pattern = 'TelescopePreviewerLoaded', diff --git a/after/plugin/ts.lua b/after/plugin/ts.lua index 96bebb6..59dea81 100644 --- a/after/plugin/ts.lua +++ b/after/plugin/ts.lua @@ -1,6 +1,6 @@ local status_ok, treesitter = pcall(require, "nvim-treesitter.configs") if not status_ok then - return + return end treesitter.setup { diff --git a/colors/mellow.ext.lua b/colors/mellow.ext.lua index a3080a3..aed1972 100644 --- a/colors/mellow.ext.lua +++ b/colors/mellow.ext.lua @@ -11,6 +11,17 @@ local highlight = function(group, opts, space) end end +local function cpyhl(hlgroup) + local ok, hl = pcall(vim.api.nvim_get_hl_by_name, hlgroup, true) + if not ok then return end + for _, key in pairs({"foreground", "background", "special"}) do + if hl[key] then + hl[key] = string.format("#%06x", hl[key]) + end + end + return hl +end + local function getcolor(index, fallback) return vim.g['terminal_color_' .. index] or fallback end @@ -36,31 +47,15 @@ local colors = { if pcall(require, "mellow") then c = require('mellow.colors').dark end --- vim highlights ------------------------------------------------------------- -highlight('CursorLineNr', { bold = true }) - -- remove tildas highlight('EndOfBuffer', { fg = vim.g.terminal_color_background }) +-- make all backgrounds the same color +highlight('NormalNC', cpyhl('Normal')) + -- plugin highlights ---------------------------------------------------------- -- telescope -highlight('TelescopeMatching', { bg = c.gray01, fg = c.blue }) - -highlight('TelescopePreviewBorder', { bg = c.bg_dark }) -highlight('TelescopePreviewNormal', { bg = c.bg_dark }) -highlight('TelescopePreviewTitle', { bg = c.bg_dark, fg = c.bg_dark }) - -highlight('TelescopePromptBorder', { bg = c.gray01 }) -highlight('TelescopePromptNormal', { bg = c.gray01 }) -highlight('TelescopePromptPrefix', { bg = c.gray01 }) -highlight('TelescopePromptTitle', { bg = c.gray01 }) - -highlight('TelescopeResultsBorder', { bg = c.bg_dark }) -highlight('TelescopeResultsNormal', { bg = c.bg_dark }) -highlight('TelescopeResultsTitle', { bg = c.bg_dark, fg = c.bg_dark }) - -highlight('TelescopeSelection', { bg = vim.g.terminal_color_background }) -highlight('TelescopeSelectionCaret', { bg = vim.g.terminal_color_background, fg = c.cyan, bold = true }) +highlight('TelescopeMatching', { fg = c.yellow }) -- alpha highlight('AlphaHeader', { fg = colors.blue }) @@ -9,15 +9,14 @@ vim.loader.enable() -- main lua files ------------------------------------------------------------- misc = require('core.misc') -require('bootstrap') -require('conf') - +misc.include('bootstrap') +misc.include('conf') -- core lua files ------------------------------------------------------------- -require('core.conf') +misc.include('core.conf') -- call all snippets in the lua/snippets directory ---------------------------- if pcall(require, "luasnip") then - require('snippet.shorthands') + misc.include('snippet.shorthands') for _, file in ipairs(vim.fn.readdir(vim.fn.stdpath('config')..'/lua/snippet', [[v:val =~ '\.lua$']])) do require('snippet.'..file:gsub('%.lua$', '')) diff --git a/lua/conf/binds.lua b/lua/conf/binds.lua index 3e9a3aa..11c791c 100644 --- a/lua/conf/binds.lua +++ b/lua/conf/binds.lua @@ -93,15 +93,8 @@ if pcall(require, "telescope") then -- search for vim options map('n', '<leader>sv', telebuilt.vim_options, { desc = 'Find vim options.' }) -- search for string in project - map('n', '<leader>sp', function() - 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.' }) + map('n', '<leader>sp', telebuilt.live_grep, { desc = 'Find string in project.' }) + -- Code Actions (requires telescope) if pcall(require, "actions-preview") then map({ "n", "v" }, "<leader>ca", require("actions-preview").code_actions, { @@ -110,6 +103,24 @@ if pcall(require, "telescope") then end end +-- harpoon +if pcall(require, 'harpoon') then + local mark = require("harpoon.mark") + local ui = require("harpoon.ui") + + map("n", "<leader>a", function() + mark.add_file() + vim.notify('added new file to quickmarks', vim.log.levels.INFO, { + title = misc.appid, + }) + end) + map("n", "<C-e>", ui.toggle_quick_menu) + map('n', '<C-q>', function() ui.nav_file(1) end) + map('n', '<C-g>', function() ui.nav_file(2) end) + map('n', '<C-h>', function() ui.nav_file(3) end) + map('n', '<C-i>', function() ui.nav_file(4) end) +end + map('n', '<leader>u', '<cmd>UndotreeToggle<CR>', { desc = 'Open undo tree.' }) map('n', '<leader>f', '<cmd>SFMToggle<CR>', { desc = 'Open file tree view.' }) map('n', '<leader>b', '<cmd>JABSOpen<CR>', { desc = 'Switch between buffers.' }) @@ -119,10 +130,6 @@ if pcall(require, "smart-splits") then map('n', '<leader>r', smartsplits.start_resize_mode) end --- toggle term (don't use leader key in these binds) -map({'n', 't'}, '<C-\\>', '<cmd>ToggleTerm direction=float<CR>') -map({'n', 't'}, '<C-g>', '<cmd>lua _glow()<CR>') - -- git map('n', '<leader>gp', '<cmd>Gitsigns preview_hunk_inline<CR>') map('n', '<leader>gs', '<cmd>Gitsigns stage_hunk<CR>') diff --git a/lua/conf/opts.lua b/lua/conf/opts.lua index 3997b5f..d229bcf 100644 --- a/lua/conf/opts.lua +++ b/lua/conf/opts.lua @@ -36,6 +36,7 @@ misc.colorscheme('mellow') -- better editing ------------------------------------------------------------- o.clipboard = 'unnamedplus' -- system clipboard o.splitkeep = "screen" -- keep same text on screen when spliting +o.updatetime = 200 -- file saving ---------------------------------------------------------------- o.swapfile = false diff --git a/lua/conf/plugins.lua b/lua/conf/plugins.lua index 45b1433..4b2bcf1 100644 --- a/lua/conf/plugins.lua +++ b/lua/conf/plugins.lua @@ -7,7 +7,7 @@ require('dep') { }, -- colorschemes ------------------------------------------------------------- - { 'kvrohit/mellow.nvim', + { 'mellow-theme/mellow.nvim', requires = 'nvim-treesitter/nvim-treesitter' }, @@ -32,17 +32,19 @@ require('dep') { -- 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', - }, { 'chentoast/marks.nvim' }, -- marks in gutter { 'vidocqh/auto-indent.nvim' }, -- better tabbing into indents { 'mbbill/undotree' }, -- careful this one is written in vimscript { 'dhruvasagar/vim-table-mode' }, -- same with this one - { 'windwp/nvim-autopairs' }, + { 'altermo/ultimate-autopair.nvim', -- autopairs + branch = 'v0.6' + }, { 'numToStr/Comment.nvim' }, { 'ahmedkhalf/project.nvim' }, -- cd into root of project { 'mrjones2014/smart-splits.nvim'}, -- buffer resizing + { 'ThePrimeagen/harpoon', -- super duper fast navigation through files + requires = 'nvim-lua/plenary.nvim' + }, -- note taking -------------------------------------------------------------- { 'nvim-neorg/neorg', @@ -82,7 +84,6 @@ require('dep') { -- treesitter + colorizing -------------------------------------------------- { 'nvim-treesitter/nvim-treesitter', deps = { - 'm-demare/hlargs.nvim', 'Wansmer/treesj', 'nvim-treesitter/nvim-treesitter-context' } @@ -98,19 +99,20 @@ require('dep') { 'lukas-reineke/cmp-under-comparator', -- better results 'hrsh7th/cmp-buffer', -- buffers 'FelipeLema/cmp-async-path', -- path - 'hrsh7th/cmp-calc', -- calculator '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' + requires = 'L3MON4D3/LuaSnip', } }, }, -- snippets ----------------------------------------------------------------- { 'L3MON4D3/LuaSnip', - deps = 'rafamadriz/friendly-snippets' + deps = 'rafamadriz/friendly-snippets', + config = function() + vim.cmd('make install_jsregexp') + end }, -- lsp ---------------------------------------------------------------------- diff --git a/lua/core/misc.lua b/lua/core/misc.lua index 41cbf93..6f69e81 100644 --- a/lua/core/misc.lua +++ b/lua/core/misc.lua @@ -13,7 +13,7 @@ end function M.include(fn) if not pcall(require, fn) then - vim.notify('Could not find '..fn, vim.log.levels.WARN, { title = M.appid }) + vim.notify('Could not find "'..fn, vim.log.levels.WARN..'"', { title = M.appid }) end end |