Updates to nvim config
This commit is contained in:
parent
5aeddfdd5d
commit
e67c6beb67
214
init.lua
214
init.lua
|
|
@ -91,7 +91,7 @@ vim.g.mapleader = ' '
|
|||
vim.g.maplocalleader = ' '
|
||||
|
||||
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
||||
vim.g.have_nerd_font = false
|
||||
vim.g.have_nerd_font = true
|
||||
|
||||
-- [[ Setting options ]]
|
||||
-- See `:help vim.opt`
|
||||
|
|
@ -213,6 +213,11 @@ if not vim.loop.fs_stat(lazypath) then
|
|||
end ---@diagnostic disable-next-line: undefined-field
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
local function close_neo_tree()
|
||||
require('neo-tree.sources.manager').close_all()
|
||||
vim.notify 'closed all'
|
||||
end
|
||||
--
|
||||
-- [[ Configure and install plugins ]]
|
||||
--
|
||||
-- To check the current status of your plugins, run
|
||||
|
|
@ -239,6 +244,31 @@ require('lazy').setup({
|
|||
|
||||
-- "gc" to comment visual regions/lines
|
||||
{ 'numToStr/Comment.nvim', opts = {} },
|
||||
--
|
||||
-- Auto-save sessions
|
||||
{
|
||||
'rmagatti/auto-session',
|
||||
lazy = false,
|
||||
opts = {
|
||||
log_level = 'error',
|
||||
auto_session_suppress_dirs = { '~/', '/' },
|
||||
auto_session_enable_last_session = true,
|
||||
auto_session_root_dir = '~/.local/state/nvim/sessions/',
|
||||
bypass_session_save_file_types = { 'neo-tree' },
|
||||
pre_save_cmds = {
|
||||
close_neo_tree,
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{
|
||||
'<leader>as',
|
||||
function()
|
||||
require('auto-session.session-lens').search_session()
|
||||
end,
|
||||
desc = 'Sessions',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Here is a more advanced example where we pass configuration
|
||||
-- options to `gitsigns.nvim`. This is equivalent to the following Lua:
|
||||
|
|
@ -627,7 +657,7 @@ require('lazy').setup({
|
|||
|
||||
{ -- Autoformat
|
||||
'stevearc/conform.nvim',
|
||||
lazy = false,
|
||||
lazy = true,
|
||||
keys = {
|
||||
{
|
||||
'<leader>f',
|
||||
|
|
@ -639,7 +669,7 @@ require('lazy').setup({
|
|||
},
|
||||
},
|
||||
opts = {
|
||||
notify_on_error = false,
|
||||
notify_on_error = true,
|
||||
format_on_save = function(bufnr)
|
||||
-- Disable "format_on_save lsp_fallback" for languages that don't
|
||||
-- have a well standardized coding style. You can add additional
|
||||
|
|
@ -772,7 +802,28 @@ require('lazy').setup({
|
|||
}
|
||||
end,
|
||||
},
|
||||
|
||||
-- {
|
||||
-- 'folke/persistence.nvim',
|
||||
-- event = 'BufReadPre',
|
||||
-- opts = { options = vim.opt.sessionoptions:get() },
|
||||
-- -- stylua: ignore
|
||||
-- keys = {
|
||||
-- { "<leader>qs", function() require('persistence').load()
|
||||
-- end, desc = "Restore Session" },
|
||||
-- { "<leader>ql", function() require('persistence').load { last = true }
|
||||
-- end, desc = "Restore Last Session" },
|
||||
-- { "<leader>qd", function() require('persistence').stop()
|
||||
-- end, desc = "Don't Save Current Session" },
|
||||
-- },
|
||||
-- },
|
||||
{
|
||||
'catppuccin/nvim',
|
||||
name = 'catppuccin',
|
||||
priority = 1000,
|
||||
init = function()
|
||||
vim.cmd.colorscheme 'catppuccin-mocha'
|
||||
end,
|
||||
},
|
||||
{ -- You can easily change to a different colorscheme.
|
||||
-- Change the name of the colorscheme plugin below, and then
|
||||
-- change the command in the config to whatever the name of that colorscheme is.
|
||||
|
|
@ -784,13 +835,148 @@ require('lazy').setup({
|
|||
-- Load the colorscheme here.
|
||||
-- Like many other themes, this one has different styles, and you could load
|
||||
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
|
||||
vim.cmd.colorscheme 'tokyonight-night'
|
||||
-- vim.cmd.colorscheme 'tokyonight-night'
|
||||
|
||||
-- You can configure highlights by doing something like:
|
||||
vim.cmd.hi 'Comment gui=none'
|
||||
end,
|
||||
},
|
||||
{
|
||||
'nvim-neo-tree/neo-tree.nvim',
|
||||
branch = 'v3.x',
|
||||
cmd = 'Neotree',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended
|
||||
'MunifTanjim/nui.nvim',
|
||||
-- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
|
||||
},
|
||||
keys = {
|
||||
{
|
||||
'<C-n>',
|
||||
function()
|
||||
require('neo-tree.command').execute { toggle = true, dir = vim.uv.cwd() }
|
||||
end,
|
||||
desc = 'Explorer NeoTree (cwd)',
|
||||
},
|
||||
-- {
|
||||
-- '<leader>fE',
|
||||
-- function()
|
||||
-- require('neo-tree.command').execute { toggle = true, dir = vim.uv.cwd() }
|
||||
-- end,
|
||||
-- desc = 'Explorer NeoTree (cwd)',
|
||||
-- },
|
||||
-- { '<leader>e', '<leader>fe', desc = 'Explorer NeoTree (cwd)', remap = true },
|
||||
-- { '<leader>E', '<leader>fE', desc = 'Explorer NeoTree (cwd)', remap = true },
|
||||
{
|
||||
'<leader>ge',
|
||||
function()
|
||||
require('neo-tree.command').execute { source = 'git_status', toggle = true }
|
||||
end,
|
||||
desc = 'Git Explorer',
|
||||
},
|
||||
{
|
||||
'<leader>te',
|
||||
function()
|
||||
require('neo-tree.command').execute { source = 'buffers', toggle = true }
|
||||
end,
|
||||
desc = 'Buffer Explorer',
|
||||
},
|
||||
},
|
||||
deactivate = function()
|
||||
vim.cmd [[Neotree close]]
|
||||
end,
|
||||
init = function()
|
||||
-- FIX: use `autocmd` for lazy-loading neo-tree instead of directly requiring it,
|
||||
-- because `cwd` is not set up properly.
|
||||
vim.api.nvim_create_autocmd('BufEnter', {
|
||||
group = vim.api.nvim_create_augroup('Neotree_start_directory', { clear = true }),
|
||||
desc = 'Start Neo-tree with directory',
|
||||
once = true,
|
||||
callback = function()
|
||||
if package.loaded['neo-tree'] then
|
||||
return
|
||||
else
|
||||
local stats = vim.uv.fs_stat(vim.fn.argv(0))
|
||||
if stats and stats.type == 'directory' then
|
||||
require 'neo-tree'
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
opts = {
|
||||
sources = { 'filesystem', 'buffers', 'git_status', 'document_symbols' },
|
||||
open_files_do_not_replace_types = { 'terminal', 'Trouble', 'trouble', 'qf', 'Outline' },
|
||||
filesystem = {
|
||||
bind_to_cwd = false,
|
||||
follow_current_file = { enabled = true },
|
||||
use_libuv_file_watcher = true,
|
||||
filtered_items = {
|
||||
visible = true,
|
||||
hide_dotfiles = false,
|
||||
hide_gitingore = false,
|
||||
},
|
||||
},
|
||||
window = {
|
||||
mappings = {
|
||||
['l'] = 'open',
|
||||
['h'] = 'close_node',
|
||||
['<space>'] = 'none',
|
||||
['Y'] = {
|
||||
function(state)
|
||||
local node = state.tree:get_node()
|
||||
local path = node:get_id()
|
||||
vim.fn.setreg('+', path, 'c')
|
||||
end,
|
||||
desc = 'Copy Path to Clipboard',
|
||||
},
|
||||
['O'] = {
|
||||
function(state)
|
||||
require('lazy.util').open(state.tree:get_node().path, { system = true })
|
||||
end,
|
||||
desc = 'Open with System Application',
|
||||
},
|
||||
['P'] = { 'toggle_preview', config = { use_float = false } },
|
||||
},
|
||||
},
|
||||
default_component_configs = {
|
||||
indent = {
|
||||
with_expanders = true, -- if nil and file nesting is enabled, will enable expanders
|
||||
expander_collapsed = '',
|
||||
expander_expanded = '',
|
||||
expander_highlight = 'NeoTreeExpander',
|
||||
},
|
||||
git_status = {
|
||||
symbols = {
|
||||
unstaged = '',
|
||||
staged = '',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
local function on_move(data)
|
||||
LazyVim.lsp.on_rename(data.source, data.destination)
|
||||
end
|
||||
|
||||
local events = require 'neo-tree.events'
|
||||
opts.event_handlers = opts.event_handlers or {}
|
||||
vim.list_extend(opts.event_handlers, {
|
||||
{ event = events.FILE_MOVED, handler = on_move },
|
||||
{ event = events.FILE_RENAMED, handler = on_move },
|
||||
})
|
||||
require('neo-tree').setup(opts)
|
||||
vim.api.nvim_create_autocmd('TermClose', {
|
||||
pattern = '*lazygit',
|
||||
callback = function()
|
||||
if package.loaded['neo-tree.sources.git_status'] then
|
||||
require('neo-tree.sources.git_status').refresh()
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
-- Highlight todo, notes, etc in comments
|
||||
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
|
||||
|
||||
|
|
@ -803,7 +989,14 @@ require('lazy').setup({
|
|||
-- - va) - [V]isually select [A]round [)]paren
|
||||
-- - yinq - [Y]ank [I]nside [N]ext [']quote
|
||||
-- - ci' - [C]hange [I]nside [']quote
|
||||
require('mini.ai').setup { n_lines = 500 }
|
||||
local ai = require 'mini.ai'
|
||||
ai.setup {
|
||||
n_lines = 500,
|
||||
-- custom_textobjects = {
|
||||
-- B = MiniExtra.gen_ai_spec.buffer(),
|
||||
-- F = ai.gen_spec.treesitter { a = '@function.outer', i = '@function.inner' },
|
||||
-- },
|
||||
}
|
||||
|
||||
-- Add/delete/replace surroundings (brackets, quotes, etc.)
|
||||
--
|
||||
|
|
@ -873,12 +1066,13 @@ require('lazy').setup({
|
|||
-- Here are some example plugins that I've included in the Kickstart repository.
|
||||
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
|
||||
--
|
||||
-- require 'kickstart.plugins.debug',
|
||||
-- require 'kickstart.plugins.indent_line',
|
||||
require 'kickstart.plugins.lazygit',
|
||||
require 'kickstart.plugins.debug',
|
||||
require 'kickstart.plugins.indent_line',
|
||||
-- require 'kickstart.plugins.lint',
|
||||
-- require 'kickstart.plugins.autopairs',
|
||||
require 'kickstart.plugins.autopairs',
|
||||
-- require 'kickstart.plugins.neo-tree',
|
||||
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
|
||||
require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
|
||||
|
||||
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
|
||||
-- This is the easiest way to modularize your config.
|
||||
|
|
|
|||
|
|
@ -2,4 +2,5 @@
|
|||
-- I promise not to create any merge conflicts in this directory :)
|
||||
--
|
||||
-- See the kickstart.nvim README for more information
|
||||
return {}
|
||||
return {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ return {
|
|||
'jay-babu/mason-nvim-dap.nvim',
|
||||
|
||||
-- Add your own debuggers here
|
||||
'leoluz/nvim-dap-go',
|
||||
-- 'leoluz/nvim-dap-go',
|
||||
},
|
||||
config = function()
|
||||
local dap = require 'dap'
|
||||
|
|
@ -85,12 +85,12 @@ return {
|
|||
dap.listeners.before.event_exited['dapui_config'] = dapui.close
|
||||
|
||||
-- Install golang specific config
|
||||
require('dap-go').setup {
|
||||
delve = {
|
||||
-- On Windows delve must be run attached or it crashes.
|
||||
-- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring
|
||||
detached = vim.fn.has 'win32' == 0,
|
||||
},
|
||||
}
|
||||
-- require('dap-go').setup {
|
||||
-- delve = {
|
||||
-- -- On Windows delve must be run attached or it crashes.
|
||||
-- -- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring
|
||||
-- detached = vim.fn.has 'win32' == 0,
|
||||
-- },
|
||||
-- }
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
return {
|
||||
'kdheepak/lazygit.nvim',
|
||||
cmd = {
|
||||
'LazyGit',
|
||||
'LazyGitConfig',
|
||||
'LazyGitCurrentFile',
|
||||
'LazyGitFilter',
|
||||
'LazyGitFilterCurrentFile',
|
||||
},
|
||||
-- optional for floating window border decoration
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
},
|
||||
-- setting the keybinding for LazyGit with 'keys' is recommended in
|
||||
-- order to load the plugin when the command is run for the first time
|
||||
keys = {
|
||||
{ '<leader>lg', '<cmd>LazyGit<cr>', desc = 'Open lazy git' },
|
||||
},
|
||||
}
|
||||
Loading…
Reference in New Issue