diff --git a/.gitignore b/.gitignore index 005b535b606..8a192cab54d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ test.sh nvim spell/ -lazy-lock.json diff --git a/init.lua b/init.lua index 776c6873ff6..e3d83bdbaee 100644 --- a/init.lua +++ b/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` @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -120,6 +120,7 @@ end) -- Enable break indent vim.opt.breakindent = true +-- vim.opt.smartindent = true -- Save undo history vim.opt.undofile = true @@ -164,13 +165,18 @@ vim.opt.confirm = true -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` --- Clear highlights on search when pressing in normal mode +-- Set highlight on search, but clear on pressing in normal mode -- See `:help hlsearch` +vim.opt.hlsearch = true vim.keymap.set('n', '', 'nohlsearch') -- Diagnostic keymaps vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) +-- new line on shift enter +vim.keymap.set('n', '', 'm`o``') +vim.keymap.set('n', '', 'm`O``') + -- 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. @@ -241,6 +247,15 @@ require('lazy').setup({ -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically + { + 'max397574/better-escape.nvim', + config = function() + require('better_escape').setup() + end, + }, + + { 'almo7aya/openingh.nvim' }, + -- NOTE: Plugins can also be added by using a table, -- with the first argument being the link and the following -- keys can be used to configure plugin behavior/loading/etc. @@ -336,6 +351,9 @@ require('lazy').setup({ -- Document existing key chains spec = { + { 'c', group = '[C]ode', mode = { 'n', 'x' } }, + { 'd', group = '[D]ocument' }, + { 'r', group = '[R]ename' }, { 's', group = '[S]earch' }, { 't', group = '[T]oggle' }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, @@ -404,6 +422,18 @@ require('lazy').setup({ -- i = { [''] = 'to_fuzzy_refine' }, -- }, -- }, + -- + defaults = { + layout_strategy = 'vertical', + layout_config = { + vertical = { + preview_cutoff = 0, + width = 0.95, + height = 0.95, + }, + }, + -- layout_config = { height = 0.95 }, + }, -- pickers = {} extensions = { ['ui-select'] = { @@ -564,6 +594,10 @@ require('lazy').setup({ -- the definition of its *type*, not where it was *defined*. map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition') + -- Opens a popup that displays documentation about the word under your cursor + -- See `:help K` for why this keymap. + map('K', vim.lsp.buf.hover, 'Hover Documentation') + -- 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 @@ -665,7 +699,19 @@ require('lazy').setup({ local servers = { -- clangd = {}, -- gopls = {}, - -- pyright = {}, + pyright = { + settings = { + pyright = { + disableOrganizeImports = true, -- Using Ruff + }, + python = { + analysis = { + ignore = { '*' }, -- Using Ruff + }, + }, + }, + }, + ruff = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- @@ -673,8 +719,7 @@ require('lazy').setup({ -- https://github.com/pmizio/typescript-tools.nvim -- -- But for many setups, the LSP (`ts_ls`) will work just fine - -- ts_ls = {}, - -- + ts_ls = {}, lua_ls = { -- cmd = { ... }, @@ -761,10 +806,11 @@ require('lazy').setup({ formatters_by_ft = { lua = { 'stylua' }, -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, + python = { 'black' }, -- -- You can use 'stop_after_first' to run the first available formatter from the list -- javascript = { "prettierd", "prettier", stop_after_first = true }, + ruby = { 'standardrb' }, }, }, }, @@ -881,8 +927,8 @@ require('lazy').setup({ styles = { comments = { italic = false }, -- Disable italics in comments }, + transparent = true, } - -- 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'. @@ -911,6 +957,9 @@ require('lazy').setup({ -- - sr)' - [S]urround [R]eplace [)] ['] require('mini.surround').setup() + -- - gcc - Comment current line + require('mini.comment').setup() + -- Simple and easy statusline. -- You could remove this setup call if you don't like it, -- and try some other statusline plugin @@ -944,16 +993,55 @@ require('lazy').setup({ -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. -- If you are experiencing weird indenting issues, add the language to -- the list of additional_vim_regex_highlighting and disabled languages for indent. - additional_vim_regex_highlighting = { 'ruby' }, + additional_vim_regex_highlighting = { 'ruby', 'python' }, }, - indent = { enable = true, disable = { 'ruby' } }, + indent = { enable = true, disable = { 'ruby', 'python' } }, }, - -- There are additional nvim-treesitter modules that you can use to interact - -- with nvim-treesitter. You should go explore a few and see what interests you: - -- - -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` - -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context - -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects + config = function(_, opts) + -- [[ Configure Treesitter ]] See `:help nvim-treesitter` + + -- Prefer git instead of curl in order to improve connectivity in some environments + require('nvim-treesitter.install').prefer_git = true + ---@diagnostic disable-next-line: missing-fields + require('nvim-treesitter.configs').setup(opts) + + -- There are additional nvim-treesitter modules that you can use to interact + -- with nvim-treesitter. You should go explore a few and see what interests you: + -- + -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` + -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context + -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects + end, + }, + + -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context + { + 'nvim-treesitter/nvim-treesitter-context', + config = function() + require('treesitter-context').setup { + enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) + max_lines = 3, -- How many lines the window should span. Values <= 0 mean no limit. + min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit. + line_numbers = true, + multiline_threshold = 10, -- Maximum number of lines to show for a single context + trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' + mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline' + separator = nil, -- When separator is set, the context will only show up when there are at least 2 lines above cursorline. + zindex = 20, -- The Z-index of the context window + on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching + } + end, + }, + { + 'mrjones2014/smart-splits.nvim', + lazy = false, + }, + + { + 'mg979/vim-visual-multi', + }, + { + 'github/copilot.vim', }, -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the @@ -968,15 +1056,15 @@ require('lazy').setup({ -- require 'kickstart.plugins.debug', -- require 'kickstart.plugins.indent_line', -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.autopairs', + 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! @@ -1004,5 +1092,22 @@ require('lazy').setup({ }, }) +-- Smart Splits +vim.keymap.set('n', '', require('smart-splits').resize_left) +vim.keymap.set('n', '', require('smart-splits').resize_down) +vim.keymap.set('n', '', require('smart-splits').resize_up) +vim.keymap.set('n', '', require('smart-splits').resize_right) +-- moving between splits +vim.keymap.set('n', '', require('smart-splits').move_cursor_left) +vim.keymap.set('n', '', require('smart-splits').move_cursor_down) +vim.keymap.set('n', '', require('smart-splits').move_cursor_up) +vim.keymap.set('n', '', require('smart-splits').move_cursor_right) +vim.keymap.set('n', '', require('smart-splits').move_cursor_previous) +-- swapping buffers between windows +vim.keymap.set('n', 'h', require('smart-splits').swap_buf_left) +vim.keymap.set('n', 'j', require('smart-splits').swap_buf_down) +vim.keymap.set('n', 'k', require('smart-splits').swap_buf_up) +vim.keymap.set('n', 'l', require('smart-splits').swap_buf_right) + -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000000..68f310ee610 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,38 @@ +{ + "LuaSnip": { "branch": "master", "commit": "5a1e39223db9a0498024a77b8441169d260c8c25" }, + "better-escape.nvim": { "branch": "master", "commit": "19a38aab94961016430905ebec30d272a01e9742" }, + "blink.cmp": { "branch": "main", "commit": "4b18c32adef2898f95cdef6192cbd5796c1a332d" }, + "conform.nvim": { "branch": "master", "commit": "c2526f1cde528a66e086ab1668e996d162c75f4f" }, + "copilot.vim": { "branch": "release", "commit": "a12fd5672110c8aa7e3c8419e28c96943ca179be" }, + "fidget.nvim": { "branch": "main", "commit": "7fa433a83118a70fe24c1ce88d5f0bd3453c0970" }, + "gitsigns.nvim": { "branch": "main", "commit": "9f3c6dd7868bcc116e9c1c1929ce063b978fa519" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lazydev.nvim": { "branch": "main", "commit": "5231c62aa83c2f8dc8e7ba957aa77098cda1257d" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "21c2a84ce368e99b18f52ab348c4c02c32c02fcf" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc" }, + "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, + "mini.nvim": { "branch": "main", "commit": "4ca988557786c9a4e41d5e5b6e31b4c9d7379f53" }, + "neo-tree.nvim": { "branch": "main", "commit": "f3df514fff2bdd4318127c40470984137f87b62e" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-autopairs": { "branch": "master", "commit": "59bce2eef357189c3305e25bc6dd2d138c1683f5" }, + "nvim-dap": { "branch": "master", "commit": "db321947bb289a2d4d76a32e76e4d2bd6103d7df" }, + "nvim-dap-python": { "branch": "master", "commit": "1808458eba2b18f178f990e01376941a42c7f93b" }, + "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, + "nvim-lspconfig": { "branch": "master", "commit": "44acfe887d4056f704ccc4f17513ed41c9e2b2e6" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-treesitter-context": { "branch": "master", "commit": "64dd4cf3f6fd0ab17622c5ce15c91fc539c3f24a" }, + "nvim-web-devicons": { "branch": "master", "commit": "746ffbb17975ebd6c40142362eee1b0249969c5c" }, + "openingh.nvim": { "branch": "main", "commit": "7cc8c897cb6b34d8ed28e99d95baccef609ed251" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "smart-splits.nvim": { "branch": "master", "commit": "b9d563ea52c4926a4d91e5e795c68bb8f89f8ba0" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "master", "commit": "ad7d9580338354ccc136e5b8f0aa4f880434dcdc" }, + "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, + "tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" }, + "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, + "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, + "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } +} diff --git a/lua/custom/plugins/nvim-dap.lua b/lua/custom/plugins/nvim-dap.lua new file mode 100644 index 00000000000..09292002375 --- /dev/null +++ b/lua/custom/plugins/nvim-dap.lua @@ -0,0 +1,86 @@ +return { + { + 'mfussenegger/nvim-dap', + dependencies = { + 'nvim-neotest/nvim-nio', + 'rcarriga/nvim-dap-ui', + 'mfussenegger/nvim-dap-python', + 'theHamsta/nvim-dap-virtual-text', + }, + config = function() + local dap = require 'dap' + local dapui = require 'dapui' + local dap_python = require 'dap-python' + + require('dapui').setup {} + require('nvim-dap-virtual-text').setup { + commented = true, -- Show virtual text alongside comment + } + + dap_python.setup 'uv' + + vim.fn.sign_define('DapBreakpoint', { + text = '', + texthl = 'DiagnosticSignError', + linehl = '', + numhl = '', + }) + + vim.fn.sign_define('DapBreakpointRejected', { + text = '', -- or "❌" + texthl = 'DiagnosticSignError', + linehl = '', + numhl = '', + }) + + vim.fn.sign_define('DapStopped', { + text = '', -- or "→" + texthl = 'DiagnosticSignWarn', + linehl = 'Visual', + numhl = 'DiagnosticSignWarn', + }) + + -- Automatically open/close DAP UI + dap.listeners.after.event_initialized['dapui_config'] = function() + dapui.open() + end + + local opts = { noremap = true, silent = true } + + -- Toggle breakpoint + vim.keymap.set('n', 'db', function() + dap.toggle_breakpoint() + end, opts) + + -- Continue / Start + vim.keymap.set('n', 'dc', function() + dap.continue() + end, opts) + + -- Step Over + vim.keymap.set('n', 'do', function() + dap.step_over() + end, opts) + + -- Step Into + vim.keymap.set('n', 'di', function() + dap.step_into() + end, opts) + + -- Step Out + vim.keymap.set('n', 'dO', function() + dap.step_out() + end, opts) + + -- Keymap to terminate debugging + vim.keymap.set('n', 'dq', function() + require('dap').terminate() + end, opts) + + -- Toggle DAP UI + vim.keymap.set('n', 'du', function() + dapui.toggle() + end, opts) + end, + }, +} diff --git a/lua/custom/plugins/ruby.lua b/lua/custom/plugins/ruby.lua new file mode 100644 index 00000000000..fbc2ef83a50 --- /dev/null +++ b/lua/custom/plugins/ruby.lua @@ -0,0 +1,25 @@ +return { + { + 'WhoIsSethDaniel/mason-tool-installer.nvim', + opts = { + ensure_installed = { + 'ruby-lsp', + 'erb-formatter', + }, + }, + }, + { + 'saghen/blink.cmp', + opts = { + sources = { + providers = { + snippets = { + opts = { + extended_filetypes = { ruby = { 'rails' } }, + }, + }, + }, + }, + }, + }, +} diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index bd4422695aa..a856a99090c 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -13,8 +13,29 @@ return { keys = { { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, }, + -- sourced from here https://github.com/LazyVim/LazyVim/blob/4d706f1bdc687f1d4d4cd962ec166c65c453633e/lua/lazyvim/plugins/editor.lua#L46-L64 + -- 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 = { filesystem = { + filtered_items = { hide_dotfiles = false }, window = { mappings = { ['\\'] = 'close_window',