Compare commits

...

2 Commits

Author SHA1 Message Date
4a51d27a4e Track lazy-lock.json 2024-10-16 22:18:18 +08:00
ef5b599b8b Add own customisation + harpoon 2024-10-16 22:15:21 +08:00
3 changed files with 105 additions and 31 deletions

2
.gitignore vendored
View File

@ -4,4 +4,4 @@ test.sh
nvim nvim
spell/ spell/
lazy-lock.json #lazy-lock.json

106
init.lua
View File

@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
vim.opt.number = true vim.opt.number = true
-- You can also add relative line numbers, to help with jumping. -- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it! -- 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! -- Enable mouse mode, can be useful for resizing splits for example!
vim.opt.mouse = 'a' vim.opt.mouse = 'a'
@ -185,10 +185,13 @@ vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' }
-- Use CTRL+<hjkl> to switch between windows -- Use CTRL+<hjkl> to switch between windows
-- --
-- See `:help wincmd` for a list of all window commands -- See `:help wincmd` for a list of all window commands
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' }) --vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' }) --vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' }) --vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' }) --vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
-- Open file explorer
vim.keymap.set('n', '<leader>pv', vim.cmd.Ex, { desc = 'File explorer' })
-- [[ Basic Autocommands ]] -- [[ Basic Autocommands ]]
-- See `:help lua-guide-autocommands` -- See `:help lua-guide-autocommands`
@ -316,11 +319,11 @@ require('lazy').setup({
spec = { spec = {
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } }, { '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
{ '<leader>d', group = '[D]ocument' }, { '<leader>d', group = '[D]ocument' },
{ '<leader>r', group = '[R]ename' }, { '<leader>f', group = '[F]ind' },
{ '<leader>s', group = '[S]earch' },
{ '<leader>w', group = '[W]orkspace' }, { '<leader>w', group = '[W]orkspace' },
{ '<leader>t', group = '[T]oggle' }, { '<leader>l', group = '[L]SP Options' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } }, { '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
{ '<leader>m', group = '[M]iscellaneous', mode = { 'n', 'v' } },
}, },
}, },
}, },
@ -401,15 +404,15 @@ require('lazy').setup({
-- See `:help telescope.builtin` -- See `:help telescope.builtin`
local builtin = require 'telescope.builtin' local builtin = require 'telescope.builtin'
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = '[F]ind [H]elp' })
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) vim.keymap.set('n', '<leader>fk', builtin.keymaps, { desc = '[F]ind [K]eymaps' })
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = '[F]ind [F]iles' })
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', '<leader>fs', builtin.builtin, { desc = '[F]ind [S]elect Telescope' })
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', '<leader>fw', builtin.grep_string, { desc = '[F]ind current [W]ord' })
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = '[F]ind by [G]rep' })
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', '<leader>fd', builtin.diagnostics, { desc = '[F]ind [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' }) vim.keymap.set('n', '<leader>fr', builtin.resume, { desc = '[F]ind [R]esume' })
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set('n', '<leader>f.', builtin.oldfiles, { desc = '[F]ind Recent Files ("." for repeat)' })
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' }) vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
-- Slightly advanced example of overriding default behavior and theme -- Slightly advanced example of overriding default behavior and theme
@ -423,17 +426,17 @@ require('lazy').setup({
-- It's also possible to pass additional configuration options. -- It's also possible to pass additional configuration options.
-- See `:help telescope.builtin.live_grep()` for information about particular keys -- See `:help telescope.builtin.live_grep()` for information about particular keys
vim.keymap.set('n', '<leader>s/', function() vim.keymap.set('n', '<leader>f/', function()
builtin.live_grep { builtin.live_grep {
grep_open_files = true, grep_open_files = true,
prompt_title = 'Live Grep in Open Files', 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 -- Shortcut for searching your Neovim configuration files
vim.keymap.set('n', '<leader>sn', function() vim.keymap.set('n', '<leader>fn', function()
builtin.find_files { cwd = vim.fn.stdpath 'config' } builtin.find_files { cwd = vim.fn.stdpath 'config' }
end, { desc = '[S]earch [N]eovim files' }) end, { desc = '[F]ind [N]eovim files' })
end, end,
}, },
@ -537,7 +540,7 @@ require('lazy').setup({
-- Rename the variable under your cursor. -- Rename the variable under your cursor.
-- Most Language Servers support renaming across files, etc. -- Most Language Servers support renaming across files, etc.
map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame') map('<leader>lr', vim.lsp.buf.rename, '[L]SP [R]ename')
-- Execute a code action, usually your cursor needs to be on top of an error -- 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. -- or a suggestion from your LSP for this to activate.
@ -581,9 +584,9 @@ require('lazy').setup({
-- --
-- This may be unwanted, since they displace some of your code -- This may be unwanted, since they displace some of your code
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
map('<leader>th', function() map('<leader>lh', function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
end, '[T]oggle Inlay [H]ints') end, 'LSP Toggle Inlay [H]ints')
end end
end, end,
}) })
@ -671,7 +674,7 @@ require('lazy').setup({
cmd = { 'ConformInfo' }, cmd = { 'ConformInfo' },
keys = { keys = {
{ {
'<leader>f', '<leader>o',
function() function()
require('conform').format { async = true, lsp_format = 'fallback' } require('conform').format { async = true, lsp_format = 'fallback' }
end, end,
@ -685,7 +688,8 @@ require('lazy').setup({
-- Disable "format_on_save lsp_fallback" for languages that don't -- Disable "format_on_save lsp_fallback" for languages that don't
-- have a well standardized coding style. You can add additional -- have a well standardized coding style. You can add additional
-- languages here or re-enable it for the disabled ones. -- languages here or re-enable it for the disabled ones.
local disable_filetypes = { c = true, cpp = true } --local disable_filetypes = { c = true, cpp = true }
local disable_filetypes = {}
local lsp_format_opt local lsp_format_opt
if disable_filetypes[vim.bo[bufnr].filetype] then if disable_filetypes[vim.bo[bufnr].filetype] then
lsp_format_opt = 'never' lsp_format_opt = 'never'
@ -704,6 +708,13 @@ require('lazy').setup({
-- --
-- You can use 'stop_after_first' to run the first available formatter from the list -- You can use 'stop_after_first' to run the first available formatter from the list
-- javascript = { "prettierd", "prettier", stop_after_first = true }, -- javascript = { "prettierd", "prettier", stop_after_first = true },
c = { 'astyle' },
cpp = { 'astyle' },
},
formatters = {
astyle = {
prepend_args = { '--project' },
},
}, },
}, },
}, },
@ -756,7 +767,7 @@ require('lazy').setup({
luasnip.lsp_expand(args.body) luasnip.lsp_expand(args.body)
end, end,
}, },
completion = { completeopt = 'menu,menuone,noinsert' }, completion = { completeopt = 'menu,menuone,noinsert,noselect' },
-- For an understanding of why these mappings were -- For an understanding of why these mappings were
-- chosen, you will need to read `:help ins-completion` -- chosen, you will need to read `:help ins-completion`
@ -829,13 +840,13 @@ require('lazy').setup({
-- change the command in the config to whatever the name of that colorscheme is. -- 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`. -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
'folke/tokyonight.nvim', 'ellisonleao/gruvbox.nvim',
priority = 1000, -- Make sure to load this before all the other start plugins. priority = 1000, -- Make sure to load this before all the other start plugins.
init = function() init = function()
-- Load the colorscheme here. -- Load the colorscheme here.
-- Like many other themes, this one has different styles, and you could load -- Like many other themes, this one has different styles, and you could load
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
vim.cmd.colorscheme 'tokyonight-night' vim.cmd.colorscheme 'gruvbox'
-- You can configure highlights by doing something like: -- You can configure highlights by doing something like:
vim.cmd.hi 'Comment gui=none' vim.cmd.hi 'Comment gui=none'
@ -861,7 +872,7 @@ require('lazy').setup({
-- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
-- - sd' - [S]urround [D]elete [']quotes -- - sd' - [S]urround [D]elete [']quotes
-- - sr)' - [S]urround [R]eplace [)] ['] -- - sr)' - [S]urround [R]eplace [)] [']
require('mini.surround').setup() --require('mini.surround').setup()
-- Simple and easy statusline. -- Simple and easy statusline.
-- You could remove this setup call if you don't like it, -- You could remove this setup call if you don't like it,
@ -930,6 +941,41 @@ require('lazy').setup({
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- 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` -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
-- { import = 'custom.plugins' }, -- { import = 'custom.plugins' },
{
'ThePrimeagen/harpoon',
config = function()
vim.keymap.set('n', '<leader>mq', function()
vim.cmd 'lua require("harpoon.ui").toggle_quick_menu()'
end, { desc = 'Harpoon Menu' })
vim.keymap.set('n', '<leader>mm', function()
vim.cmd 'lua require("harpoon.mark").add_file()'
end, { desc = 'Harpoon add file' })
vim.keymap.set('n', '<leader>a', function()
vim.cmd 'lua require("harpoon.ui").nav_file(1)'
end, { desc = 'Harpoon file 1' })
vim.keymap.set('n', '<leader>r', function()
vim.cmd 'lua require("harpoon.ui").nav_file(2)'
end, { desc = 'Harpoon file 2' })
vim.keymap.set('n', '<leader>s', function()
vim.cmd 'lua require("harpoon.ui").nav_file(3)'
end, { desc = 'Harpoon file 3' })
vim.keymap.set('n', '<leader>t', function()
vim.cmd 'lua require("harpoon.ui").nav_file(4)'
end, { desc = 'Harpoon file 4' })
vim.keymap.set('n', '<leader>ma', function()
vim.cmd 'lua require("harpoon.ui").nav_file(5)'
end, { desc = 'Harpoon file 5' })
vim.keymap.set('n', '<leader>mr', function()
vim.cmd 'lua require("harpoon.ui").nav_file(6)'
end, { desc = 'Harpoon file 6' })
vim.keymap.set('n', '<leader>ms', function()
vim.cmd 'lua require("harpoon.ui").nav_file(7)'
end, { desc = 'Harpoon file 7' })
vim.keymap.set('n', '<leader>mt', function()
vim.cmd 'lua require("harpoon.ui").nav_file(8)'
end, { desc = 'Harpoon file 8' })
end,
},
}, { }, {
ui = { ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the -- If you are using a Nerd Font: set icons to an empty table which will use the

28
lazy-lock.json Normal file
View File

@ -0,0 +1,28 @@
{
"LuaSnip": { "branch": "master", "commit": "e808bee352d1a6fcf902ca1a71cee76e60e24071" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "f5bd8419f8a29451e20bdb1061a54fe13d5c8de3" },
"fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" },
"gitsigns.nvim": { "branch": "main", "commit": "863903631e676b33e8be2acb17512fdc1b80b4fb" },
"gruvbox.nvim": { "branch": "main", "commit": "49d9c0b150ba70efcd831ec7b3cb8ee740067045" },
"harpoon": { "branch": "master", "commit": "1bc17e3e42ea3c46b33c0bbad6a880792692a1b3" },
"lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" },
"lazydev.nvim": { "branch": "main", "commit": "491452cf1ca6f029e90ad0d0368848fac717c6d2" },
"luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"mini.nvim": { "branch": "main", "commit": "d4ce7d025f9c7bb4d55ebc4fd88987651e632893" },
"nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" },
"nvim-lspconfig": { "branch": "master", "commit": "541f3a2781de481bb84883889e4d9f0904250a56" },
"nvim-treesitter": { "branch": "master", "commit": "92725df6222614307c4712eb9982e5287f21aa11" },
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
"telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" },
"vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" },
"which-key.nvim": { "branch": "main", "commit": "8badb359f7ab8711e2575ef75dfe6fbbd87e4821" }
}