diff --git a/after/plugin/keybinds.lua b/after/plugin/keybinds.lua index 9b2771c1..4dc219c2 100644 --- a/after/plugin/keybinds.lua +++ b/after/plugin/keybinds.lua @@ -1,14 +1,48 @@ +local map = vim.keymap.set + +-- The good 'ol keybinds +map('n', '', 'w', { noremap = true, silent = true, desc = 'File save' }) +map('n', '', '%y+', { desc = 'File copy whole' }) + -- Move between windows with arrows -vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +map('n', '', '', { desc = 'Move focus to the left window' }) +map('n', '', '', { desc = 'Move focus to the right window' }) +map('n', '', '', { desc = 'Move focus to the lower window' }) +map('n', '', '', { desc = 'Move focus to the upper window' }) + +-- Double Q to close current window +--map('n', 'qq', 'q', { silent = true, desc = 'CLose window' }) +-- vim.api.nvim_create_autocmd('FileType', { +-- pattern = 'TelescopePrompt', +-- callback = function(params) +-- vim.keymap.set('', 'qq', '', { noremap = true, buffer = params.buf }) +-- end, +-- }) -- Keep cursor centered when PgUp & PgDown -vim.keymap.set({ 'n', 'i', 'v' }, '', 'zz', { desc = 'Page up' }) -vim.keymap.set({ 'n', 'i', 'v' }, '', 'zz', { desc = 'Page down' }) +map({ 'n', 'i', 'v' }, '', 'normal zz', { desc = 'Page up' }) +map({ 'n', 'i', 'v' }, '', 'normal zz', { desc = 'Page down' }) -- Redirect command output and allow edit -vim.keymap.set('c', '', function() +map('c', '', function() require('noice').redirect(vim.fn.getcmdline()) end, { desc = 'Redirect Cmdline' }) + +-- LSP specific mappings +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), + callback = function(event) + local map = function(keys, fn, desc) + vim.keymap.set('n', keys, fn, { buffer = event.buf, desc = 'LSP: ' .. desc }) + end + + local builtin = require 'telescope.builtin' + map('gd', builtin.lsp_definitions, '[G]oto [D]efinition') + map('gr', builtin.lsp_references, '[G]oto [R]eferences') + map('gi', builtin.lsp_implementations, '[G]oto [I]mplementation') + map('gt', builtin.lsp_type_definitions, '[G]oto [T]ype Definition') + map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclarations') + map('gic', builtin.lsp_incoming_calls, '[G]oto [I]ncoming [C]alls') + map('goc', builtin.lsp_outgoing_calls, '[G]oto [O]utgoing [C]alls') + end, +}) diff --git a/fancywrapper.ts b/fancywrapper.ts new file mode 100644 index 00000000..cc3e560b --- /dev/null +++ b/fancywrapper.ts @@ -0,0 +1 @@ +function FancyWrapper(ptr: NativePointer); diff --git a/init.lua b/init.lua index f6ba04c3..1bd9f304 100644 --- a/init.lua +++ b/init.lua @@ -81,7 +81,7 @@ vim.opt.smartcase = true vim.opt.signcolumn = 'yes' -- Decrease update time -vim.opt.updatetime = 125 +vim.opt.updatetime = 250 -- Decrease mapped sequence wait time -- Displays which-key popup sooner @@ -113,11 +113,14 @@ vim.opt.scrolloff = 10 vim.opt.hlsearch = true vim.keymap.set('n', '', 'nohlsearch') --- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) +-- Add padding to Neovide only +if vim.g.neovide then + vim.g.neovide_padding_top = 4 + vim.g.neovide_padding_bottom = 6 + vim.g.neovide_padding_right = 12 + vim.g.neovide_padding_left = 12 +end + -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier -- for people to discover. Otherwise, you normally need to press , which -- is not what someone will guess without a bit more experience. @@ -191,7 +194,7 @@ local opts = { }, } -require 'autocommand' +require 'commands' require 'fancyutil' require('lazy').setup('plugins', opts) -- The line beneath this is called `modeline`. See `:help modeline` diff --git a/lua/autocommand.lua b/lua/commands.lua similarity index 100% rename from lua/autocommand.lua rename to lua/commands.lua diff --git a/lua/fancyutil.lua b/lua/fancyutil.lua index e94de0ca..deb62564 100644 --- a/lua/fancyutil.lua +++ b/lua/fancyutil.lua @@ -1,11 +1,11 @@ -- init module local _M = {} ---- @param bufnr integer | nil +--- @param winnr integer | nil --- @return true | false | nil -function _M.get_oil_nnn(bufnr) - bufnr = bufnr or 0 - local ok, value = pcall(vim.api.nvim_buf_get_var, bufnr, 'nnn') +function _M.get_oil_nnn(winnr) + winnr = winnr or 0 + local ok, value = pcall(vim.api.nvim_win_get_var, winnr, 'nnn') if not ok then return nil end @@ -14,6 +14,12 @@ function _M.get_oil_nnn(bufnr) end return false end -vim.fn.get_oil_nnn = _M.get_oil_nnn + +--- @param val boolean +--- @param winnr integer | nil +function _M.set_oil_nnn(val, winnr) + winnr = winnr or 0 + vim.api.nvim_win_set_var(winnr, 'nnn', val) +end return _M diff --git a/lua/kickstart/plugins/autopairs.lua b/lua/kickstart/plugins/autopairs.lua index 87a7e5ff..7763188c 100644 --- a/lua/kickstart/plugins/autopairs.lua +++ b/lua/kickstart/plugins/autopairs.lua @@ -1,16 +1,15 @@ --- autopairs --- https://github.com/windwp/nvim-autopairs - return { - 'windwp/nvim-autopairs', - event = 'InsertEnter', - -- Optional dependency - dependencies = { 'hrsh7th/nvim-cmp' }, - config = function() - require('nvim-autopairs').setup {} - -- If you want to automatically add `(` after selecting a function or method - local cmp_autopairs = require 'nvim-autopairs.completion.cmp' - local cmp = require 'cmp' - cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) - end, + { + 'windwp/nvim-autopairs', + event = 'InsertEnter', + -- Optional dependency + dependencies = { 'hrsh7th/nvim-cmp' }, + config = function() + require('nvim-autopairs').setup {} + -- If you want to automatically add `(` after selecting a function or method + local cmp_autopairs = require 'nvim-autopairs.completion.cmp' + local cmp = require 'cmp' + cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) + end, + }, } diff --git a/lua/plugins/autopair.lua b/lua/plugins/autopair.lua index 253d3b0b..2afb7933 100644 --- a/lua/plugins/autopair.lua +++ b/lua/plugins/autopair.lua @@ -1,9 +1,19 @@ return { { 'windwp/nvim-autopairs', + event = 'InsertEnter', dependencies = { 'hrsh7th/nvim-cmp' }, + opts = { + check_ts = true, + + ts_config = { + lua = { 'string' }, -- it will not add a pair on that treesitter node + javascript = { 'template_string' }, + java = false, -- don't check treesitter on java + }, + enable_check_bracket_line = true, + }, config = function() - require('nvim-autopairs').setup {} local cmp_autopairs = require 'nvim-autopairs.completion.cmp' local cmp = require 'cmp' cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua index c583316a..cc9a086f 100644 --- a/lua/plugins/conform.lua +++ b/lua/plugins/conform.lua @@ -5,7 +5,7 @@ return { cmd = { 'ConformInfo' }, keys = { { - 'f', + '', function() require('conform').format { async = true, lsp_fallback = true } end, @@ -25,7 +25,7 @@ return { --[[ c = true, cpp = true ]] } return { - timeout_ms = 500, + timeout_ms = 3000, lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], } end, diff --git a/lua/plugins/cutlass.lua b/lua/plugins/cutlass.lua new file mode 100644 index 00000000..d480e11b --- /dev/null +++ b/lua/plugins/cutlass.lua @@ -0,0 +1,8 @@ +return { + { + 'gbprod/cutlass.nvim', + opts = { + cut_key = 'm', + }, + }, +} diff --git a/lua/plugins/highlight-action.lua b/lua/plugins/highlight-action.lua index 4fa0b62a..384357e2 100644 --- a/lua/plugins/highlight-action.lua +++ b/lua/plugins/highlight-action.lua @@ -1,36 +1,37 @@ -return { - { - 'tzachar/highlight-undo.nvim', - config = function() - vim.api.nvim_create_autocmd('TextYankPost', { - desc = 'Highlight when yanking (copying) text', - group = vim.api.nvim_create_augroup('highlight-yank', { clear = true }), - callback = function() - vim.highlight.on_yank { timeout = 200 } - end, - }) - - vim.api.nvim_set_hl(0, 'highlight-action', { - fg = '#dcd7ba', - bg = '#2d4f67', - default = true, - }) - - require('highlight-undo').setup { - duration = 200, - undo = { - lhs = 'u', - hlgroup = 'DiffAdd', - map = 'undo', - opts = {}, - }, - redo = { - lhs = '', - hlgroup = 'DiffAdd', - map = 'redo', - opts = {}, - }, - } - end, - }, -} +-- return { +-- { +-- 'tzachar/highlight-undo.nvim', +-- config = function() +-- vim.api.nvim_create_autocmd('TextYankPost', { +-- desc = 'Highlight when yanking (copying) text', +-- group = vim.api.nvim_create_augroup('highlight-yank', { clear = true }), +-- callback = function() +-- vim.highlight.on_yank { timeout = 200 } +-- end, +-- }) +-- +-- vim.api.nvim_set_hl(0, 'highlight-action', { +-- fg = '#dcd7ba', +-- bg = '#2d4f67', +-- default = true, +-- }) +-- +-- require('highlight-undo').setup { +-- duration = 200, +-- undo = { +-- lhs = 'u', +-- hlgroup = 'DiffAdd', +-- map = 'undo', +-- opts = {}, +-- }, +-- redo = { +-- lhs = '', +-- hlgroup = 'DiffAdd', +-- map = 'redo', +-- opts = {}, +-- }, +-- } +-- end, +-- }, +-- } +return {} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 1eaaffa5..aba4fa3c 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -26,17 +26,55 @@ return { which_key = true, }, }, + config = function(_, opts) + require('catppuccin').setup(opts) + local theme = require 'catppuccin.palettes.mocha' + local highlight = { + RainbowRed = theme.red, + RainbowYellow = theme.yellow, + RainbowBlue = theme.blue, + RainbowOrange = theme.peach, + RainbowGreen = theme.green, + RainbowViolet = theme.maroon, + RainbowCyan = theme.teal, + } + vim.g.rainbow_delimiters = { highlight = highlight } + end, }, { 'tpope/vim-sleuth' }, { 'lukas-reineke/indent-blankline.nvim', + dependencies = { 'catppuccin/nvim' }, main = 'ibl', opts = { + indent = vim.g.rainbow_delimiters, exclude = { filetypes = { 'dashboard', }, }, }, + config = function(_, opts) + local hooks = require 'ibl.hooks' + hooks.register(hooks.type.HIGHLIGHT_SETUP, function() + for name, value in pairs(vim.g.rainbow_delimiters) do + vim.api.nvim_set_hl(0, name, { fg = value }) + end + end) + + opts.scope = { + highlight = { + 'RainbowDelimiterRed', + 'RainbowDelimiterYellow', + 'RainbowDelimiterBlue', + 'RainbowDelimiterOrange', + 'RainbowDelimiterGreen', + 'RainbowDelimiterViolet', + 'RainbowDelimiterCyan', + }, + } + -- require('ibl').setup(opts) + hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark) + end, }, } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 00312122..b3386e4b 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -6,11 +6,11 @@ return { 'williamboman/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', 'folke/lazydev.nvim', + 'b0o/schemastore.nvim', { 'j-hui/fidget.nvim' }, }, config = function() require('lazydev').setup {} - require('neoconf').setup {} vim.diagnostic.config { update_in_insert = true, float = { @@ -21,6 +21,11 @@ return { virtual_text = false, } + vim.fn.sign_define('DiagnosticSignError', { text = '', texthl = 'DiagnosticSignError' }) + vim.fn.sign_define('DiagnosticSignWarn', { text = '', texthl = 'DiagnosticSignWarn' }) + vim.fn.sign_define('DiagnosticSignInfo', { text = '', texthl = 'DiagnosticSignInfo' }) + vim.fn.sign_define('DiagnosticSignHint', { text = '', texthl = 'DiagnosticSignHint' }) + -- function will be executed to configure the current buffer vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), @@ -48,6 +53,7 @@ return { local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) capabilities.textDocument.completion.completionItem.snippetSupport = true + capabilities.textDocument.callHierarchy.dynamicRegistration = true local lazyPlugins = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' local servers = { @@ -74,9 +80,39 @@ return { }, }, }, - jsonls = {}, - yamlls = {}, + jsonls = { + settings = { + json = { + schemas = require('schemastore').json.schemas(), + validate = { + enable = true, + }, + }, + }, + }, + yamlls = { + settings = { + yaml = { + schemas = require('schemastore').yaml.schemas(), + }, + schemaStore = { + enable = true, + }, + }, + }, eslint_d = {}, + pylsp = { + settings = { + pylsp = { + plugins = { + pycodestyle = { + ignore = { 'W391' }, + maxLineLength = 120, + }, + }, + }, + }, + }, } -- You can press `g?` for help in this menu. diff --git a/lua/plugins/lspsaga.lua b/lua/plugins/lspsaga.lua new file mode 100644 index 00000000..6b65605f --- /dev/null +++ b/lua/plugins/lspsaga.lua @@ -0,0 +1,5 @@ +return { + { + 'nvimdev/lspsaga.nvim', + }, +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index e0219641..668017e2 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -1,3 +1,28 @@ +local function get_oil_extension() + local oil_ext = vim.deepcopy(require 'lualine.extensions.oil') + oil_ext.sections.lualine_z = { + { + 'mode', + separator = { left = '', right = '' }, + fmt = function(mode, context) + local winnr = vim.fn.tabpagewinnr(context.tabnr) + local val = require('fancyutil').get_oil_nnn(winnr) + if val then + return 'nnn' + end + return mode + end, + color = function() + local val = require('fancyutil').get_oil_nnn() + if val then + return { fg = '#054fca', bg = '#ff98dd' } + end + end, + }, + } + return oil_ext +end + return { { 'nvim-lualine/lualine.nvim', @@ -18,32 +43,41 @@ return { component_separators = '', section_separators = { left = '', right = '' }, }, + tabline = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { + '%=', + { + 'filename', + file_status = true, + path = 3, + symbols = { + modified = '', -- Text to show when the file is modified. + readonly = '󰌾', -- Text to show when the file is non-modifiable or readonly. + unnamed = '[No Name]', -- Text to show for unnamed buffers. + newfile = '[New]', -- Text to show for newly created file before first write + }, + }, + }, + lualine_x = { + { 'filetype' }, + { 'fileformat' }, + }, + lualine_y = {}, + lualine_z = {}, + }, sections = { lualine_a = { { 'mode', - separator = { left = '' }, - fmt = function(_, _) - -- local winnr = vim.fn.tab (context.tabnr) - -- vim.fn.winbufnr(winnr) - local val = require('fancyutil').get_oil_nnn() - if val then - return 'nnn' - end - end, - color = function(_) - local val = require('fancyutil').get_oil_nnn() - if val == true then - return { fg = '#054fca' } - end - return {} - end, + separator = { left = '', right = '' }, }, }, lualine_x = { { 'lsp_progress', - display_components = { 'lsp_client_name', { 'title', 'percentage', 'message' } }, + display_components = { 'lsp_client_name', 'spinner', { 'title', 'percentage', 'message' } }, colors = { percentage = colors.gray, title = colors.gray, @@ -52,35 +86,25 @@ return { lsp_client_name = colors.purple, use = true, }, + timer = { + progress_enddelay = 1500, + spinner = 1500, + lsp_client_enddelay = 2500, + }, }, }, lualine_z = { { 'location', - separator = { right = '' }, - left_padding = 2, + separator = { left = '', right = '' }, }, }, }, extensions = { - 'oil', + get_oil_extension(), 'lazy', }, } - - -- vim.api.nvim_create_autocmd({ 'BufEnter' }, { - -- callback = function(ev) - -- local filetype = vim.api.nvim_get_option_value('filetype', { buf = ev.buf }) - -- - -- print(string.format('event fired: %s', filetype)) - -- if filetype == 'oil' then - -- local ok, value = pcall(vim.api.nvim_buf_get_var, ev.buf, 'nnn') - -- if not ok then - -- vim.api.nvim_buf_set_var(ev.buf, 'nnn', true) - -- end - -- end - -- end, - -- }) end, }, } diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua index 5cb29a63..9a8bdc3b 100644 --- a/lua/plugins/mini.lua +++ b/lua/plugins/mini.lua @@ -30,6 +30,20 @@ return { return MiniHipatterns.compute_hex_color_group(correct, 'bg') end, }, + rgb = { + pattern = '()Rgb%(%s*%d+,%s*%d+,%s*%d+%s*%)()', + group = function(_, _, data) + local _, _, r, g, b = data.full_match:find 'Rgb%(%s*(%d+),%s*(%d+),%s*(%d+)%s*%)' + local correct = string.format('#%02x%02x%02x', r, g, b) + if correct:len() ~= 7 then + return + end + return MiniHipatterns.compute_hex_color_group(correct, 'bg') + end, + extmark_opts = { + priority = 210, + }, + }, }, } diff --git a/lua/plugins/neoconf.lua b/lua/plugins/neoconf.lua deleted file mode 100644 index 56b64169..00000000 --- a/lua/plugins/neoconf.lua +++ /dev/null @@ -1,6 +0,0 @@ -return { - { - 'folke/neoconf.nvim', - opts = {}, - }, -} diff --git a/lua/plugins/nvim-treesitter.lua b/lua/plugins/nvim-treesitter.lua index 3072f641..9241ce51 100644 --- a/lua/plugins/nvim-treesitter.lua +++ b/lua/plugins/nvim-treesitter.lua @@ -3,7 +3,6 @@ return { 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', opts = { - ensure_installed = { 'bash', 'c', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' }, auto_install = true, highlight = { diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua index 337e19cf..d155a44c 100644 --- a/lua/plugins/oil.lua +++ b/lua/plugins/oil.lua @@ -3,77 +3,33 @@ return { dependencies = { 'nvim-tree/nvim-web-devicons' }, event = 'VimEnter', keys = { - { - 'qq', - function() - require('oil').close() - end, - mode = '', - desc = 'Close current window', - }, - { - 'tn', - function() - local val = require('fancyutil').get_oil_nnn() - if val == true then - vim.api.nvim_buf_set_var(bufnr, 'nnn', false) - elseif val == false then - vim.api.nvim_buf_set_var(bufnr, 'nnn', true) - end - end, - mode = '', - desc = '[T]oggle [n]nn Mode', - }, { '~', 'Oil', mode = '', desc = 'Open parent directory', }, - { - '', - function() - if require('oil.util').is_oil_bufnr(0) and require('fancyutil').get_oil_nnn() then - local oil = require 'oil' - local bufname = vim.api.nvim_buf_get_name(0) - local parent = oil.get_buffer_parent_url(bufname, true) - return oil.open(parent) - end - -- fallback to sending page up key - local keys = vim.api.nvim_replace_termcodes('', true, false, true) - vim.api.nvim_feedkeys(keys, 'n', false) - end, - mode = '', - desc = 'Move up the file tree', - }, - { - '', - function() - local oil = require 'oil' - local entry = oil.get_cursor_entry() - local dir = oil.get_current_dir() - if entry and dir and require('fancyutil').get_oil_nnn() then - local path = dir .. entry.name - local stat = vim.loop.fs_stat(path) - if stat and stat.type == 'directory' then - return oil.open(path) - end - end - -- fallback to sending arrow key - local keys = vim.api.nvim_replace_termcodes('', true, false, true) - vim.api.nvim_feedkeys(keys, 'n', false) - end, - mode = '', - desc = 'Move down the file tree', - }, }, opts = { default_file_explorer = true, restore_window_options = true, + keymaps = { + ['gd'] = { + desc = 'Toggle file detail view', + callback = function() + vim.g.detail = not vim.g.detail + if vim.g.detail then + require('oil').set_columns { 'icon', 'permissions', 'size', 'mtime' } + else + require('oil').set_columns { 'icon' } + end + end, + }, + }, win_options = { wrap = true, - signcolumn = 'yes', + -- signcolumn = '', cursorcolumn = false, foldcolumn = '0', spell = false, @@ -88,29 +44,57 @@ return { return name:match '.git' end, }, - -- group = aug, - extensions = { - 'oil', - }, }, - config = function(_, opts) - local oil = require 'oil' - oil.setup(opts) - end, init = function() - vim.api.nvim_create_autocmd('BufEnter', { - desc = 'Detect buffer and setup oil nnn flag', - -- group = aug, - pattern = '*', - nested = true, + vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWinEnter' }, { + pattern = 'oil://*', callback = function(params) local bufnr = params.buf - local _, filetype = pcall(vim.api.nvim_get_option_value, 'filetype', { buf = bufnr }) - if filetype == 'oil' then - local val = require('fancyutil').get_oil_nnn(bufnr) - if val == nil then - vim.api.nvim_buf_set_var(bufnr, 'nnn', true) - end + if params.event == 'BufEnter' then + -- double Q to close window + vim.keymap.set('', 'qq', require('oil').close, { buffer = bufnr, desc = 'Close current window' }) + + -- toggle detailed list mode + vim.keymap.set('', 'tnnn', function() + local fu = require 'fancyutil' + local winnr = 0 + local val = fu.get_oil_nnn(winnr) + fu.set_oil_nnn(val ~= true, winnr) + end, { buffer = bufnr, desc = '[T]oggle [nnn] Mode' }) + + --- nnn move up file tree + vim.keymap.set('', '', function() + if require('oil.util').is_oil_bufnr(bufnr) and require('fancyutil').get_oil_nnn() then + local oil = require 'oil' + local bufname = vim.api.nvim_buf_get_name(bufnr) + local parent = oil.get_buffer_parent_url(bufname, true) + return oil.open(parent) + end + local keys = vim.api.nvim_replace_termcodes('', true, false, true) + vim.api.nvim_feedkeys(keys, 'n', false) -- send consumed keys + end, { buffer = bufnr, desc = 'Move up the file tree' }) + + -- nnn move down file tree + vim.keymap.set('', '', function() + local oil = require 'oil' + local entry = oil.get_cursor_entry() + local dir = oil.get_current_dir() + if entry and dir and require('fancyutil').get_oil_nnn(0) then + local path = dir .. entry.name + local stat = vim.loop.fs_stat(path) + if stat and stat.type == 'directory' then + return oil.open(path) + end + end + local keys = vim.api.nvim_replace_termcodes('', true, false, true) + vim.api.nvim_feedkeys(keys, 'n', false) -- send consumed keys + end, { buffer = bufnr, desc = 'Move down the file tree' }) + return + end + local winnr = vim.fn.bufwinid(bufnr) + local val = require('fancyutil').get_oil_nnn(winnr) + if val == nil then + require('fancyutil').set_oil_nnn(true, winnr) end end, }) diff --git a/lua/plugins/rainbow.lua b/lua/plugins/rainbow.lua new file mode 100644 index 00000000..16fd25ee --- /dev/null +++ b/lua/plugins/rainbow.lua @@ -0,0 +1,8 @@ +return { + { + 'HiPhish/rainbow-delimiters.nvim', + config = function(_, opts) + require('rainbow-delimiters.setup').setup {} + end, + }, +} diff --git a/lua/plugins/repeat.lua b/lua/plugins/repeat.lua new file mode 100644 index 00000000..25dffacc --- /dev/null +++ b/lua/plugins/repeat.lua @@ -0,0 +1,6 @@ +return { + { + 'tpope/vim-repeat', + event = 'VeryLazy', + }, +} diff --git a/lua/plugins/tabline.lua b/lua/plugins/tabline.lua index 5e2e49d2..f1138648 100644 --- a/lua/plugins/tabline.lua +++ b/lua/plugins/tabline.lua @@ -6,7 +6,7 @@ return { { 'nvim-tree/nvim-web-devicons' }, }, opts = { - enable = true, + enable = false, options = { -- If lualine is installed tabline will use separators configured in lualine by default. -- These options can be used to override those settings. @@ -16,13 +16,16 @@ return { show_tabs_always = true, -- this shows tabs only when there are more than one tab or if the first tab is named show_devicons = true, -- this shows devicons in buffer section colored = true, - show_bufnr = true, -- this appends [bufnr] to buffer section, + show_bufnr = false, -- this appends [bufnr] to buffer section, tabline_show_last_separator = true, show_filename_only = true, -- shows base filename only instead of relative path in filename - modified_icon = 'single', -- change the default modified icon + modified_icon = '*', -- change the default modified icon modified_italic = true, -- set to true by default; this determines whether the filename turns italic if modified show_tabs_only = false, -- this shows only tabs instead of tabs + buffers }, + extensions = { + 'lazy', + }, }, config = function(_, opts) require('tabline').setup(opts) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 0b40d2bf..54f3a759 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -2,18 +2,11 @@ return { { 'nvim-telescope/telescope.nvim', event = 'VimEnter', - branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim', - { -- If encountering errors, see telescope-fzf-native README for installation instructions + { 'nvim-telescope/telescope-fzf-native.nvim', - - -- `build` is used to run some command when the plugin is installed/updated. - -- This is only run then, not every time Neovim starts up. build = 'make', - - -- `cond` is a condition used to determine whether this plugin should be - -- installed and loaded. cond = function() return vim.fn.executable 'make' == 1 end, @@ -45,18 +38,21 @@ return { -- [[ Configure Telescope ]] -- See `:help telescope` and `:help telescope.setup()` require('telescope').setup { - -- You can put your default mappings / updates / etc. in here - -- All the info you're looking for is in `:help telescope.setup()` - -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, - -- pickers = {} + defaults = { + mappings = { + i = { + [''] = 'to_fuzzy_refine', + }, + n = { + ['qq'] = 'close', + }, + }, + dynamic_preview_title = true, + }, + pickers = {}, extensions = { ['ui-select'] = { - require('telescope.themes').get_dropdown(), + require('telescope.themes').get_ivy(), }, }, } @@ -66,9 +62,12 @@ return { pcall(require('telescope').load_extension, 'ui-select') pcall(require('telescope').load_extension, 'noice') pcall(require('telescope').load_extension, 'undo') + pcall(require('telescope').load_extension, 'yank_history') -- See `:help telescope.builtin` local builtin = require 'telescope.builtin' + local extensions = require('telescope').extensions + vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) vim.keymap.set('n', 'fh', builtin.help_tags, { desc = '[F]ind [H]elp' }) vim.keymap.set('n', 'fk', builtin.keymaps, { desc = '[F]ind [K]eymaps' }) vim.keymap.set('n', 'ff', builtin.find_files, { desc = '[F]ind [F]iles' }) @@ -77,13 +76,13 @@ return { vim.keymap.set('n', 'fg', builtin.live_grep, { desc = '[F]ind by [G]rep' }) vim.keymap.set('n', 'fd', builtin.diagnostics, { desc = '[F]ind [D]iagnostics' }) vim.keymap.set('n', 'fr', builtin.resume, { desc = '[F]ind [R]esume' }) - vim.keymap.set('n', 'f.', builtin.oldfiles, { desc = '[F]ind Recent Files ("." for repeat)' }) - vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', 'f.', builtin.oldfiles, { desc = '[F]ind Recent Files [.]' }) + vim.keymap.set('n', 'fy', extensions.yank_history.yank_history, { desc = '[F]ind [Y]ank History' }) -- Slightly advanced example of overriding default behavior and theme vim.keymap.set('n', '/', function() -- You can pass additional configuration to Telescope to change the theme, layout, etc. - builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_ivy { winblend = 10, previewer = false, }) diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua new file mode 100644 index 00000000..51745bb5 --- /dev/null +++ b/lua/plugins/toggleterm.lua @@ -0,0 +1,20 @@ +return { + { + 'akinsho/toggleterm.nvim', + version = '*', + opts = { + size = 24, + open_mapping = [[]], + }, + init = function() + vim.api.nvim_create_autocmd('BufWinEnter', { + desc = 'Detect buffer and setup oil nnn flag', + pattern = 'term://*', + callback = function(params) + local winnr = vim.fn.bufwinid(params.buf) + vim.api.nvim_set_option_value('cursorline', false, { win = winnr }) + end, + }) + end, + }, +} diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua index ff48e2e9..d0888307 100644 --- a/lua/plugins/trouble.lua +++ b/lua/plugins/trouble.lua @@ -3,17 +3,13 @@ return { 'folke/trouble.nvim', opts = { modes = { - preview_float = { + test = { mode = 'diagnostics', preview = { - type = 'float', - relative = 'editor', - border = 'rounded', - title = 'Preview', - title_pos = 'center', - position = { 0, -2 }, - size = { width = 0.3, height = 0.3 }, - zindex = 200, + relative = 'win', + type = 'split', + position = 'right', + size = 0.3, }, }, }, diff --git a/lua/plugins/yanky.lua b/lua/plugins/yanky.lua index 2f8da55c..39bd3772 100644 --- a/lua/plugins/yanky.lua +++ b/lua/plugins/yanky.lua @@ -2,7 +2,7 @@ return { { 'gbprod/yanky.nvim', opts = { - ystem_clipboard = { + system_clipboard = { sync_with_ring = true, clipboard_register = nil, }, @@ -11,6 +11,9 @@ return { on_yank = true, timer = 500, }, + preserve_cursor_position = { + enabled = true, + }, }, }, } diff --git a/mocha.ron b/mocha.ron index 7a4be738..9818424e 100644 --- a/mocha.ron +++ b/mocha.ron @@ -17,7 +17,7 @@ commit_author: Some(Rgb(116, 199, 236)), danger_fg: Some(Rgb(243, 139, 168)), push_gauge_bg: Some(Rgb(137, 180, 250)), - push_gauge_fg: some(Rgb(30, 30, 46)), + push_gauge_fg: Some(Rgb(30, 30, 46)), tag_fg: Some(Rgb(245, 224, 220)), branch_fg: Some(Rgb(148, 226, 213)) ) diff --git a/neoconf.json b/neoconf.json deleted file mode 100644 index 0690d1ad..00000000 --- a/neoconf.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "neodev": { - "library": { - "enabled": true, - "plugins": ["neoconf.nvim", "nvim-lspconfig"] - } - }, - "neoconf": { - "plugins": { - "lua_ls": { - "enabled": true - } - } - }, - "lspconfig": { - "sumneko_lua": {} - } -}