Skip to content

Commit

Permalink
init neovim config from kickstart
Browse files Browse the repository at this point in the history
  • Loading branch information
WendellXY committed Dec 29, 2024
1 parent db65812 commit a4c6f81
Show file tree
Hide file tree
Showing 20 changed files with 753 additions and 93 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[*.swift]
indent_style = space
[*]
indent_style = tab
indent_size = 2
tab_width = 2
insert_final_newline = true
Expand Down
2 changes: 1 addition & 1 deletion .stylua.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
column_width = 120
line_endings = "Unix"
indent_type = "Spaces"
indent_type = "Tabs"
indent_width = 2
quote_style = "AutoPreferDouble"
call_parentheses = "None"
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"stylua.targetReleaseVersion": "latest"
}
24 changes: 13 additions & 11 deletions nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ vim.opt.mouse = "a"
vim.opt.showmode = false

vim.schedule(function()
vim.opt.clipboard = 'unnamedplus'
vim.opt.clipboard = "unnamedplus"
end)

vim.opt.breakindent = true
Expand All @@ -21,7 +21,7 @@ vim.opt.undofile = true
vim.opt.ignorecase = true
vim.opt.smartcase = true

vim.opt.signcolumn = 'yes'
vim.opt.signcolumn = "yes"

vim.opt.updatetime = 250

Expand All @@ -31,21 +31,23 @@ vim.opt.splitright = true
vim.opt.splitbelow = true

vim.opt.list = true
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '' }
vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "" }

vim.opt.inccommand = 'split'
vim.opt.inccommand = "split"

vim.opt.cursorline = true

vim.opt.scrolloff = 10

-- Highlight when yanking (copying) text
vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text',
group = vim.api.nvim_create_augroup('highlight-yank', { clear = true }),
callback = function()
vim.highlight.on_yank()
end,
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking (copying) text",
group = vim.api.nvim_create_augroup("highlight-yank", { clear = true }),
callback = function()
vim.highlight.on_yank()
end,
})

require("config.lazy")
require "config.lazy"

require "config.keymaps"
28 changes: 27 additions & 1 deletion nvim/lazy-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
{
"LuaSnip": { "branch": "master", "commit": "33b06d72d220aa56a7ce80a0dd6f06c70cd82b9d" },
"auto-dark-mode.nvim": { "branch": "master", "commit": "4531f8b2b09ed8f0b8875a706419f9cecda1d969" },
"catppuccin": { "branch": "main", "commit": "f67b886d65a029f12ffa298701fb8f1efd89295d" },
"lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }
"cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"conform.nvim": { "branch": "master", "commit": "9180320205d250429f0f80e073326c674e2a7149" },
"fidget.nvim": { "branch": "main", "commit": "9238947645ce17d96f30842e61ba81147185b657" },
"gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" },
"lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" },
"lazydev.nvim": { "branch": "main", "commit": "8620f82ee3f59ff2187647167b6b47387a13a018" },
"luvit-meta": { "branch": "main", "commit": "57d464c4acb5c2e66bd4145060f5dc9e96a7bbb7" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "c6c686781f9841d855bf1b926e10aa5e19430a38" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"mini.nvim": { "branch": "main", "commit": "2faada1cffce5609d78ac5e81eaf3754e0476758" },
"neo-tree.nvim": { "branch": "v3.x", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" },
"nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" },
"nvim-cmp": { "branch": "main", "commit": "b555203ce4bd7ff6192e759af3362f9d217e8c89" },
"nvim-lspconfig": { "branch": "master", "commit": "8b15a1a597a59f4f5306fad9adfe99454feab743" },
"nvim-treesitter": { "branch": "master", "commit": "046b8e936142ca7d0285c807201965ae4916bf01" },
"nvim-web-devicons": { "branch": "master", "commit": "63f552a7f59badc6e6b6d22e603150f0d5abebb7" },
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" },
"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": "8ab96b38a2530eacba5be717f52e04601eb59326" }
}
9 changes: 9 additions & 0 deletions nvim/lua/config/keymaps.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- Helper function for setting keymaps
local function map(mode, key, command, desc)
vim.keymap.set(mode, key, command, { desc = desc })
end

-- File Management Keymaps
map('n', '<C-n>', ':Neotree toggle<CR>', 'Toggle Neo-tree')
map('n', '<leader>nf', '::Neotree focus<CR>', 'Focus Neo-tree')

117 changes: 117 additions & 0 deletions nvim/lua/plugins/autocompletion.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
return {
{ -- Autocompletion
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
-- Snippet Engine & its associated nvim-cmp source
{
"L3MON4D3/LuaSnip",
build = (function()
-- Build Step is needed for regex support in snippets.
-- This step is not supported in many windows environments.
-- Remove the below condition to re-enable on windows.
if vim.fn.has "win32" == 1 or vim.fn.executable "make" == 0 then
return
end
return "make install_jsregexp"
end)(),
dependencies = {
-- `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,
-- },
},
},
"saadparwaiz1/cmp_luasnip",

-- Adds other completion capabilities.
-- nvim-cmp does not ship with all sources by default. They are split
-- into multiple repos for maintenance purposes.
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-path",
},
config = function()
-- See `:help cmp`
local cmp = require "cmp"
local luasnip = require "luasnip"
luasnip.config.setup {}

cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
completion = { completeopt = "menu,menuone,noinsert" },

-- For an understanding of why these mappings were
-- chosen, you will need to read `:help ins-completion`
--
-- No, but seriously. Please read `:help ins-completion`, it is really good!
mapping = cmp.mapping.preset.insert {
-- Select the [n]ext item
["<C-n>"] = cmp.mapping.select_next_item(),
-- Select the [p]revious item
["<C-p>"] = cmp.mapping.select_prev_item(),

-- Scroll the documentation window [b]ack / [f]orward
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),

-- Accept ([y]es) the completion.
-- This will auto-import if your LSP supports it.
-- This will expand snippets if the LSP sent a snippet.
["<C-y>"] = cmp.mapping.confirm { select = true },

-- If you prefer more traditional completion keymaps,
-- you can uncomment the following lines
--['<CR>'] = cmp.mapping.confirm { select = true },
--['<Tab>'] = cmp.mapping.select_next_item(),
--['<S-Tab>'] = cmp.mapping.select_prev_item(),

-- Manually trigger a completion from nvim-cmp.
-- Generally you don't need this, because nvim-cmp will display
-- completions whenever it has completion options available.
["<C-Space>"] = cmp.mapping.complete {},

-- Think of <c-l> as moving to the right of your snippet expansion.
-- So if you have a snippet that's like:
-- function $name($args)
-- $body
-- end
--
-- <c-l> will move you to the right of each of the expansion locations.
-- <c-h> is similar, except moving you backwards.
["<C-l>"] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
end
end, { "i", "s" }),
["<C-h>"] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
end
end, { "i", "s" }),

-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
},
sources = {
{
name = "lazydev",
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
group_index = 0,
},
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "path" },
},
}
end,
},
}
34 changes: 34 additions & 0 deletions nvim/lua/plugins/autoformat.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
return {
{ -- Autoformat
"stevearc/conform.nvim",
event = { "BufWritePre" },
cmd = { "ConformInfo" },
opts = {
notify_on_error = false,
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 lsp_format_opt
if disable_filetypes[vim.bo[bufnr].filetype] then
lsp_format_opt = "never"
else
lsp_format_opt = "fallback"
end
return {
timeout_ms = 500,
lsp_format = lsp_format_opt,
}
end,
formatters_by_ft = {
lua = { "stylua" },
-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
-- You can use 'stop_after_first' to run the first available formatter from the list
-- javascript = { "prettierd", "prettier", stop_after_first = true },
},
},
},
}
115 changes: 115 additions & 0 deletions nvim/lua/plugins/basics.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
return {
"tpope/vim-sleuth", -- Detect tabstop and shiftwidth automatically
"lewis6991/gitsigns.nvim", -- Adds git related signs to the gutter, as well as utilities for managing changes
{ -- Useful plugin to show you pending keybinds.
"folke/which-key.nvim",
event = "VimEnter", -- Sets the loading event to 'VimEnter'
opts = {
icons = {
-- set icon mappings to true if you have a Nerd Font
mappings = vim.g.have_nerd_font,
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
-- default which-key.nvim defined Nerd Font icons, otherwise define a string table
keys = vim.g.have_nerd_font and {} or {
Up = "<Up> ",
Down = "<Down> ",
Left = "<Left> ",
Right = "<Right> ",
C = "<C-…> ",
M = "<M-…> ",
D = "<D-…> ",
S = "<S-…> ",
CR = "<CR> ",
Esc = "<Esc> ",
ScrollWheelDown = "<ScrollWheelDown> ",
ScrollWheelUp = "<ScrollWheelUp> ",
NL = "<NL> ",
BS = "<BS> ",
Space = "<Space> ",
Tab = "<Tab> ",
F1 = "<F1>",
F2 = "<F2>",
F3 = "<F3>",
F4 = "<F4>",
F5 = "<F5>",
F6 = "<F6>",
F7 = "<F7>",
F8 = "<F8>",
F9 = "<F9>",
F10 = "<F10>",
F11 = "<F11>",
F12 = "<F12>",
},
},

-- Document existing key chains
spec = {
{ "<leader>c", group = "[C]ode", mode = { "n", "x" } },
{ "<leader>d", group = "[D]ocument" },
{ "<leader>r", group = "[R]ename" },
{ "<leader>s", group = "[S]earch" },
{ "<leader>w", group = "[W]orkspace" },
{ "<leader>t", group = "[T]oggle" },
{ "<leader>h", group = "Git [H]unk", mode = { "n", "v" } },
},
},
},
{
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
-- used for completion, annotations and signatures of Neovim apis
"folke/lazydev.nvim",
ft = "lua",
opts = {
library = {
-- Load luvit types when the `vim.uv` word is found
{ path = "luvit-meta/library", words = { "vim%.uv" } },
},
},
},
{ "Bilal2453/luvit-meta", lazy = true },
-- Highlight todo, notes, etc in comments
{
"folke/todo-comments.nvim",
event = "VimEnter",
dependencies = { "nvim-lua/plenary.nvim" },
opts = { signs = false },
},

{ -- Collection of various small independent plugins/modules
"echasnovski/mini.nvim",
config = function()
-- Better Around/Inside textobjects
--
-- Examples:
-- - va) - [V]isually select [A]round [)]paren
-- - yinq - [Y]ank [I]nside [N]ext [Q]uote
-- - ci' - [C]hange [I]nside [']quote
require("mini.ai").setup { n_lines = 500 }

-- Add/delete/replace surroundings (brackets, quotes, etc.)
--
-- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
-- - sd' - [S]urround [D]elete [']quotes
-- - sr)' - [S]urround [R]eplace [)] [']
require("mini.surround").setup()

-- Simple and easy statusline.
-- You could remove this setup call if you don't like it,
-- and try some other statusline plugin
local statusline = require "mini.statusline"
-- set use_icons to true if you have a Nerd Font
statusline.setup { use_icons = vim.g.have_nerd_font }

-- You can configure sections in the statusline by overriding their
-- default behavior. For example, here we set the section for
-- cursor location to LINE:COLUMN
---@diagnostic disable-next-line: duplicate-set-field
statusline.section_location = function()
return "%2l:%-2v"
end

-- ... and there is more!
-- Check out: https://github.com/echasnovski/mini.nvim
end,
},
}
Loading

0 comments on commit a4c6f81

Please sign in to comment.