From 073319c1b901ffc5221cabcf9ca776166c6af960 Mon Sep 17 00:00:00 2001 From: adollar <71227493+abp1994@users.noreply.github.com> Date: Wed, 25 Jun 2025 16:56:32 +0100 Subject: [PATCH] added the basics back in --- init.lua | 246 ++----------------------------- lazy-lock.json | 14 +- lua/core/keymaps.lua | 51 +++++++ lua/core/options.lua | 44 ++++++ lua/core/snippets.lua | 13 ++ lua/plugins/autopairs.lua | 7 + lua/plugins/gitsigns.lua | 53 +++++++ lua/plugins/indent-blankline.lua | 25 ++++ lua/plugins/neo-tree.lua | 25 ++++ 9 files changed, 236 insertions(+), 242 deletions(-) create mode 100644 lua/core/keymaps.lua create mode 100644 lua/core/options.lua create mode 100644 lua/core/snippets.lua create mode 100644 lua/plugins/autopairs.lua create mode 100644 lua/plugins/gitsigns.lua create mode 100644 lua/plugins/indent-blankline.lua create mode 100644 lua/plugins/neo-tree.lua diff --git a/init.lua b/init.lua index 9bbf413d..bd9a073f 100644 --- a/init.lua +++ b/init.lua @@ -1,244 +1,10 @@ ---[[ - -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== -======== .-----. ======== -======== .----------------------. | === | ======== -======== |.-""""""""""""""""""-.| |-----| ======== -======== || || | === | ======== -======== || KICKSTART.NVIM || |-----| ======== -======== || || | === | ======== -======== || || |-----| ======== -======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____o| ======== -======== `"")----------------(""` ___________ ======== -======== /::::::::::| |::::::::::\ \ no mouse \ ======== -======== /:::========| |==hjkl==:::\ \ required \ ======== -======== '""""""""""""' '""""""""""""'smarttab '""""""""""' ======== -======== ======== -===================================================================== -===================================================================== - -What is Kickstart? - - Kickstart.nvim is *not* a distribution. - - Kickstart.nvim is a starting point for your own configuration. - The goal is that you can read every line of code, top-to-bottom, understand - what your configuration is doing, and modify it to suit your needs. - - Once you've done that, you can start exploring, configuring and tinkering to - make Neovim your own! That might mean leaving Kickstart just the way it is for a while - or immediately breaking it into modular pieces. It's up to you! - - If you don't know anything about Lua, I recommend taking some time to read through - a guide. One possible example which will only take 10-15 minutes: - - https://learnxinyminutes.com/docs/lua/ - - After understanding a bit more about Lua, you can use `:help lua-guide` as a - reference for how Neovim integrates Lua. - - :help lua-guide - - (or HTML version): https://neovim.io/doc/user/lua-guide.html - -Kickstart Guide: - - TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. - - If you don't know what this means, type the following: - - - - : - - Tutor - - - - (If you already know the Neovim basics, you can skip this step.) - - Once you've completed that, you can continue working through **AND READING** the rest - of the kickstart init.lua. - - Next, run AND READ `:help`. - This will open up a help window with some basic information - about reading, navigating and searching the builtin help documentation. - - This should be the first place you go to look when you're stuck or confused - with something. It's one of my favorite Neovim features. - - MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation, - which is very useful when you're not exactly sure of what you're looking for. - - I have left several `:help X` comments throughout the init.lua - These are hints about where to find more information about the relevant settings, - plugins or Neovim features used in Kickstart. - - NOTE: Look for lines like this - - Throughout the file. These are for you, the reader, to help you understand what is happening. - Feel free to delete them once you know what you're doing, but they should serve as a guide - for when you are first encountering a few different constructs in your Neovim config. - -If you experience any errors while trying to install kickstart, run `:checkhealth` for more info. - -I hope you enjoy your Neovim journey, -- TJ - -P.S. You can delete this when you're done too. It's your config now! :) ---]] - --- 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 = ' ' +require 'core.options' +require 'core.keymaps' +require 'core.snippets' -- Set to true if you have a Nerd Font installed and selected in the terminal vim.g.have_nerd_font = true --- [[ Setting options ]] --- See `:help vim.o` --- NOTE: You can change these options as you wish! --- For more options, you can see `:help option-list` - --- Make line numbers default -vim.o.number = true --- You can also add relative line numbers, to help with jumping. --- Experiment for yourself to see if you like it! -vim.o.relativenumber = true - --- Enable mouse mode, can be useful for resizing splits for example! -vim.o.mouse = 'a' - --- Don't show the mode, since it's already in the status line -vim.o.showmode = false - --- Sync clipboard between OS and Neovim. --- Schedule the setting after `UiEnter` because it can increase startup-time. --- Remove this option if you want your OS clipboard to remain independent. --- See `:help 'clipboard'` -vim.schedule(function() - vim.o.clipboard = 'unnamedplus' -end) - --- Enable break indent -vim.o.breakindent = true - --- Save undo history -vim.o.undofile = true - --- Case-insensitive searching UNLESS \C or one or more capital letters in the search term -vim.o.ignorecase = true - --- Override 'ignorecase' if search pattern contains uppercase letters -vim.o.smartcase = true - --- Show search matches as you type -vim.o.incsearch = true - --- Highlight all matches of the last search -vim.o.hlsearch = true - --- Keep signcolumn on by default -vim.o.signcolumn = 'yes' - --- Decrease update time -vim.o.updatetime = 250 - --- Decrease mapped sequence wait time -vim.o.timeoutlen = 300 - --- Configure how new splits should be opened -vim.o.splitright = true -vim.o.splitbelow = true - --- Sets how neovim will display certain whitespace characters in the editor. --- See `:help 'list'` --- and `:help 'listchars'` --- --- Notice listchars is set using `vim.opt` instead of `vim.o`. --- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables. --- See `:help lua-options` --- and `:help lua-options-guide` -vim.o.list = true -vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } - --- Preview substitutions live, as you type! -vim.o.inccommand = 'split' - --- Show which line your cursor is on -vim.o.cursorline = true - --- Minimal number of screen lines to keep above and below the cursor. -vim.o.scrolloff = 10 - --- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), --- instead raise a dialog asking if you wish to save the current file(s) --- See `:help 'confirm'` -vim.o.confirm = true - --- Highlight matching parentheses and brackets -vim.o.showmatch = true - ---Enable automatic indentation -vim.o.autoindent = true - ---Enable smart indentation -vim.o.smartindent = true - ---Round indent to multiple of 'hiftwidth' -vim.o.shiftround = false - --- [[ Basic Keymaps ]] --- See `:help vim.keymap.set()` - --- Clear highlights on search when pressing in normal mode --- See `:help hlsearch` -vim.keymap.set('n', '', 'nohlsearch') - --- Diagnostic keymaps -vim.keymap.set('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 -vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) - --- TIP: Disable arrow keys in normal mode --- vim.keymap.set('n', '', 'echo "Use h to move!!"') --- vim.keymap.set('n', '', 'echo "Use l to move!!"') --- vim.keymap.set('n', '', 'echo "Use k to move!!"') --- vim.keymap.set('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 -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' }) - --- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes --- vim.keymap.set("n", "", "H", { desc = "Move window to the left" }) --- vim.keymap.set("n", "", "L", { desc = "Move window to the right" }) --- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) --- vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) - --- [[ Basic Autocommands ]] --- See `:help lua-guide-autocommands` - --- Highlight when yanking (copying) text --- Try it with `yap` in normal mode --- See `:help vim.hl.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.hl.on_yank() - end, -}) - -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' @@ -303,6 +69,10 @@ require('lazy').setup({ }, }, }, + require 'plugins.neo-tree', + require 'plugins.autopairs', + require 'plugins.gitsigns', + require 'plugins.indent-blankline', -- NOTE: Plugins can also be configured to run Lua code when they are loaded. -- @@ -694,6 +464,7 @@ require('lazy').setup({ -- clangd = {}, -- gopls = {}, -- pyright = {}, + ruff = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- @@ -788,6 +559,7 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + python = { 'ruff_fix', 'ruff_format', 'ruff_organize_imports' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- diff --git a/lazy-lock.json b/lazy-lock.json index 27299c64..44fdbe60 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -3,17 +3,21 @@ "blink.cmp": { "branch": "main", "commit": "9bcb14b43852a6f2bfd5ac9ef29cb5cf09b1b39b" }, "conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" }, "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, - "gitsigns.nvim": { "branch": "main", "commit": "88205953bd748322b49b26e1dfb0389932520dc9" }, + "gitsigns.nvim": { "branch": "main", "commit": "1b0350ab707713b2bc6c236151f1a324175347b1" }, "guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" }, + "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "be159e939543777bbfe9e1fe5389984c4570afce" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "c4c84f4521d62de595c0d0f718a9a40c1890c8ce" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "93a9ff9b34c91c0cb0f7de8d5f7e4abce51d8903" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, - "mini.nvim": { "branch": "main", "commit": "3f5d06a6f710966cb93baaadc4897eeb6d6210e5" }, - "nvim-lspconfig": { "branch": "master", "commit": "314b35335cc84bc2a085c84c69da955ba22da163" }, + "mini.nvim": { "branch": "main", "commit": "01dce72f2177de6044bcab60ebb8f8e56ade0936" }, + "neo-tree.nvim": { "branch": "main", "commit": "f481de16a0eb59c985abac8985e3f2e2f75b4875" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-autopairs": { "branch": "master", "commit": "2647cce4cb64fb35c212146663384e05ae126bdf" }, + "nvim-lspconfig": { "branch": "master", "commit": "6bba673aa8993eceec233be17b42ddfb9540794b" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, + "nvim-web-devicons": { "branch": "master", "commit": "19d6211c78169e78bab372b585b6fb17ad974e82" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, diff --git a/lua/core/keymaps.lua b/lua/core/keymaps.lua new file mode 100644 index 00000000..f1f9ed23 --- /dev/null +++ b/lua/core/keymaps.lua @@ -0,0 +1,51 @@ +-- [[ Basic Keymaps ]] +-- See `:help vim.keymap.set()` + +-- Set as the leader key +-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' + +-- Sync clipboard between OS and Neovim. +-- Schedule the setting after `UiEnter` because it can increase startup-time. +-- Remove this option if you want your OS clipboard to remain independent. +-- See `:help 'clipboard'` +vim.schedule(function() + vim.o.clipboard = 'unnamedplus' +end) + +-- Clear highlights on search when pressing in normal mode +-- See `:help hlsearch` +vim.keymap.set('n', '', 'nohlsearch') + +-- Diagnostic keymaps +vim.keymap.set('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 +vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) + +-- TIP: Disable arrow keys in normal mode +vim.keymap.set('n', '', 'echo "Use h to move!!"') +vim.keymap.set('n', '', 'echo "Use l to move!!"') +vim.keymap.set('n', '', 'echo "Use k to move!!"') +vim.keymap.set('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 +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' }) + +-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes +-- vim.keymap.set("n", "", "H", { desc = "Move window to the left" }) +-- vim.keymap.set("n", "", "L", { desc = "Move window to the right" }) +-- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) +-- vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) diff --git a/lua/core/options.lua b/lua/core/options.lua new file mode 100644 index 00000000..1b142614 --- /dev/null +++ b/lua/core/options.lua @@ -0,0 +1,44 @@ +-- [[ Setting options ]] +-- See `:help vim.o` +-- NOTE: You can change these options as you wish! +-- For more options, you can see `:help option-list` + +vim.o.number = true -- Make line numbers default +vim.o.relativenumber = true -- Add relative line numbers +vim.o.mouse = 'a' -- Enable mouse mode, can be useful for resizing splits for example! +vim.o.showmode = false -- Don't show the mode, since it's already in the status line +vim.o.breakindent = true -- Enable break indent +vim.o.undofile = true -- Save undo history +vim.o.ignorecase = true -- Case-insensitive searching UNLESS \C or one or more capital letters in the search term +vim.o.smartcase = true -- Override 'ignorecase' if search pattern contains uppercase letters +vim.o.incsearch = true -- Show search matches as you type +vim.o.hlsearch = true -- Highlight all matches of the last search +vim.o.signcolumn = 'yes' -- Keep signcolumn on by default +vim.o.updatetime = 250 -- Decrease update time +vim.o.timeoutlen = 300 -- Decrease mapped sequence wait time +vim.o.splitright = true -- Configure how new splits should be opened +vim.o.splitbelow = true -- Configure how new splits should be opened + +-- Notice listchars is set using `vim.opt` instead of `vim.o`. +-- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables. +-- See `:help lua-options` +-- and `:help lua-options-guide` +vim.o.list = true +vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } + +-- Preview substitutions live, as you type! +vim.o.inccommand = 'split' +vim.o.cursorline = true -- Show which line your cursor is on +vim.o.scrolloff = 10 -- Minimal number of screen lines to keep above and below the cursor. + +-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), +-- instead raise a dialog asking if you wish to save the current file(s) +-- See `:help 'confirm'` +vim.o.confirm = true +vim.o.showmatch = true -- Highlight matching parentheses and brackets +vim.o.autoindent = true --Enable automatic indentation +vim.o.smartindent = true --Enable smart indentation +vim.o.shiftround = false --Round indent to multiple of 'hiftwidth' +vim.o.wrap = false -- Display lines as a long line. +vim.o.termguicolors = true --Allow 24-bit colors in the terminal +vim.opt.colorcolumn = '80' --make a coloured col at 80. diff --git a/lua/core/snippets.lua b/lua/core/snippets.lua new file mode 100644 index 00000000..4b8d1d58 --- /dev/null +++ b/lua/core/snippets.lua @@ -0,0 +1,13 @@ +-- [[ Basic Autocommands ]] +-- See `:help lua-guide-autocommands` + +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.hl.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.hl.on_yank() + end, +}) diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua new file mode 100644 index 00000000..ad7342ba --- /dev/null +++ b/lua/plugins/autopairs.lua @@ -0,0 +1,7 @@ +return { + -- Autoclose parentheses, brackets, quotes, etc. + 'windwp/nvim-autopairs', + event = 'InsertEnter', + config = true, + opts = {}, +} diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua new file mode 100644 index 00000000..1f14e2b1 --- /dev/null +++ b/lua/plugins/gitsigns.lua @@ -0,0 +1,53 @@ +-- Adds git related signs to the gutter, as well as utilities for managing changes +return { + 'lewis6991/gitsigns.nvim', + opts = { + signs = { + add = { text = '┃' }, + change = { text = '┃' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + untracked = { text = '┆' }, + }, + signs_staged = { + add = { text = '┃' }, + change = { text = '┃' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + untracked = { text = '┆' }, + }, + signs_staged_enable = true, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = true, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + follow_files = true, + }, + auto_attach = true, + attach_to_untracked = false, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + ignore_whitespace = false, + virt_text_priority = 100, + use_focus = true, + }, + current_line_blame_formatter = ', - ', + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, -- Disable if file is longer than this (in lines) + preview_config = { + -- Options passed to nvim_open_win + style = 'minimal', + relative = 'cursor', + row = 0, + col = 1, + }, + }, +} diff --git a/lua/plugins/indent-blankline.lua b/lua/plugins/indent-blankline.lua new file mode 100644 index 00000000..27e44089 --- /dev/null +++ b/lua/plugins/indent-blankline.lua @@ -0,0 +1,25 @@ +return { + 'lukas-reineke/indent-blankline.nvim', + main = 'ibl', + opts = { + indent = { + char = '▏', + }, + scope = { + show_start = false, + show_end = false, + show_exact_scope = false, + }, + exclude = { + filetypes = { + 'help', + 'startify', + 'dashboard', + 'packer', + 'neogitstatus', + 'NvimTree', + 'Trouble', + }, + }, + }, +} diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua new file mode 100644 index 00000000..c7067891 --- /dev/null +++ b/lua/plugins/neo-tree.lua @@ -0,0 +1,25 @@ +-- 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 = '*', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended + 'MunifTanjim/nui.nvim', + }, + lazy = false, + keys = { + { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, + }, + opts = { + filesystem = { + window = { + mappings = { + ['\\'] = 'close_window', + }, + }, + }, + }, +}