mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 08:41:43 +05:30
feat(nvim): Align to Kickstart NVIM
This commit is contained in:
@@ -33,17 +33,14 @@
|
||||
require("config")
|
||||
|
||||
-- `:help lazy.nvim.txt` for more info
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
vim.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--filter=blob:none",
|
||||
"https://github.com/folke/lazy.nvim.git",
|
||||
"--branch=stable",
|
||||
lazypath,
|
||||
})
|
||||
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
|
||||
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
|
||||
if vim.v.shell_error ~= 0 then
|
||||
error('Error cloning lazy.nvim:\n' .. out)
|
||||
end
|
||||
end ---@diagnostic disable-next-line: undefined-field
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
-- You can also configure plugins after the setup call,
|
||||
|
||||
@@ -17,3 +17,8 @@ vim.opt.inccommand = "split" -- With :%s command, show the preview in a split in
|
||||
vim.opt.splitkeep = "screen"
|
||||
-- Fix markdown indentation settings
|
||||
vim.g.markdown_recommended_style = 0
|
||||
|
||||
vim.g.have_nerd_font = true
|
||||
|
||||
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
|
||||
vim.opt.inccommand = 'split'
|
||||
|
||||
@@ -5,10 +5,33 @@ return {
|
||||
{
|
||||
-- Autocompletion
|
||||
"hrsh7th/nvim-cmp",
|
||||
event = "InsertEnter",
|
||||
cond = require("config.util").is_not_vscode(),
|
||||
dependencies = {
|
||||
-- Snippet Engine & its associated nvim-cmp source
|
||||
"L3MON4D3/LuaSnip",
|
||||
{
|
||||
'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 LSP completion capabilities
|
||||
@@ -18,9 +41,6 @@ return {
|
||||
|
||||
"hrsh7th/cmp-vsnip",
|
||||
"hrsh7th/vim-vsnip",
|
||||
|
||||
-- Adds a number of user-friendly snippets
|
||||
"rafamadriz/friendly-snippets",
|
||||
},
|
||||
config = function()
|
||||
-- See `:help cmp`
|
||||
@@ -63,6 +83,19 @@ return {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
}),
|
||||
|
||||
-- <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' }),
|
||||
}),
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
|
||||
@@ -3,11 +3,8 @@ return {
|
||||
"stevearc/conform.nvim",
|
||||
-- cond = require("config.util").is_not_vscode(),
|
||||
lazy = true,
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
config = function()
|
||||
local conform = require("conform")
|
||||
|
||||
conform.setup({
|
||||
event = { "BufWritePre" },
|
||||
opts = {
|
||||
formatters_by_ft = {
|
||||
javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||
typescript = { "prettierd", "prettier", stop_after_first = true },
|
||||
@@ -27,12 +24,23 @@ return {
|
||||
zsh = { "shfmt", "shellharden", stop_after_first = true },
|
||||
["_"] = { "trim_whitespace" },
|
||||
},
|
||||
format_on_save = {
|
||||
lsp_fallback = true,
|
||||
async = false,
|
||||
timeout_ms = 3000,
|
||||
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 {
|
||||
quiet = false,
|
||||
},
|
||||
timeout_ms = 500,
|
||||
lsp_format = lsp_format_opt,
|
||||
}
|
||||
end,
|
||||
formatters = {
|
||||
injected = { options = { ignore_errors = true } },
|
||||
shfmt = {
|
||||
@@ -52,7 +60,6 @@ return {
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,29 +1,6 @@
|
||||
return {
|
||||
{ "tpope/vim-repeat" },
|
||||
|
||||
-- Better surround than tpope/vim-surround
|
||||
{
|
||||
"kylechui/nvim-surround",
|
||||
version = "*",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("nvim-surround").setup({})
|
||||
end,
|
||||
},
|
||||
|
||||
-- "gc" to comment visual regions/lines
|
||||
{
|
||||
"numToStr/Comment.nvim",
|
||||
cond = require("config.util").is_not_vscode(),
|
||||
config = function()
|
||||
require("Comment").setup({
|
||||
pre_hook = function()
|
||||
return vim.bo.commentstring
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- Better code folding
|
||||
{
|
||||
"kevinhwang91/nvim-ufo",
|
||||
@@ -107,13 +84,6 @@ return {
|
||||
end,
|
||||
},
|
||||
|
||||
-- auto pairs
|
||||
{
|
||||
"echasnovski/mini.pairs",
|
||||
event = "VeryLazy",
|
||||
opts = {},
|
||||
},
|
||||
|
||||
-- indent guides for Neovim
|
||||
{
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
@@ -140,6 +110,34 @@ return {
|
||||
main = "ibl",
|
||||
},
|
||||
|
||||
-- Collection of various small independent plugins/modules
|
||||
{
|
||||
"chasnovski/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()
|
||||
|
||||
require("mini.pairs").setup()
|
||||
require("mini.comment").setup()
|
||||
require("mini.completion").setup()
|
||||
|
||||
-- ... and there is more!
|
||||
-- Check out: https://github.com/echasnovski/mini.nvim
|
||||
end,
|
||||
},
|
||||
|
||||
-- Highlights the current level of indentation, and animates the highlighting.
|
||||
{
|
||||
"echasnovski/mini.indentscope",
|
||||
@@ -167,10 +165,11 @@ return {
|
||||
-- Finds and lists all of the TODO, HACK, BUG, etc comment
|
||||
{
|
||||
"folke/todo-comments.nvim",
|
||||
lazy = false,
|
||||
event = "VimEnter",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
config = true,
|
||||
opts = {
|
||||
signs = false,
|
||||
keywords = {
|
||||
HACK = { alt = { "TIP" } },
|
||||
},
|
||||
@@ -245,8 +244,6 @@ return {
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>o", "<cmd>Trouble symbols toggle preview.type=main focus=true<cr>", desc = "Code: Toggle Symbol Outline" },
|
||||
|
||||
{ "<leader>dd", "<cmd>Trouble project_errors toggle focus=true<cr>", desc = "Trouble: Document Diagnostics" },
|
||||
{ "<leader>dw", "<cmd>Trouble most_severe toggle focus=true<cr>", desc = "Trouble: List Project Diagnostics" },
|
||||
{ "<leader>dl", "<cmd>Trouble loclist toggle focus=true<cr>", desc = "Trouble: Location List" },
|
||||
@@ -333,8 +330,10 @@ return {
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<leader>cR", "<cmd>Lspsaga finder<cr>", { desc = "Code: Goto References" })
|
||||
vim.keymap.set("n", "<leader>cd", "<cmd>Lspsaga peek_definition<cr>", { desc = "Code: Peek definition: Function" })
|
||||
vim.keymap.set("n", "<leader>cD", "<cmd>Lspsaga peek_type_definition<cr>", { desc = "Code: Peek definition: Class" })
|
||||
vim.keymap.set("n", "<leader>cd", "<cmd>Lspsaga peek_definition<cr>",
|
||||
{ desc = "Code: Peek definition: Function" })
|
||||
vim.keymap.set("n", "<leader>cD", "<cmd>Lspsaga peek_type_definition<cr>",
|
||||
{ desc = "Code: Peek definition: Class" })
|
||||
|
||||
vim.keymap.set("n", "K", "<cmd>Lspsaga hover_doc<cr>", { desc = "Hover Documentation" })
|
||||
end,
|
||||
|
||||
@@ -11,7 +11,7 @@ return {
|
||||
config = true,
|
||||
keys = {
|
||||
{ "<leader>gg", "<cmd>Neogit<cr>", desc = "Git: Open Neogit", mode = { "n" } },
|
||||
{ "<leader>gL", "<cmd>Neogit log<cr>", desc = "Git: Open Neogit Log", mode = { "n" } },
|
||||
{ "<leader>gL", "<cmd>Neogit log<cr>", desc = "Git: Open Log", mode = { "n" } },
|
||||
},
|
||||
},
|
||||
|
||||
@@ -116,7 +116,8 @@ return {
|
||||
-- FIX: Open files do NOT get replaced with the changed branch
|
||||
require("telescope").load_extension("git_worktree")
|
||||
|
||||
vim.keymap.set("n", "<leader>gw", "<cmd> lua require('telescope').extensions.git_worktree.git_worktrees()<CR>")
|
||||
vim.keymap.set("n", "<leader>gw",
|
||||
"<cmd> lua require('telescope').extensions.git_worktree.git_worktrees()<CR>")
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -42,6 +42,9 @@ return {
|
||||
|
||||
-- Useful status updates for LSP
|
||||
{ "j-hui/fidget.nvim", opts = {} },
|
||||
|
||||
-- Allows extra capabilities provided by nvim-cmp
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -259,7 +259,8 @@ return {
|
||||
pcall(require("telescope").load_extension, "fzf")
|
||||
|
||||
-- Special Things: Telescope
|
||||
vim.keymap.set("n", "<leader>nc", require("telescope.builtin").colorscheme, { desc = "List Neovim Colorschemes (with preview)" })
|
||||
vim.keymap.set("n", "<leader>nc", require("telescope.builtin").colorscheme,
|
||||
{ desc = "List Neovim Colorschemes (with preview)" })
|
||||
|
||||
-- Grep things -> Search
|
||||
vim.keymap.set("n", "<leader>sb", function()
|
||||
|
||||
@@ -234,24 +234,62 @@ return {
|
||||
dependencies = {
|
||||
"echasnovski/mini.icons",
|
||||
},
|
||||
config = function()
|
||||
-- document existing key chains
|
||||
require("which-key").add({
|
||||
opts = {
|
||||
defaults = {
|
||||
["<leader>r"] = { name = "+refactor" },
|
||||
},
|
||||
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> ',
|
||||
Lefj = '<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 = "Code" },
|
||||
{ "<leader>b", group = "Buffer Operations" },
|
||||
{ "<leader>d", group = "Diagnostics" },
|
||||
{ "<leader>f", group = "File Operations" },
|
||||
{ "<leader>g", group = "Git" },
|
||||
{ "<leader>h", group = "Harpoon" },
|
||||
{ "<leader>l", group = "List Things" },
|
||||
{ "<leader>f", group = "Find and List Things" },
|
||||
{ "<leader>n", group = "NVIM Things" },
|
||||
{ "<leader>q", group = "Database Query" },
|
||||
{ "<leader>r", group = "Refactor Code" },
|
||||
{ "<leader>s", group = "Search/Grep Things" },
|
||||
{ "<leader>t", group = "Unit Test Operations" },
|
||||
{ "<leader>x", group = "Delete/Remove Something" },
|
||||
})
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Session management. Saves your session in the background
|
||||
|
||||
Reference in New Issue
Block a user