diff --git a/init.lua b/init.lua index b98ffc6198a..9243c7cfcbc 100644 --- a/init.lua +++ b/init.lua @@ -83,15 +83,21 @@ I hope you enjoy your Neovim journey, P.S. You can delete this when you're done too. It's your config now! :) --]] +-- +-- +-- NvimTree +-- disable netrw at the very start of your init.lua +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 -- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) -vim.g.mapleader = ' ' -vim.g.maplocalleader = ' ' +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.o` @@ -100,6 +106,9 @@ vim.g.have_nerd_font = false -- Make line numbers default vim.o.number = true + +require 'keymaps' + -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! -- vim.o.relativenumber = true @@ -283,6 +292,9 @@ require('lazy').setup({ }, }, }, + { + 'giuxtaposition/blink-cmp-copilot', + }, -- NOTE: Plugins can also be configured to run Lua code when they are loaded. -- @@ -344,7 +356,7 @@ require('lazy').setup({ -- Document existing key chains spec = { - { 's', group = '[S]earch' }, + { 'f', group = '[F]ind' }, { 't', group = '[T]oggle' }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, }, @@ -426,15 +438,15 @@ require('lazy').setup({ -- See `:help telescope.builtin` local builtin = require 'telescope.builtin' - vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) - vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + 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' }) + vim.keymap.set('n', 'fs', builtin.builtin, { desc = '[F]ind [S]elect Telescope' }) + vim.keymap.set('n', 'fw', builtin.grep_string, { desc = '[F]ind current [W]ord' }) + 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' }) -- Slightly advanced example of overriding default behavior and theme @@ -448,17 +460,17 @@ require('lazy').setup({ -- It's also possible to pass additional configuration options. -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set('n', 's/', function() + vim.keymap.set('n', 'f/', function() builtin.live_grep { grep_open_files = true, prompt_title = 'Live Grep in Open Files', } - end, { desc = '[S]earch [/] in Open Files' }) + end, { desc = '[F]ind [/] in Open Files' }) -- Shortcut for searching your Neovim configuration files - vim.keymap.set('n', 'sn', function() + vim.keymap.set('n', 'fn', function() builtin.find_files { cwd = vim.fn.stdpath 'config' } - end, { desc = '[S]earch [N]eovim files' }) + end, { desc = '[F]ind [N]eovim files' }) end, }, @@ -535,43 +547,8 @@ require('lazy').setup({ vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) end - -- Rename the variable under your cursor. - -- Most Language Servers support renaming across files, etc. - map('grn', vim.lsp.buf.rename, '[R]e[n]ame') - - -- Execute a code action, usually your cursor needs to be on top of an error - -- or a suggestion from your LSP for this to activate. - map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' }) - - -- Find references for the word under your cursor. - map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - - -- Jump to the implementation of the word under your cursor. - -- Useful when your language has ways of declaring types without an actual implementation. - map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - - -- Jump to the definition of the word under your cursor. - -- This is where a variable was first declared, or where a function is defined, etc. - -- To jump back, press . - map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - - -- WARN: This is not Goto Definition, this is Goto Declaration. - -- For example, in C this would take you to the header. - map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - - -- Fuzzy find all the symbols in your current document. - -- Symbols are things like variables, functions, types, etc. - map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols') - - -- Fuzzy find all the symbols in your current workspace. - -- Similar to document symbols, except searches over your entire project. - map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols') - - -- Jump to the type of the word under your cursor. - -- Useful when you're not sure what type a variable is and you want to see - -- the definition of its *type*, not where it was *defined*. - map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition') - + -- Check out lua/custom/plugins/lsp.lua for more lsp related keymaps + -- -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10) ---@param client vim.lsp.Client ---@param method vim.lsp.protocol.Method @@ -672,7 +649,41 @@ require('lazy').setup({ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { -- clangd = {}, - -- gopls = {}, + gopls = { + settings = { + gopls = { + gofumpt = true, + codelenses = { + gc_details = false, + generate = true, + regenerate_cgo = true, + test = true, + tidy = true, + upgrade_dependency = true, + vendor = true, + }, + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, + analyses = { + fieldalignment = true, + nilness = true, + unusedparams = true, + unusedwrite = true, + useany = true, + }, + usePlaceholders = true, + completeUnimported = true, + staticcheck = true, + directoryFilters = { '-.git', '-.vscode', '-.idea', '-.vscode-test', '-node_modules' }, + }, + }, + }, -- pyright = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs @@ -742,7 +753,7 @@ require('lazy').setup({ cmd = { 'ConformInfo' }, keys = { { - 'f', + 'F', function() require('conform').format { async = true, lsp_format = 'fallback' } end, @@ -796,17 +807,23 @@ require('lazy').setup({ return 'make install_jsregexp' end)(), dependencies = { + -- Add the copilot source for blink here as well to ensure it loads + 'giuxtaposition/blink-cmp-copilot', + 'zbirenbaum/copilot.lua', -- Ensure the base copilot plugin is also present -- `friendly-snippets` contains a variety of premade snippets. -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, }, - opts = {}, + config = function() + -- load snippets from path/of/your/nvim/config/my-cool-snippets + require('luasnip.loaders.from_vscode').lazy_load { paths = { '~/.config/lvim/snippets/my-snippets' } } + end, }, 'folke/lazydev.nvim', }, @@ -851,11 +868,36 @@ require('lazy').setup({ -- By default, you may press `` to show the documentation. -- Optionally, set `auto_show = true` to show the documentation after a delay. documentation = { auto_show = false, auto_show_delay_ms = 500 }, + menu = { + draw = { + -- Define the columns to show in the completion menu + columns = { + { 'kind_icon' }, + { 'label', 'label_description', gap = 1 }, + { 'source_name' }, + }, + components = { + source_name = { + width = { max = 20 }, + text = function(ctx) + return ctx.source_name or '' + end, + highlight = 'BlinkCmpSource', + }, + }, + }, + }, }, - sources = { - default = { 'lsp', 'path', 'snippets', 'lazydev' }, + + default = { 'copilot', 'lsp', 'path', 'snippets', 'lazydev' }, providers = { + copilot = { + name = 'copilot', + module = 'blink-cmp-copilot', + score_offset = 100, + async = true, + }, lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, }, }, @@ -941,7 +983,7 @@ require('lazy').setup({ { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', - main = 'nvim-treesitter.configs', -- Sets main module to use for opts + main = 'nvim-treesitter.config', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, @@ -977,14 +1019,14 @@ require('lazy').setup({ -- require 'kickstart.plugins.indent_line', -- require 'kickstart.plugins.lint', -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.neo-tree', -- 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. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! @@ -1012,5 +1054,15 @@ require('lazy').setup({ }, }) +require('neo-tree').setup { + filesystem = { + follow_current_file = { + enabled = true, -- This will find and focus the file in the active buffer every time + -- -- the current file is changed while the tree is open. + leave_dirs_open = true, -- `false` closes auto expanded dirs, such as with `:Neotree reveal` + }, + }, +} + -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/custom/plugins/bufferline.lua b/lua/custom/plugins/bufferline.lua new file mode 100644 index 00000000000..d3f2faa6d1c --- /dev/null +++ b/lua/custom/plugins/bufferline.lua @@ -0,0 +1 @@ +return { 'akinsho/bufferline.nvim', version = '*', dependencies = 'nvim-tree/nvim-web-devicons' } diff --git a/lua/custom/plugins/conform.lua b/lua/custom/plugins/conform.lua new file mode 100644 index 00000000000..3b7fa781031 --- /dev/null +++ b/lua/custom/plugins/conform.lua @@ -0,0 +1,93 @@ +return { + 'stevearc/conform.nvim', + event = { 'BufWritePre' }, + cmd = { 'ConformInfo' }, + keys = { + { + -- Customize or remove this keymap to your liking + 'lf', + function() + require('conform').format { async = false } + end, + mode = 'n', + desc = 'Format buffer', + }, + }, + -- This will provide type hinting with LuaLS + ---@module "conform" + ---@type conform.setupOpts + opts = { + -- Define your formatters + formatters_by_ft = { + lua = { 'stylua' }, + python = { 'isort', 'black' }, + javascript = { 'eslint_d' }, + typescript = { 'eslint_d' }, + html = { 'eslint_d' }, + css = { 'eslint_d' }, + }, + -- Set default options + default_format_opts = { + lsp_format = 'fallback', + }, + -- Set up format-on-save + format_on_save = function(bufnr) + -- Disable format_on_save for TypeScript to prevent auto-indent conflicts + local filetype = vim.bo[bufnr].filetype + if filetype == 'typescript' or filetype == 'typescriptreact' or filetype == 'ts' or filetype == 'tsx' then + return false + end + return { timeout_ms = 500 } + end, + -- Customize formatters + formatters = { + shfmt = { + prepend_args = { '-i', '2' }, + }, + }, + eslint_d = { + args = { '--fix', '--stdin', '--stdin-filename', '$FILENAME' }, + cwd = function(bufnr) + local bufname = vim.api.nvim_buf_get_name(bufnr) + return vim.fs.dirname(bufname) + end, + }, + }, + init = function() + vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" + + -- Set TypeScript indentation to 2 spaces and disable ALL auto-formatting/indenting + vim.api.nvim_create_autocmd('FileType', { + pattern = { 'typescript', 'typescriptreact', 'ts', 'tsx' }, + callback = function() + vim.opt_local.tabstop = 2 + vim.opt_local.shiftwidth = 2 + -- Disable ALL auto-indent/format options + vim.opt_local.autoindent = false + vim.opt_local.smartindent = false + vim.opt_local.cindent = false + vim.opt_local.indentexpr = '' + vim.opt_local.equalprg = '' + vim.opt_local.formatprg = '' + vim.opt_local.formatexpr = '' + -- Disable vim-sleuth for TypeScript files + vim.b.sleuth_automatic = 0 + end, + }) + + -- Prevent ANY auto-indent/format before write for TypeScript files + vim.api.nvim_create_autocmd('BufWritePre', { + pattern = { '*.ts', '*.tsx' }, + callback = function() + -- Completely disable all formatting/indenting right before save + vim.opt_local.indentexpr = '' + vim.opt_local.equalprg = '' + vim.opt_local.formatprg = '' + vim.opt_local.formatexpr = '' + vim.opt_local.autoindent = false + vim.opt_local.smartindent = false + vim.opt_local.cindent = false + end, + }) + end, +} diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua new file mode 100644 index 00000000000..eb6ceb12d7d --- /dev/null +++ b/lua/custom/plugins/copilot.lua @@ -0,0 +1,20 @@ +return { + 'zbirenbaum/copilot.lua', + cmd = 'Copilot', + event = 'InsertEnter', + dependencies = { + 'copilotlsp-nvim/copilot-lsp', + }, + opts = { + -- nes = { + -- enabled = true, + -- keymap = { + -- accept_and_goto = '', + -- accept = false, + -- dismiss = '', + -- }, + -- }, + suggestion = { enabled = true }, + panel = { enabled = false }, + }, +} diff --git a/lua/custom/plugins/lazyvim.lua b/lua/custom/plugins/lazyvim.lua new file mode 100644 index 00000000000..07995784e79 --- /dev/null +++ b/lua/custom/plugins/lazyvim.lua @@ -0,0 +1,8 @@ +return { + "kdheepak/lazygit.nvim", + cmd = "LazyGit", + -- optional for floating window border decoration + dependencies = { + "nvim-lua/plenary.nvim", + }, +} diff --git a/lua/custom/plugins/markdown-preview.lua b/lua/custom/plugins/markdown-preview.lua new file mode 100644 index 00000000000..a16a810a24d --- /dev/null +++ b/lua/custom/plugins/markdown-preview.lua @@ -0,0 +1,17 @@ +-- return { +-- 'iamcco/markdown-preview.nvim', +-- cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' }, +-- ft = { 'markdown' }, +-- build = function() +-- vim.fn['mkdp#util#install']() +-- end, +-- } +return { + "iamcco/markdown-preview.nvim", + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + build = "cd app && yarn install", + init = function() + vim.g.mkdp_filetypes = { "markdown" } + end, + ft = { "markdown" }, +} diff --git a/lua/custom/plugins/nvim-surround.lua b/lua/custom/plugins/nvim-surround.lua new file mode 100644 index 00000000000..252d84145b8 --- /dev/null +++ b/lua/custom/plugins/nvim-surround.lua @@ -0,0 +1,10 @@ +return { + "kylechui/nvim-surround", + version = "*", -- Use for stability; omit to use `main` branch for the latest features + event = "VeryLazy", + config = function() + require("nvim-surround").setup { + -- Configuration here, or leave empty to use defaults + } + end, +} diff --git a/lua/custom/plugins/nvim-tmux-navigation.lua b/lua/custom/plugins/nvim-tmux-navigation.lua new file mode 100644 index 00000000000..26f482289ac --- /dev/null +++ b/lua/custom/plugins/nvim-tmux-navigation.lua @@ -0,0 +1,16 @@ +return { + 'alexghergh/nvim-tmux-navigation', + config = function() + require('nvim-tmux-navigation').setup { + disable_when_zoomed = true, -- defaults to false + keybindings = { + left = '', + down = '', + up = '', + right = '', + last_active = '', + next = '', + }, + } + end, +} diff --git a/lua/custom/plugins/obsidian.lua b/lua/custom/plugins/obsidian.lua new file mode 100644 index 00000000000..92cfb6b75d2 --- /dev/null +++ b/lua/custom/plugins/obsidian.lua @@ -0,0 +1,19 @@ +return { + 'obsidian-nvim/obsidian.nvim', + version = '*', -- use latest release, remove to use latest commit + ft = 'markdown', + ---@module 'obsidian' + ---@type obsidian.config + opts = { + legacy_commands = false, -- this will be removed in the next major release + -- Disable footer to avoid "calling 'backlinks' on bad self" when timer runs + -- after buffer is closed/reused (plugin bug: footer doesn't validate buffer). + footer = { enabled = false }, + workspaces = { + { + name = 'MyOnlyVault', + path = '~/AdisObsidianSyncVault', + }, + }, + }, +} diff --git a/lua/custom/plugins/plenary.lua b/lua/custom/plugins/plenary.lua new file mode 100644 index 00000000000..d3e0f62a24f --- /dev/null +++ b/lua/custom/plugins/plenary.lua @@ -0,0 +1,3 @@ +return { + 'nvim-lua/plenary.nvim', +} diff --git a/lua/custom/plugins/render-markdown.lua b/lua/custom/plugins/render-markdown.lua new file mode 100644 index 00000000000..845bb621c1c --- /dev/null +++ b/lua/custom/plugins/render-markdown.lua @@ -0,0 +1,10 @@ +return { + "MeanderingProgrammer/render-markdown.nvim", + dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" }, -- if you use the mini.nvim suite + ft = { "markdown" }, + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons + ---@module 'render-markdown' + ---@type render.md.UserConfig + opts = {}, +} diff --git a/lua/custom/plugins/tasko.lua b/lua/custom/plugins/tasko.lua new file mode 100644 index 00000000000..c9f234893c0 --- /dev/null +++ b/lua/custom/plugins/tasko.lua @@ -0,0 +1,13 @@ +return { + 'adi-de-masi/tasko.nvim', + -- dir = '/Users/adidemasi/code/tasko.nvim', + dependencies = { + { 'nvim-lua/plenary.nvim' }, + { 'nvim-telescope/telescope.nvim' }, + }, + config = function() + require('tasko').setup { + provider = 'todoist', + } + end, +} diff --git a/lua/custom/plugins/trouble.lua b/lua/custom/plugins/trouble.lua new file mode 100644 index 00000000000..cf9dd307f25 --- /dev/null +++ b/lua/custom/plugins/trouble.lua @@ -0,0 +1,37 @@ +return { + "folke/trouble.nvim", + opts = {}, -- for default options, refer to the configuration section for custom setup. + cmd = "Trouble", + keys = { + { + "tt", + "Trouble diagnostics toggle", + desc = "Diagnostics (Trouble)", + }, + { + "tb", + "Trouble diagnostics toggle filter.buf=0", + desc = "Buffer Diagnostics (Trouble)", + }, + { + "ts", + "Trouble symbols toggle focus=false", + desc = "Symbols (Trouble)", + }, + { + "tl", + "Trouble lsp toggle focus=false win.position=right", + desc = "LSP Definitions / references / ... (Trouble)", + }, + { + "tL", + "Trouble loclist toggle", + desc = "Location List (Trouble)", + }, + { + "tQ", + "Trouble qflist toggle", + desc = "Quickfix List (Trouble)", + }, + }, +} diff --git a/lua/custom/plugins/typescript-tools.lua b/lua/custom/plugins/typescript-tools.lua new file mode 100644 index 00000000000..0f139a5034d --- /dev/null +++ b/lua/custom/plugins/typescript-tools.lua @@ -0,0 +1,6 @@ +return { + 'pmizio/typescript-tools.nvim', + dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' }, + ft = { 'typescript', 'typescriptreact', 'javascript', 'javascriptreact' }, + opts = {}, +} diff --git a/lua/keymaps.lua b/lua/keymaps.lua new file mode 100644 index 00000000000..6c43f36c6cb --- /dev/null +++ b/lua/keymaps.lua @@ -0,0 +1,114 @@ +-- Adi's custom section +local map = vim.keymap.set +--local unmap = vim.keymap.del + +-- Neovim 0.11+ ships default LSP keymaps in `vim/_defaults.lua` (e.g. `grr`, `gri`, `grt`), +-- but those use the built-in UI (often a locations list / read-only buffer). +-- Override them here to prefer Telescope pickers. +local function telescope_lsp(picker, fallback, picker_opts) + return function() + local ok, builtin = pcall(require, 'telescope.builtin') + if ok and type(builtin[picker]) == 'function' then + return builtin[picker](picker_opts or {}) + end + return fallback() + end +end + +map('n', 'grr', telescope_lsp('lsp_references', vim.lsp.buf.references), { desc = 'LSP: references (telescope)' }) +map('n', 'gi', telescope_lsp('lsp_implementations', vim.lsp.buf.implementation), { desc = 'LSP: implementations (telescope)' }) +map('n', 'gt', telescope_lsp('lsp_type_definitions', vim.lsp.buf.type_definition), { desc = 'LSP: type definitions (telescope)' }) +map('n', 'gO', telescope_lsp('lsp_document_symbols', vim.lsp.buf.document_symbol), { desc = 'LSP: document symbols (telescope)' }) +map('n', 'gd', telescope_lsp('lsp_definitions', vim.lsp.buf.document_symbol), { desc = 'LSP: Go to definition' }) + +map('n', ';', ':', { desc = 'CMD enter command mode' }) +map('i', 'jk', '') + +map('n', 'h', 'nohlsearch', { desc = 'set no highlight search' }) +map('n', '', ' m .+1==', { desc = 'Move line down' }) +map('n', '', ' m .-2==', { desc = 'Move line up' }) +map('v', '', ":m '>+1gv=gv", { desc = 'Move selected block down' }) +map('v', '', ":m '<-2gv=gv", { desc = 'Move selected block up' }) +map('v', 'y', '"*y', { desc = 'Yank to clipboard' }) + +map('n', 'w', ':w ', { desc = 'alias to :w' }) +map('n', '', 'NvimTmuxNavigateLeft', { silent = true }) +map('n', '', 'NvimTmuxNavigateDown', { silent = true }) +map('n', '', 'NvimTmuxNavigateUp', { silent = true }) +map('n', '', 'NvimTmuxNavigateRight', { silent = true }) +map('n', '', 'NvimTmuxNavigateLastActive', { silent = true }) +map('n', 'm', 'MarkdownPreview', { silent = true }) +map('n', 'gg', ' LazyGit ', { desc = 'start LazyGit' }) + +map('n', 'd', ' Run/Debug') +map('n', 'fe', 'Telescope emoji', { desc = '😃 [F]ind [E]moji' }) +map('n', 'fb', 'Telescope buffers', { desc = '😃 [F]ind [B]uffer' }) +map('n', 'l', ' Lsp') +map('n', 'lw', function() + vim.diagnostic.setloclist() +end, { desc = 'Diagnostic setloclist' }) +map('n', 'la', 'lua vim.lsp.buf.code_action()', { desc = 'code actions' }) + +map('n', 't', ' Telescope or  Trouble') +map('n', 'tr', 'Telescope resume') +map('n', 'r', ' Render Markdown') +map('n', 'rt', 'RenderMarkdown toggle', { desc = 'toggle render markdown', silent = true }) +map('n', 're', 'RenderMarkdown expand', { desc = 'Increase anti-conceal margin above and below by 1', silent = true }) +map('n', 're', 'RenderMarkdown expand', { desc = 'Decrease anti-conceal margin above and below by 1', silent = true }) + +map('n', 'e', 'Neotree toggle') +map('n', '', 'bn', { desc = 'next buffer' }) +map('n', '', 'bp', { desc = 'previous buffer' }) +map('n', 'x', 'bd', { desc = 'delete buffer' }) + +map('n', 'X', ':only', { desc = 'Close other panes' }) + +-- TJs kickstart +-- +-- +-- [[ Basic Keymaps ]] +-- See `:help map()` + +-- Clear highlights on search when pressing in normal mode +-- See `:help hlsearch` +--map('n', '', 'nohlsearch') + +-- Diagnostic keymaps +map('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) + +-- 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. +-- +-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping +-- or just use to exit terminal mode +map('t', '', '', { desc = 'Exit terminal mode' }) + +-- TIP: Disable arrow keys in normal mode +-- map('n', '', 'echo "Use h to move!!"') +-- map('n', '', 'echo "Use l to move!!"') +-- map('n', '', 'echo "Use k to move!!"') +-- map('n', '', 'echo "Use j to move!!"') + +-- Keybinds to make split navigation easier. +-- Use CTRL+ to switch between windows +-- +-- See `:help wincmd` for a list of all window commands +-- 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' }) + +-- [[ Basic Autocommands ]] +-- See `:help lua-guide-autocommands` + +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.highlight.on_yank()` +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index c7067891df0..4640a3e3e65 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -1,6 +1,5 @@ -- Neo-tree is a Neovim plugin to browse the file system -- https://github.com/nvim-neo-tree/neo-tree.nvim - return { 'nvim-neo-tree/neo-tree.nvim', version = '*', @@ -21,5 +20,37 @@ return { }, }, }, + -- your config here + event_handlers = { + -- save layout before opening neotree + { + event = 'neo_tree_window_before_open', + handler = function() + -- vim.cmd("set noequalalways") + local layout = {} + for _, win in ipairs(vim.api.nvim_list_wins()) do + layout[win] = { + height = vim.api.nvim_win_get_height(win), + width = vim.api.nvim_win_get_width(win), + } + end + vim._neotree_layout = layout + end, + }, + -- restore layout after closing neotree + { + event = 'neo_tree_window_after_close', + handler = function() + if vim._neotree_layout then + for win, dims in pairs(vim._neotree_layout) do + if vim.api.nvim_win_is_valid(win) then + pcall(vim.api.nvim_win_set_height, win, dims.height) + pcall(vim.api.nvim_win_set_width, win, dims.width) + end + end + end + end, + }, + }, }, }