From 05d00e70e7574cdfac5086d7552b8c061a239555 Mon Sep 17 00:00:00 2001 From: Volodymyr Patuta Date: Fri, 31 May 2024 11:03:10 +0200 Subject: [PATCH] update, add none-ls --- init.lua | 3 +- lua/plugins/cmp.lua | 8 +- lua/plugins/dap.lua | 10 +- lua/plugins/editor.lua | 10 +- lua/plugins/lsp/init.lua | 4 +- lua/plugins/lsp/ui.lua | 86 +++++++-------- lua/plugins/misc.lua | 76 +++++++------ .../{unused/none-ls.lua.bak => none-ls.lua} | 0 lua/plugins/oil.lua | 18 ++- lua/plugins/snippets/init.lua | 104 +++++++++--------- lua/plugins/toggleterm.lua | 14 ++- lua/plugins/treesitter.lua | 2 +- lua/plugins/ui.lua | 42 +++---- lua/plugins/which-key.lua | 8 +- 14 files changed, 207 insertions(+), 178 deletions(-) rename lua/plugins/{unused/none-ls.lua.bak => none-ls.lua} (100%) diff --git a/init.lua b/init.lua index 0eca1cf..7b198c4 100644 --- a/init.lua +++ b/init.lua @@ -13,9 +13,10 @@ vim.api.nvim_create_autocmd('User', { local Terminal = require('toggleterm.terminal').Terminal local lazygit = Terminal:new({ + count = 5, cmd = "lazygit", dir = "git_dir", - direction = "tab", + direction = "float", float_opts = { border = "none", }, diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 326d4c3..11f606f 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -37,7 +37,7 @@ return { }, experimental = { ghost_text = { - hl_group = { "Comment" }, + hl_group = { 'Comment' }, }, }, mapping = cmp.mapping.preset.insert { @@ -71,7 +71,7 @@ return { { name = 'buffer' }, }), formatting = { - format = require 'lspkind'.cmp_format({ + format = require('lspkind').cmp_format { mode = 'symbol_text', -- show only symbol annotations maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) -- can also be a function to dynamically calculate max width such as @@ -83,8 +83,8 @@ return { -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30)) before = function(entry, vim_item) return vim_item - end - }) + end, + }, }, } diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index 6a597ec..476c466 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -9,10 +9,10 @@ return { end return { - { 'dc', dap 'continue', desc = 'continue' }, - { 'ds', dap 'step_into', desc = 'step into' }, - { 'dn', dap 'step_over', desc = 'step over (next)' }, - { 'df', dap 'step_out', desc = 'step out (finish)' }, + { 'dc', dap 'continue', desc = 'continue' }, + { 'ds', dap 'step_into', desc = 'step into' }, + { 'dn', dap 'step_over', desc = 'step over (next)' }, + { 'df', dap 'step_out', desc = 'step out (finish)' }, { 'db', dap 'toggle_breakpoint', desc = 'toggle breakpoint' }, { 'do', @@ -27,7 +27,7 @@ return { desc = 'set conditional breakpoint', }, { 'dl', dap 'clear_breakpoints', desc = 'clear breakpoints' }, - { 'dq', dap 'terminate', desc = 'quit' }, + { 'dq', dap 'terminate', desc = 'quit' }, } end, }, diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua index 57db895..84b6586 100644 --- a/lua/plugins/editor.lua +++ b/lua/plugins/editor.lua @@ -2,7 +2,7 @@ return { { 'echasnovski/mini.diff', version = false, - event = "VeryLazy", + event = 'VeryLazy', opts = { -- Options for how hunks are visualized view = { @@ -59,7 +59,7 @@ return { -- Whether to wrap around edges during hunk navigation wrap_goto = false, }, - } + }, }, { 'nvim-telescope/telescope.nvim', @@ -88,10 +88,10 @@ return { defaults = { mappings = { i = { - [""] = require('telescope.actions').close - } + [''] = require('telescope.actions').close, + }, }, - } + }, } telescope.load_extension 'fzf' end, diff --git a/lua/plugins/lsp/init.lua b/lua/plugins/lsp/init.lua index f7a265d..af2b9a6 100644 --- a/lua/plugins/lsp/init.lua +++ b/lua/plugins/lsp/init.lua @@ -3,6 +3,7 @@ return { 'neovim/nvim-lspconfig', event = { 'BufReadPre', 'BufNewFile' }, dependencies = { + { 'nvimtools/none-ls.nvim' }, { 'williamboman/mason.nvim' }, { 'williamboman/mason-lspconfig.nvim' }, { 'hrsh7th/cmp-nvim-lsp' }, @@ -10,8 +11,7 @@ return { { 'simrat39/rust-tools.nvim' }, { 'j-hui/fidget.nvim', - opts = { - }, + opts = {}, }, }, config = function() diff --git a/lua/plugins/lsp/ui.lua b/lua/plugins/lsp/ui.lua index 0e190dd..319650a 100644 --- a/lua/plugins/lsp/ui.lua +++ b/lua/plugins/lsp/ui.lua @@ -1,53 +1,53 @@ local M = {} function M.setup() - -- Signs - local signs = { Error = "", Warn = "", Hint = "", Info = "" } - for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) - end + -- Signs + local signs = { Error = '', Warn = '', Hint = '', Info = '' } + for type, icon in pairs(signs) do + local hl = 'DiagnosticSign' .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) + end - -- Floating window borders - local border = { - { "╭", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╮", "FloatBorder" }, - { "│", "FloatBorder" }, - { "╯", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╰", "FloatBorder" }, - { "│", "FloatBorder" }, - } - local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview - function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...) - opts = opts or {} - opts.border = opts.border or border - return orig_util_open_floating_preview(contents, syntax, opts, ...) - end + -- Floating window borders + local border = { + { '╭', 'FloatBorder' }, + { '─', 'FloatBorder' }, + { '╮', 'FloatBorder' }, + { '│', 'FloatBorder' }, + { '╯', 'FloatBorder' }, + { '─', 'FloatBorder' }, + { '╰', 'FloatBorder' }, + { '│', 'FloatBorder' }, + } + local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview + function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...) + opts = opts or {} + opts.border = opts.border or border + return orig_util_open_floating_preview(contents, syntax, opts, ...) + end end function M.on_attach(client, bufnr) - -- Highlight references - if client.server_capabilities.documentHighlightProvider then - vim.api.nvim_create_augroup("lsp_document_highlight", { - clear = false, - }) - vim.api.nvim_clear_autocmds({ - group = "lsp_document_highlight", - buffer = bufnr, - }) - vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { - group = "lsp_document_highlight", - buffer = bufnr, - callback = vim.lsp.buf.document_highlight, - }) - vim.api.nvim_create_autocmd("CursorMoved", { - group = "lsp_document_highlight", - buffer = bufnr, - callback = vim.lsp.buf.clear_references, - }) - end + -- Highlight references + if client.server_capabilities.documentHighlightProvider then + vim.api.nvim_create_augroup('lsp_document_highlight', { + clear = false, + }) + vim.api.nvim_clear_autocmds { + group = 'lsp_document_highlight', + buffer = bufnr, + } + vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { + group = 'lsp_document_highlight', + buffer = bufnr, + callback = vim.lsp.buf.document_highlight, + }) + vim.api.nvim_create_autocmd('CursorMoved', { + group = 'lsp_document_highlight', + buffer = bufnr, + callback = vim.lsp.buf.clear_references, + }) + end end return M diff --git a/lua/plugins/misc.lua b/lua/plugins/misc.lua index 12966e5..5f8520a 100644 --- a/lua/plugins/misc.lua +++ b/lua/plugins/misc.lua @@ -1,76 +1,86 @@ return { { 'jghauser/mkdir.nvim', lazy = false }, { - "willothy/nvim-cokeline", + 'willothy/nvim-cokeline', dependencies = { - "nvim-lua/plenary.nvim", -- Required for v0.4.0+ - "nvim-tree/nvim-web-devicons", -- If you want devicons + 'nvim-lua/plenary.nvim', -- Required for v0.4.0+ + 'nvim-tree/nvim-web-devicons', -- If you want devicons { - "stevearc/resession.nvim", + 'stevearc/resession.nvim', config = function() - local resession = require("resession") + local resession = require 'resession' resession.setup() -- Resession does NOTHING automagically, so we have to set up some keymaps - vim.keymap.set("n", "ss", resession.save) - vim.keymap.set("n", "sl", resession.load) - vim.keymap.set("n", "sd", resession.delete) - end - } -- Optional, for persistent history + vim.keymap.set('n', 'ss', resession.save) + vim.keymap.set('n', 'sl', resession.load) + vim.keymap.set('n', 'sd', resession.delete) + end, + }, -- Optional, for persistent history }, - event = "VeryLazy", + event = 'VeryLazy', keys = { - { 'gp', "(cokeline-focus-prev)", desc = 'next buffer' }, - { 'gn', "(cokeline-focus-next)", desc = 'next buffer' }, + { 'gp', '(cokeline-focus-prev)', desc = 'next buffer' }, + { 'gn', '(cokeline-focus-next)', desc = 'next buffer' }, }, -- opts = {}, config = function() local get_hex = require('cokeline.hlgroups').get_hl_attr - require('cokeline').setup({ + require('cokeline').setup { default_hl = { fg = function(buffer) - return - buffer.is_focused - and get_hex('Normal', 'fg') - or get_hex('Comment', 'fg') + return buffer.is_focused and get_hex('Normal', 'fg') or + get_hex('Comment', 'fg') end, bg = 'NONE', }, components = { { - text = function(buffer) return (buffer.index ~= 1) and '▏' or '' end, - fg = function() return get_hex('Normal', 'fg') end + text = function(buffer) + return (buffer.index ~= 1) and '▏' or '' + end, + fg = function() + return get_hex('Normal', 'fg') + end, }, { - text = function(buffer) return ' ' .. buffer.devicon.icon end, - fg = function(buffer) return buffer.devicon.color end, + text = function(buffer) + return ' ' .. buffer.devicon.icon + end, + fg = function(buffer) + return buffer.devicon.color + end, }, { - text = function(buffer) return buffer.filename .. ' ' end, - bold = function(buffer) return buffer.is_focused end + text = function(buffer) + return buffer.filename .. ' ' + end, + bold = function(buffer) + return buffer.is_focused + end, }, { text = '󰖭', on_click = function(_, _, _, _, buffer) buffer:delete() - end + end, }, { text = ' ', }, }, - }) - end + } + end, }, { - "willothy/flatten.nvim", + 'willothy/flatten.nvim', opts = function() ---@type Terminal? local saved_terminal return { window = { - open = "alternate", + open = 'alternate', }, callbacks = { should_block = function(argv) @@ -81,13 +91,13 @@ return { -- In this case, we would block if we find the `-b` flag -- This allows you to use `nvim -b file1` instead of -- `nvim --cmd 'let g:flatten_wait=1' file1` - return vim.tbl_contains(argv, "-b") + return vim.tbl_contains(argv, '-b') -- Alternatively, we can block if we find the diff-mode option -- return vim.tbl_contains(argv, "-d") end, pre_open = function() - local term = require("toggleterm.terminal") + local term = require 'toggleterm.terminal' local termid = term.get_focused_id() saved_terminal = term.get(termid) end, @@ -109,8 +119,8 @@ return { -- If the file is a git commit, create one-shot autocmd to delete its buffer on write -- If you just want the toggleable terminal integration, ignore this bit - if ft == "gitcommit" or ft == "gitrebase" then - vim.api.nvim_create_autocmd("BufWritePost", { + if ft == 'gitcommit' or ft == 'gitrebase' then + vim.api.nvim_create_autocmd('BufWritePost', { buffer = bufnr, once = true, callback = vim.schedule_wrap(function() diff --git a/lua/plugins/unused/none-ls.lua.bak b/lua/plugins/none-ls.lua similarity index 100% rename from lua/plugins/unused/none-ls.lua.bak rename to lua/plugins/none-ls.lua diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua index a705a82..62651e0 100644 --- a/lua/plugins/oil.lua +++ b/lua/plugins/oil.lua @@ -6,6 +6,8 @@ return { { '.', 'Oil', desc = 'oil' }, }, opts = { + + delete_to_trash = true, columns = { 'mtime', 'size', @@ -30,10 +32,10 @@ return { keymaps = { ['g?'] = 'actions.show_help', -- [''] = 'actions.select', - [""] = function() - require("oil").select(nil, function(err) + [''] = function() + require('oil').select(nil, function(err) if not err then - local curdir = require("oil").get_current_dir() + local curdir = require('oil').get_current_dir() if curdir then vim.cmd.lcd(curdir) end @@ -49,14 +51,18 @@ return { [''] = 'actions.refresh', ['-'] = 'actions.parent', -- ['l'] = 'actions.parent', - ["l"] = function() - require("oil.actions").parent.callback() - vim.cmd.lcd(require("oil").get_current_dir()) + ['l'] = function() + require('oil.actions').parent.callback() + vim.cmd.lcd(require('oil').get_current_dir()) end, ['_'] = 'actions.open_cwd', ['`'] = 'actions.cd', ['~'] = 'actions.tcd', ['g.'] = 'actions.toggle_hidden', + ['gh'] = function() + require('oil').open '~/' + vim.cmd.lcd(require('oil').get_current_dir()) + end, }, }, } diff --git a/lua/plugins/snippets/init.lua b/lua/plugins/snippets/init.lua index 481767c..acb41a7 100644 --- a/lua/plugins/snippets/init.lua +++ b/lua/plugins/snippets/init.lua @@ -1,53 +1,55 @@ return { - "L3MON4D3/LuaSnip", - keys = { - { - "", - function() - if require("luasnip").jumpable(1) then - require("luasnip").jump(1) - end - end, - mode = { "i", "s" }, - }, - { - "", - function() - if require("luasnip").jumpable(-1) then - require("luasnip").jump(-1) - end - end, - mode = { "i", "s" }, - }, - { - "", - function() - if require("luasnip").choice_active() then - require("luasnip").change_choice(1) - end - end, - mode = { "i", "s" }, - }, - { - "", - function() - if require("luasnip").choice_active() then - require("luasnip").change_choice(-1) - end - end, - mode = { "i", "s" }, - }, - }, - opts = { - history = true, - update_events = { "TextChanged", "TextChangedI" }, - }, - config = function(_, opts) - local ls = require("luasnip") - ls.setup(opts) - -- for _, lang in pairs({ "c", "make", "markdown", "tiger", "sh", "nix" }) do - -- ls.add_snippets(lang, require("plugins.snippets." .. lang)) - -- end - -- ls.add_snippets("cpp", require("plugins.snippets.c")) - end, + 'L3MON4D3/LuaSnip', + dependencies = { 'rafamadriz/friendly-snippets' }, + keys = { + { + '', + function() + if require('luasnip').jumpable(1) then + require('luasnip').jump(1) + end + end, + mode = { 'i', 's' }, + }, + { + '', + function() + if require('luasnip').jumpable(-1) then + require('luasnip').jump(-1) + end + end, + mode = { 'i', 's' }, + }, + { + '', + function() + if require('luasnip').choice_active() then + require('luasnip').change_choice(1) + end + end, + mode = { 'i', 's' }, + }, + { + '', + function() + if require('luasnip').choice_active() then + require('luasnip').change_choice(-1) + end + end, + mode = { 'i', 's' }, + }, + }, + opts = { + history = true, + update_events = { 'TextChanged', 'TextChangedI' }, + }, + config = function(_, opts) + local ls = require 'luasnip' + ls.setup(opts) + require('luasnip.loaders.from_vscode').lazy_load() + -- for _, lang in pairs({ "c", "make", "markdown", "tiger", "sh", "nix" }) do + -- ls.add_snippets(lang, require("plugins.snippets." .. lang)) + -- end + -- ls.add_snippets("cpp", require("plugins.snippets.c")) + end, } diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua index eda0fff..dce9ebc 100644 --- a/lua/plugins/toggleterm.lua +++ b/lua/plugins/toggleterm.lua @@ -2,8 +2,18 @@ return { 'akinsho/toggleterm.nvim', cmd = 'ToggleTerm', keys = { - { "", 'ToggleTerm direction=horizontal', mode = { 'n', 't', 'v', 'i' }, desc = "Toggle Terminal" }, - { "", 'ToggleTerm direction=float', mode = { 'n', 't', 'v', 'i' }, desc = "Toggle Terminal floating" }, + { + '', + 'ToggleTerm direction=horizontal', + mode = { 'n', 't', 'v', 'i' }, + desc = 'Toggle Terminal', + }, + { + '', + 'ToggleTerm direction=float', + mode = { 'n', 't', 'v', 'i' }, + desc = 'Toggle Terminal floating', + }, }, opts = { -- size can be a number or function which is passed the current terminal diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 5d6a411..45bb2d3 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -6,7 +6,7 @@ return { event = 'VeryLazy', keys = { { 'v', desc = 'start incremental selection' }, - { 'h', 'TSBufToggle highlight', desc = 'toggle TS highlight' }, + { 'h', 'TSBufToggle highlight', desc = 'toggle TS highlight' }, }, -- init = function(plugin) -- require('lazy.core.loader').add_to_rtp(plugin) diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua index 5537546..ec7b0e4 100644 --- a/lua/plugins/ui.lua +++ b/lua/plugins/ui.lua @@ -1,6 +1,6 @@ return { { - 'blazkowolf/gruber-darker.nvim', + url = 'https://git.filnar.com/fiplox/gruber-darker.nvim', lazy = false, opts = { -- invert = { @@ -117,36 +117,36 @@ return { end, }, { - "lukas-reineke/indent-blankline.nvim", - event = { "BufReadPost", "BufNewFile" }, - main = "ibl", + 'lukas-reineke/indent-blankline.nvim', + event = { 'BufReadPost', 'BufNewFile' }, + main = 'ibl', config = function() local highlight = { - "RainbowRed", - "RainbowYellow", - "RainbowBlue", - "RainbowOrange", - "RainbowGreen", - "RainbowViolet", - "RainbowCyan", + 'RainbowRed', + 'RainbowYellow', + 'RainbowBlue', + 'RainbowOrange', + 'RainbowGreen', + 'RainbowViolet', + 'RainbowCyan', } - local hooks = require "ibl.hooks" + local hooks = require 'ibl.hooks' -- create the highlight groups in the highlight setup hook, so they are reset -- every time the colorscheme changes hooks.register(hooks.type.HIGHLIGHT_SETUP, function() - vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" }) - vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" }) - vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" }) - vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" }) - vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" }) - vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" }) - vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" }) + vim.api.nvim_set_hl(0, 'RainbowRed', { fg = '#E06C75' }) + vim.api.nvim_set_hl(0, 'RainbowYellow', { fg = '#E5C07B' }) + vim.api.nvim_set_hl(0, 'RainbowBlue', { fg = '#61AFEF' }) + vim.api.nvim_set_hl(0, 'RainbowOrange', { fg = '#D19A66' }) + vim.api.nvim_set_hl(0, 'RainbowGreen', { fg = '#98C379' }) + vim.api.nvim_set_hl(0, 'RainbowViolet', { fg = '#C678DD' }) + vim.api.nvim_set_hl(0, 'RainbowCyan', { fg = '#56B6C2' }) end) vim.g.rainbow_delimiters = { highlight = highlight } - require("ibl").setup { scope = { highlight = highlight, show_start = false, show_end = false } } + require('ibl').setup { scope = { highlight = highlight, show_start = false, show_end = false } } hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark) - end + end, }, } diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua index 9fc4b94..9e54ac6 100644 --- a/lua/plugins/which-key.lua +++ b/lua/plugins/which-key.lua @@ -31,12 +31,12 @@ return { padding = { 1, 1, 1, 1 }, -- extra window padding [top, right, bottom, left] }, layout = { - height = { min = 4, max = 25 }, -- min and max height of the columns - width = { min = 20, max = 50 }, -- min and max width of the columns - spacing = 3, -- spacing between columns + height = { min = 4, max = 25 }, -- min and max height of the columns + width = { min = 20, max = 50 }, -- min and max width of the columns + spacing = 3, -- spacing between columns }, hidden = { '', '', '', '', 'call', 'lua', '^:', '^ ' }, -- hide mapping boilerplate - show_help = true, -- show help message on the command line when the popup is visible + show_help = true, -- show help message on the command line when the popup is visible } local opts = { mode = 'n', -- NORMAL mode