diff --git a/init.lua b/init.lua index 220d3045268..823232b3583 100644 --- a/init.lua +++ b/init.lua @@ -90,8 +90,8 @@ P.S. You can delete this when you're done too. It's your config now! :) 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 +-- Set to true if you have a Nerd Font installed +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' @@ -119,7 +119,8 @@ vim.schedule(function() end) -- Enable break indent -vim.opt.breakindent = true +vim.opt.autoindent = false +vim.opt.breakindent = false -- Save undo history vim.opt.undofile = true @@ -157,6 +158,9 @@ vim.opt.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. vim.opt.scrolloff = 10 +-- Shorten tabstop due to forced use of tabs in golang projects +vim.o.tabstop = 4 + -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` @@ -190,6 +194,24 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the right win vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +-- Keybinds for Gitsigns +vim.keymap.set('n', 'gp', 'Gitsigns preview_hunk', { desc = 'Preview git hunk' }) +vim.keymap.set('n', 'gs', 'Gitsigns toggle_current_line_blame', { desc = 'Preview git hunk' }) + +-- Organise imports +local function organize_imports() + local params = { + command = '_typescript.organizeImports', + arguments = { vim.api.nvim_buf_get_name(0) }, + title = '', + } + vim.lsp.buf.execute_command(params) +end + +vim.keymap.set('n', 'gO', 'OrganizeImports', { desc = 'Organize imports' }) + +vim.keymap.set('n', 'U', vim.cmd.UndotreeToggle) + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -204,6 +226,9 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +-- Filetype configs +vim.filetype.add { extension = { templ = 'templ' } } + -- [[ 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' @@ -245,15 +270,7 @@ require('lazy').setup({ -- See `:help gitsigns` to understand what the configuration keys do { -- Adds git related signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', - opts = { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - }, + opts = {}, }, -- NOTE: Plugins can also be configured to run Lua code when they are loaded. @@ -352,7 +369,28 @@ require('lazy').setup({ -- i = { [''] = 'to_fuzzy_refine' }, -- }, -- }, - -- pickers = {} + pickers = { + find_files = { + find_command = { + 'rg', + '--no-ignore', + '--hidden', + '--files', + '-g', + '!**/node_modules/*', + '-g', + '!**/dist/*', + '-g', + '!**/.git/*', + '-g', + '!**/build/*', + '-g', + '!**/vendor/*', + '-g', + '!**/results/*', + }, + }, + }, extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown(), @@ -480,7 +518,7 @@ require('lazy').setup({ map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') -- Find references for the word under your cursor. - map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + map('gr', 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. @@ -571,6 +609,16 @@ require('lazy').setup({ local servers = { -- clangd = {}, -- gopls = {}, + templ = { + filetypes = { 'html', 'templ' }, + }, + html = { + filetypes = { 'html', 'templ' }, + }, + tailwindcss = { + filetypes = { 'html', 'templ' }, + init_options = { userLanguages = { temp = 'html' } }, + }, -- pyright = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs @@ -579,8 +627,30 @@ require('lazy').setup({ -- https://github.com/pmizio/typescript-tools.nvim -- -- But for many setups, the LSP (`tsserver`) will work just fine - -- tsserver = {}, - -- + ts_ls = { + init_options = { + maxTsServerMemory = 8192, + }, + + commands = { + OrganizeImports = { + organize_imports, + description = 'Organize Imports', + }, + }, + on_exit = function(_, code) + if code ~= 0 then + -- Restart tsserver if it exits with a non-zero exit code + vim.lsp.start_client { + name = 'tsserver', + cmd = { 'typescript-language-server', '--stdio' }, + } + end + end, + flags = { + debounce_text_changes = 150, + }, + }, lua_ls = { -- cmd = {...}, @@ -629,6 +699,22 @@ require('lazy').setup({ end, }, + { + 'mistricky/codesnap.nvim', + build = 'make', + keys = { + { 'cc', 'CodeSnap', mode = 'x', desc = 'Save selected code snapshot into clipboard' }, + { 'cs', 'CodeSnapSave', mode = 'x', desc = 'Save selected code snapshot into ~/Pictures' }, + }, + opts = { + save_path = '~/Pictures', + has_breadcrumbs = true, + has_line_number = true, + bg_theme = 'dusk', + watermark = '', + }, + }, + { -- Autoformat 'stevearc/conform.nvim', event = { 'BufWritePre' }, @@ -644,12 +730,12 @@ require('lazy').setup({ }, }, opts = { - notify_on_error = false, + log_level = vim.log.levels.DEBUG, 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 -- languages here or re-enable it for the disabled ones. - local disable_filetypes = { c = true, cpp = true } + local disable_filetypes = { c = true, cpp = true, tsx = true, ts = true, typescript = true } return { timeout_ms = 500, lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], @@ -662,6 +748,12 @@ require('lazy').setup({ -- -- You can use 'stop_after_first' to run the first available formatter from the list -- javascript = { "prettierd", "prettier", stop_after_first = true }, + json = { 'prettier' }, + typescript = { 'prettier' }, + typescriptreact = { 'prettier' }, + javascript = { 'prettier' }, + javascriptreact = { 'prettier' }, + solidity = { 'prettier' }, }, }, }, @@ -782,26 +874,25 @@ require('lazy').setup({ 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. - -- - -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', - priority = 1000, -- Make sure to load this before all the other start plugins. - init = function() - -- 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' - - -- You can configure highlights by doing something like: - vim.cmd.hi 'Comment gui=none' + { + 'catppuccin/nvim', + name = 'catppuccin', + priority = 1000, + config = function() + -- This is the function that runs, AFTER loading + require('catppuccin').setup { flavour = 'mocha' } + + vim.cmd.colorscheme 'catppuccin' end, }, -- Highlight todo, notes, etc in comments - { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, + { + 'folke/todo-comments.nvim', + event = 'VimEnter', + dependencies = { 'nvim-lua/plenary.nvim' }, + opts = { signs = false }, + }, { -- Collection of various small independent plugins/modules 'echasnovski/mini.nvim', @@ -844,7 +935,20 @@ require('lazy').setup({ 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + ensure_installed = { + 'bash', + 'c', + 'diff', + 'html', + 'lua', + 'luadoc', + 'markdown', + 'markdown_inline', + 'query', + 'vim', + 'vimdoc', + 'templ', + }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -852,9 +956,9 @@ 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', 'templ' }, }, - indent = { enable = true, disable = { 'ruby' } }, + indent = { enable = true, disable = { 'ruby', 'typescript', 'javascript' } }, }, config = function(_, opts) -- [[ Configure Treesitter ]] See `:help nvim-treesitter` @@ -886,13 +990,19 @@ require('lazy').setup({ -- require 'kickstart.plugins.autopairs', -- require 'kickstart.plugins.neo-tree', -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + { + 'tpope/vim-fugitive', + name = 'vim-fugitive', + }, + + { 'mbbill/undotree', name = 'undotree' }, -- 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. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000000..5eacc3126b6 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,40 @@ +{ + "LuaSnip": { "branch": "master", "commit": "de10d8414235b0a8cabfeba60d07c24304e71f5c" }, + "avante.nvim": { "branch": "main", "commit": "9a7793461549939f1d52b2b309a1aa44680170c8" }, + "catppuccin": { "branch": "main", "commit": "6d4e80f8bde41b893c9bc7b07460af3155a3adfa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, + "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "codesnap.nvim": { "branch": "main", "commit": "0a0941340376439a25d6cd8a4d1d2b372edbfdbd" }, + "conform.nvim": { "branch": "master", "commit": "086a40dc7ed8242c03be9f47fbcee68699cc2395" }, + "copilot.lua": { "branch": "master", "commit": "e73fe7c43c68aeb84fbeed12ee6cc60a29e78fbb" }, + "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, + "fidget.nvim": { "branch": "main", "commit": "7fa433a83118a70fe24c1ce88d5f0bd3453c0970" }, + "fzf-lua": { "branch": "main", "commit": "30ba09afbc0eac5fc5ec8823418d1e45d0712b9f" }, + "gitsigns.nvim": { "branch": "main", "commit": "7c4faa3540d0781a28588cafbd4dd187a28ac6e3" }, + "harpoon": { "branch": "master", "commit": "1bc17e3e42ea3c46b33c0bbad6a880792692a1b3" }, + "img-clip.nvim": { "branch": "main", "commit": "b6ddfb97b5600d99afe3452d707444afda658aca" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lazydev.nvim": { "branch": "main", "commit": "5231c62aa83c2f8dc8e7ba957aa77098cda1257d" }, + "luvit-meta": { "branch": "main", "commit": "cc9b2d412d2fbd30b94a70cfc214c2a3be27a0a2" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "a676ab7282da8d651e175118bcf54483ca11e46d" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc" }, + "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, + "mini.nvim": { "branch": "main", "commit": "9990c41f10f54f29a888d13024c9f765037bde23" }, + "mini.pick": { "branch": "main", "commit": "8521fe21df86e08d9e4b3c3f3a7d50e47954e1af" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" }, + "nvim-lspconfig": { "branch": "master", "commit": "0203a9608d63eda57679b01e69f33a7b4c34b0d1" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-web-devicons": { "branch": "master", "commit": "d7462543c9e366c0d196c7f67a945eaaf5d99414" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "render-markdown.nvim": { "branch": "main", "commit": "e3c18ddd27a853f85a6f513a864cf4f2982b9f26" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, + "undotree": { "branch": "master", "commit": "6fa6b57cda8459e1e4b2ca34df702f55242f4e4d" }, + "vim-fugitive": { "branch": "master", "commit": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0" }, + "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, + "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } +} diff --git a/lua/custom/plugins/avante.lua b/lua/custom/plugins/avante.lua new file mode 100644 index 00000000000..95f3a8093b4 --- /dev/null +++ b/lua/custom/plugins/avante.lua @@ -0,0 +1,51 @@ +return { + 'yetone/avante.nvim', + event = 'VeryLazy', + version = false, -- Never set this value to "*"! Never! + opts = { + -- add any opts here + -- for example + provider = 'copilot', + }, + -- if you want to build from source then do `make BUILD_FROM_SOURCE=true` + build = 'make', + -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'stevearc/dressing.nvim', + 'nvim-lua/plenary.nvim', + 'MunifTanjim/nui.nvim', + --- The below dependencies are optional, + 'echasnovski/mini.pick', -- for file_selector provider mini.pick + 'nvim-telescope/telescope.nvim', -- for file_selector provider telescope + 'hrsh7th/nvim-cmp', -- autocompletion for avante commands and mentions + 'ibhagwan/fzf-lua', -- for file_selector provider fzf + 'nvim-tree/nvim-web-devicons', -- or echasnovski/mini.icons + 'zbirenbaum/copilot.lua', -- for providers='copilot' + { + -- support for image pasting + 'HakonHarnes/img-clip.nvim', + event = 'VeryLazy', + opts = { + -- recommended settings + default = { + embed_image_as_base64 = false, + prompt_for_file_name = false, + drag_and_drop = { + insert_mode = true, + }, + -- required for Windows users + use_absolute_path = true, + }, + }, + }, + { + -- Make sure to set this up properly if you have lazy=true + 'MeanderingProgrammer/render-markdown.nvim', + opts = { + file_types = { 'markdown', 'Avante' }, + }, + ft = { 'markdown', 'Avante' }, + }, + }, +} diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua new file mode 100644 index 00000000000..579d6d9440e --- /dev/null +++ b/lua/custom/plugins/harpoon.lua @@ -0,0 +1,28 @@ +-- lua/custom/plugins/harpoon.lua +return { + 'ThePrimeagen/harpoon', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + local harpoon = require 'harpoon' + harpoon.setup {} + + local mark = require 'harpoon.mark' + local ui = require 'harpoon.ui' + -- Harpoon keybinds + vim.keymap.set('n', 'a', mark.add_file, { desc = 'Add file to Harpoon' }) + vim.keymap.set('n', '', ui.toggle_quick_menu, { desc = 'Toggle Harpoon menu' }) + + vim.keymap.set('n', '1', function() + ui.nav_file(1) + end, { desc = 'Go to Harpoon file 1', noremap = true }) + vim.keymap.set('n', '2', function() + ui.nav_file(2) + end, { desc = 'Go to Harpoon file 2', noremap = true }) + vim.keymap.set('n', '3', function() + ui.nav_file(3) + end, { desc = 'Go to Harpoon file 3', noremap = true }) + vim.keymap.set('n', '4', function() + ui.nav_file(4) + end, { desc = 'Go to Harpoon file 4', noremap = true }) + end, +} diff --git a/lua/custom/plugins/learning.lua b/lua/custom/plugins/learning.lua new file mode 100644 index 00000000000..59177b7a449 --- /dev/null +++ b/lua/custom/plugins/learning.lua @@ -0,0 +1,10 @@ +-- lua/custom/plugins/learning.lua +return { + dir = '~/Developer/Personal/learning/nvim-plugins/first-plugin', + config = function() + vim.keymap.set('v', 'ai', function() + require('plugin').hello_world() + end) + end, + desc = 'My first nvim plugin that replaces text in visual mode from an external script/cli tool', +}