re-organized the dir and divided the init.lua into smaller plugins files
This commit is contained in:
parent
8bce42bec4
commit
8623090268
413
init.lua
413
init.lua
|
@ -1,12 +1,8 @@
|
||||||
-- Set <space> as the leader key
|
|
||||||
-- See `:help mapleader`
|
-- See `:help mapleader`
|
||||||
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
|
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
|
||||||
vim.g.mapleader = ' '
|
vim.g.mapleader = ' '
|
||||||
vim.g.maplocalleader = ' '
|
vim.g.maplocalleader = ' '
|
||||||
|
|
||||||
--import options
|
|
||||||
require('config.options')
|
|
||||||
|
|
||||||
-- Install package manager
|
-- Install package manager
|
||||||
-- https://github.com/folke/lazy.nvim
|
-- https://github.com/folke/lazy.nvim
|
||||||
-- `:help lazy.nvim.txt` for more info
|
-- `:help lazy.nvim.txt` for more info
|
||||||
|
@ -26,262 +22,22 @@ vim.opt.rtp:prepend(lazypath)
|
||||||
local opts = {
|
local opts = {
|
||||||
git = { log = { '--since=3 days ago' } },
|
git = { log = { '--since=3 days ago' } },
|
||||||
ui = { custom_keys = { false } },
|
ui = { custom_keys = { false } },
|
||||||
performance = {
|
|
||||||
rtp = {
|
|
||||||
disabled_plugins = {
|
|
||||||
'gzip',
|
|
||||||
-- 'netrwPlugin',
|
|
||||||
'tarPlugin',
|
|
||||||
'tohtml',
|
|
||||||
'tutor',
|
|
||||||
'zipPlugin',
|
|
||||||
'rplugin',
|
|
||||||
'editorconfig',
|
|
||||||
'matchparen',
|
|
||||||
'matchit',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
checker = { enabled = false },
|
checker = { enabled = false },
|
||||||
|
colorscheme = "monokai",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- NOTE: Here is where you install your plugins.
|
|
||||||
-- You can configure plugins using the `config` key.
|
|
||||||
--
|
|
||||||
-- You can also configure plugins after the setup call,
|
|
||||||
-- as they will be available in your neovim runtime.
|
|
||||||
require('lazy').setup({
|
require('lazy').setup({
|
||||||
-- NOTE: First, some plugins that don't require any configuration
|
|
||||||
|
|
||||||
-- Git related plugins
|
-- Git related plugins
|
||||||
'tpope/vim-fugitive',
|
'tpope/vim-fugitive',
|
||||||
'tpope/vim-rhubarb',
|
'tpope/vim-rhubarb',
|
||||||
|
|
||||||
-- Detect tabstop and shiftwidth automatically
|
-- Detect tabstop and shiftwidth automatically
|
||||||
'tpope/vim-sleuth',
|
'tpope/vim-sleuth',
|
||||||
|
|
||||||
-- NOTE: This is where your plugins related to LSP can be installed.
|
|
||||||
-- The configuration is done below. Search for lspconfig to find it below.
|
|
||||||
{
|
|
||||||
-- LSP Configuration & Plugin
|
|
||||||
'neovim/nvim-lspconfig',
|
|
||||||
dependencies = {
|
|
||||||
-- Automatically install LSPs to stdpath for neovim
|
|
||||||
{ 'williamboman/mason.nvim', config = true },
|
|
||||||
'williamboman/mason-lspconfig.nvim',
|
|
||||||
'WhoIsSethDaniel/mason-tool-installer.nvim',
|
|
||||||
|
|
||||||
-- Useful status updates for LSP
|
|
||||||
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
|
||||||
{
|
|
||||||
'j-hui/fidget.nvim',
|
|
||||||
tag = 'legacy',
|
|
||||||
opts = {}
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Additional lua configuration, makes nvim stuff amazing!
|
|
||||||
'folke/neodev.nvim',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
-- Autocompletion
|
|
||||||
'hrsh7th/nvim-cmp',
|
|
||||||
dependencies = {
|
|
||||||
-- Snippet Engine & its associated nvim-cmp source
|
|
||||||
'L3MON4D3/LuaSnip',
|
|
||||||
'saadparwaiz1/cmp_luasnip',
|
|
||||||
|
|
||||||
-- Adds LSP completion capabilities
|
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
|
||||||
|
|
||||||
-- Adds a number of user-friendly snippets
|
|
||||||
'rafamadriz/friendly-snippets',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Useful plugin to show you pending keybinds.
|
|
||||||
{
|
|
||||||
'folke/which-key.nvim',
|
|
||||||
opts = {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
-- Adds git related signs to the gutter, as well as utilities for managing changes
|
|
||||||
'lewis6991/gitsigns.nvim',
|
|
||||||
opts = {
|
|
||||||
-- See `:help gitsigns.txt`
|
|
||||||
signs = {
|
|
||||||
add = { text = '+' },
|
|
||||||
change = { text = '~' },
|
|
||||||
delete = { text = '_' },
|
|
||||||
topdelete = { text = '‾' },
|
|
||||||
changedelete = { text = '~' },
|
|
||||||
},
|
|
||||||
on_attach = function(bufnr)
|
|
||||||
vim.keymap.set('n', '<leader>hp', require('gitsigns').preview_hunk, { buffer = bufnr, desc = 'Preview git hunk' })
|
|
||||||
|
|
||||||
-- don't override the built-in and fugitive keymaps
|
|
||||||
local gs = package.loaded.gitsigns
|
|
||||||
vim.keymap.set({ 'n', 'v' }, ']c', function()
|
|
||||||
if vim.wo.diff then return ']c' end
|
|
||||||
vim.schedule(function() gs.next_hunk() end)
|
|
||||||
return '<Ignore>'
|
|
||||||
end, { expr = true, buffer = bufnr, desc = "Jump to next hunk" })
|
|
||||||
vim.keymap.set({ 'n', 'v' }, '[c', function()
|
|
||||||
if vim.wo.diff then return '[c' end
|
|
||||||
vim.schedule(function() gs.prev_hunk() end)
|
|
||||||
return '<Ignore>'
|
|
||||||
end, { expr = true, buffer = bufnr, desc = "Jump to previous hunk" })
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
'tanvirtin/monokai.nvim',
|
|
||||||
priority = 1000,
|
|
||||||
config = function()
|
|
||||||
vim.cmd.colorscheme('monokai')
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
|
|
||||||
-- {
|
|
||||||
-- Theme inspired by Atom
|
|
||||||
-- 'navarasu/onedark.nvim',
|
|
||||||
-- priority = 1000,
|
|
||||||
-- config = function()
|
|
||||||
-- vim.cmd.colorscheme 'onedark'
|
|
||||||
-- end,
|
|
||||||
-- },
|
|
||||||
|
|
||||||
{
|
|
||||||
-- Set lualine as statusline
|
|
||||||
'nvim-lualine/lualine.nvim',
|
|
||||||
-- See `:help lualine.txt`
|
|
||||||
opts = {
|
|
||||||
options = {
|
|
||||||
icons_enabled = false,
|
|
||||||
theme = 'onedark',
|
|
||||||
component_separators = '|',
|
|
||||||
section_separators = '',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
-- Add indentation guides even on blank lines
|
|
||||||
'lukas-reineke/indent-blankline.nvim',
|
|
||||||
-- Enable `lukas-reineke/indent-blankline.nvim`
|
|
||||||
-- See `:help indent_blankline.txt`
|
|
||||||
main = "ibl",
|
|
||||||
opts = {
|
|
||||||
indent = {
|
|
||||||
--[[ highlight = highlight ]]
|
|
||||||
char = "┆",
|
|
||||||
smart_indent_cap = true,
|
|
||||||
},
|
|
||||||
whitespace = {
|
|
||||||
--[[ highlight = highlight, ]]
|
|
||||||
remove_blankline_trail = false,
|
|
||||||
},
|
|
||||||
scope = { enabled = true },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
-- "gc" to comment visual regions/lines
|
|
||||||
{
|
|
||||||
'numToStr/Comment.nvim',
|
|
||||||
opts = {},
|
|
||||||
lazy = false
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Fuzzy Finder (files, lsp, etc)
|
|
||||||
{
|
|
||||||
'nvim-telescope/telescope.nvim',
|
|
||||||
branch = '0.1.x',
|
|
||||||
dependencies = {
|
|
||||||
'nvim-lua/plenary.nvim',
|
|
||||||
-- Fuzzy Finder Algorithm which requires local dependencies to be built.
|
|
||||||
-- Only load if `make` is available. Make sure you have the system
|
|
||||||
-- requirements installed.
|
|
||||||
{
|
|
||||||
'nvim-telescope/telescope-fzf-native.nvim',
|
|
||||||
-- NOTE: If you are having trouble with this installation,
|
|
||||||
-- refer to the README for telescope-fzf-native for more instructions.
|
|
||||||
build = 'make',
|
|
||||||
cond = function()
|
|
||||||
return vim.fn.executable 'make' == 1
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
'nvim-tree/nvim-web-devicons',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
-- Highlight, edit, and navigate code
|
|
||||||
'nvim-treesitter/nvim-treesitter',
|
|
||||||
dependencies = {
|
|
||||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
|
||||||
'windwp/nvim-ts-autotag',
|
|
||||||
},
|
|
||||||
build = ':TSUpdate',
|
|
||||||
-- setup autotag with default options
|
|
||||||
opts = {
|
|
||||||
enable = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
|
|
||||||
-- These are some example plugins that I've included in the kickstart repository.
|
|
||||||
-- Uncomment any of the lines below to enable them.
|
|
||||||
-- require 'kickstart.plugins.autoformat',
|
|
||||||
-- require 'kickstart.plugins.debug',
|
|
||||||
|
|
||||||
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
|
|
||||||
-- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping
|
|
||||||
-- up-to-date with whatever is in the kickstart repo.
|
|
||||||
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
|
|
||||||
--
|
|
||||||
-- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins
|
|
||||||
{ import = 'custom.plugins' },
|
{ import = 'custom.plugins' },
|
||||||
}, opts)
|
}, opts)
|
||||||
|
|
||||||
-- [[ Basic Keymaps ]]
|
require('config.options')
|
||||||
|
require('config.mappings')
|
||||||
-- Keymaps for better default experience
|
|
||||||
-- See `:help vim.keymap.set()`
|
|
||||||
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
|
|
||||||
vim.keymap.set('n', '<leader>pv', vim.cmd.Ex, { desc = "[P]roject [V]iew" })
|
|
||||||
|
|
||||||
-- Remap for dealing with word wrap
|
|
||||||
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
|
|
||||||
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
|
|
||||||
|
|
||||||
-- Move lines
|
|
||||||
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv", { silent = true })
|
|
||||||
vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv", { silent = true })
|
|
||||||
|
|
||||||
vim.keymap.set('n', 'J', "mzj`z")
|
|
||||||
vim.keymap.set('n', '<C-d>', "<C-d>zz", { desc = "Half Page Jumping Up" })
|
|
||||||
vim.keymap.set('n', '<C-u>', "<C-u>zz", { desc = "Half Page Jumping Down" })
|
|
||||||
|
|
||||||
-- Keep search line in the middle
|
|
||||||
vim.keymap.set('n', 'n', 'nzzzv', { silent = true })
|
|
||||||
vim.keymap.set('n', 'N', 'Nzzzv', { silent = true })
|
|
||||||
|
|
||||||
-- Quick fix navigation
|
|
||||||
vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz")
|
|
||||||
vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz")
|
|
||||||
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz", { desc = "Quick Fix Nav Up" })
|
|
||||||
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz", { desc = "Quick Fix Nav Down" })
|
|
||||||
|
|
||||||
-- Copy from plus register
|
|
||||||
vim.keymap.set({ 'n', 'v' }, '<leader>y', "\"+y", { desc = "Copy to + register" })
|
|
||||||
vim.keymap.set('n', '<leader>Y', "\"+Y")
|
|
||||||
|
|
||||||
-- Replace current word
|
|
||||||
vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]],
|
|
||||||
{ desc = "[S]ubstitute Current Word" })
|
|
||||||
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { desc = "Set Current File to Executable", silent = true })
|
|
||||||
|
|
||||||
-- [[ Highlight on yank ]]
|
-- [[ Highlight on yank ]]
|
||||||
-- See `:help vim.highlight.on_yank()`
|
-- See `:help vim.highlight.on_yank()`
|
||||||
|
@ -294,115 +50,6 @@ vim.api.nvim_create_autocmd('TextYankPost', {
|
||||||
pattern = '*',
|
pattern = '*',
|
||||||
})
|
})
|
||||||
|
|
||||||
-- [[ Configure Telescope ]]
|
|
||||||
-- See `:help telescope` and `:help telescope.setup()`
|
|
||||||
require('telescope').setup {
|
|
||||||
defaults = {
|
|
||||||
mappings = {
|
|
||||||
i = {
|
|
||||||
['<C-u>'] = false,
|
|
||||||
['<C-d>'] = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Enable telescope fzf native, if installed
|
|
||||||
pcall(require('telescope').load_extension, 'fzf')
|
|
||||||
|
|
||||||
-- See `:help telescope.builtin`
|
|
||||||
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
|
|
||||||
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
|
|
||||||
vim.keymap.set('n', '<leader>/', function()
|
|
||||||
-- You can pass additional configuration to telescope to change theme, layout, etc.
|
|
||||||
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
|
||||||
winblend = 10,
|
|
||||||
previewer = false,
|
|
||||||
})
|
|
||||||
end, { desc = '[/] Fuzzily search in current buffer' })
|
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
|
|
||||||
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
|
|
||||||
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
|
|
||||||
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
|
|
||||||
vim.keymap.set('n', '<leader>sp', function()
|
|
||||||
require('telescope.builtin').grep_string({ search = vim.fn.input("Grep Search > ") })
|
|
||||||
end, { desc = '[S]search [P]roject' })
|
|
||||||
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
|
|
||||||
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
|
|
||||||
vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]resume' })
|
|
||||||
|
|
||||||
-- [[ Configure Treesitter ]]
|
|
||||||
-- See `:help nvim-treesitter`
|
|
||||||
require('nvim-treesitter.configs').setup {
|
|
||||||
-- Add languages to be installed here that you want installed for treesitter
|
|
||||||
ensure_installed = { 'c', 'cpp', 'lua', 'python', 'go', 'vimdoc', 'vim' },
|
|
||||||
|
|
||||||
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
|
|
||||||
auto_install = false,
|
|
||||||
|
|
||||||
highlight = { enable = true },
|
|
||||||
indent = { enable = true },
|
|
||||||
incremental_selection = {
|
|
||||||
enable = true,
|
|
||||||
keymaps = {
|
|
||||||
init_selection = '<c-space>',
|
|
||||||
node_incremental = '<c-space>',
|
|
||||||
scope_incremental = '<c-s>',
|
|
||||||
node_decremental = '<M-space>',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
textobjects = {
|
|
||||||
select = {
|
|
||||||
enable = true,
|
|
||||||
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
|
|
||||||
keymaps = {
|
|
||||||
-- You can use the capture groups defined in textobjects.scm
|
|
||||||
['aa'] = '@parameter.outer',
|
|
||||||
['ia'] = '@parameter.inner',
|
|
||||||
['af'] = '@function.outer',
|
|
||||||
['if'] = '@function.inner',
|
|
||||||
['ac'] = '@class.outer',
|
|
||||||
['ic'] = '@class.inner',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
move = {
|
|
||||||
enable = true,
|
|
||||||
set_jumps = true, -- whether to set jumps in the jumplist
|
|
||||||
goto_next_start = {
|
|
||||||
[']m'] = '@function.outer',
|
|
||||||
[']]'] = '@class.outer',
|
|
||||||
},
|
|
||||||
goto_next_end = {
|
|
||||||
[']M'] = '@function.outer',
|
|
||||||
[']['] = '@class.outer',
|
|
||||||
},
|
|
||||||
goto_previous_start = {
|
|
||||||
['[m'] = '@function.outer',
|
|
||||||
['[['] = '@class.outer',
|
|
||||||
},
|
|
||||||
goto_previous_end = {
|
|
||||||
['[M'] = '@function.outer',
|
|
||||||
['[]'] = '@class.outer',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
swap = {
|
|
||||||
enable = true,
|
|
||||||
swap_next = {
|
|
||||||
['<leader>i'] = '@parameter.inner',
|
|
||||||
},
|
|
||||||
swap_previous = {
|
|
||||||
['<leader>I'] = '@parameter.inner',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Diagnostic keymaps
|
|
||||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
|
|
||||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
|
|
||||||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
|
|
||||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
|
|
||||||
|
|
||||||
-- [[ Configure LSP ]]
|
-- [[ Configure LSP ]]
|
||||||
-- This function gets run when an LSP connects to a particular buffer.
|
-- This function gets run when an LSP connects to a particular buffer.
|
||||||
|
@ -456,7 +103,7 @@ local on_attach = function(_, bufnr)
|
||||||
augroup END
|
augroup END
|
||||||
]])
|
]])
|
||||||
end
|
end
|
||||||
|
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
|
||||||
-- Enable the following language servers
|
-- Enable the following language servers
|
||||||
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
||||||
--
|
--
|
||||||
|
@ -623,55 +270,3 @@ mason_tool_installer.setup({
|
||||||
"revive",
|
"revive",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- [[ Configure nvim-cmp ]]
|
|
||||||
-- See `:help cmp`
|
|
||||||
local cmp = require 'cmp'
|
|
||||||
local luasnip = require 'luasnip'
|
|
||||||
require('luasnip.loaders.from_vscode').lazy_load()
|
|
||||||
luasnip.config.setup {}
|
|
||||||
|
|
||||||
cmp.setup {
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
luasnip.lsp_expand(args.body)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
mapping = cmp.mapping.preset.insert {
|
|
||||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
|
||||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
|
||||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
||||||
['<C-Space>'] = cmp.mapping.complete {},
|
|
||||||
['<CR>'] = cmp.mapping.confirm {
|
|
||||||
behavior = cmp.ConfirmBehavior.Replace,
|
|
||||||
select = true,
|
|
||||||
},
|
|
||||||
['<Tab>'] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_next_item()
|
|
||||||
elseif luasnip.expand_or_locally_jumpable() then
|
|
||||||
luasnip.expand_or_jump()
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { 'i', 's' }),
|
|
||||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
elseif luasnip.locally_jumpable(-1) then
|
|
||||||
luasnip.jump(-1)
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { 'i', 's' }),
|
|
||||||
},
|
|
||||||
sources = {
|
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
{ name = 'luasnip' },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
|
||||||
-- vim: ts=2 sts=2 sw=2 et
|
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
-- [[ Basic Keymaps ]]
|
||||||
|
|
||||||
|
-- Keymaps for better default experience
|
||||||
|
-- See `:help vim.keymap.set()`
|
||||||
|
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
|
||||||
|
vim.keymap.set('n', '<leader>pv', vim.cmd.Ex, { desc = "[P]roject [V]iew" })
|
||||||
|
|
||||||
|
-- Remap for dealing with word wrap
|
||||||
|
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", {
|
||||||
|
expr = true, silent = true
|
||||||
|
})
|
||||||
|
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", {
|
||||||
|
expr = true, silent = true
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Move lines
|
||||||
|
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv", { silent = true })
|
||||||
|
vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv", { silent = true })
|
||||||
|
|
||||||
|
vim.keymap.set('n', 'J', "mzj`z")
|
||||||
|
vim.keymap.set('n', '<C-d>', "<C-d>zz", { desc = "Half Page Jumping Up" })
|
||||||
|
vim.keymap.set('n', '<C-u>', "<C-u>zz", { desc = "Half Page Jumping Down" })
|
||||||
|
|
||||||
|
-- Keep search line in the middle
|
||||||
|
vim.keymap.set('n', 'n', 'nzzzv', { silent = true })
|
||||||
|
vim.keymap.set('n', 'N', 'Nzzzv', { silent = true })
|
||||||
|
|
||||||
|
-- Quick fix navigation
|
||||||
|
vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz")
|
||||||
|
vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz")
|
||||||
|
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz", { desc = "Quick Fix Nav Up" })
|
||||||
|
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz", { desc = "Quick Fix Nav Down" })
|
||||||
|
|
||||||
|
-- Copy from plus register
|
||||||
|
vim.keymap.set({ 'n', 'v' }, '<leader>y', "\"+y", { desc = "Copy to + register" })
|
||||||
|
vim.keymap.set('n', '<leader>Y', "\"+Y")
|
||||||
|
|
||||||
|
-- Replace current word
|
||||||
|
vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]],
|
||||||
|
{ desc = "[S]ubstitute Current Word" })
|
||||||
|
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { desc = "Set Current File to Executable", silent = true })
|
||||||
|
|
||||||
|
-- [ telescope keymaps]
|
||||||
|
-- See `:help telescope.builtin`
|
||||||
|
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
|
||||||
|
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
|
||||||
|
vim.keymap.set('n', '<leader>/', function()
|
||||||
|
-- You can pass additional configuration to telescope to change theme, layout, etc.
|
||||||
|
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
||||||
|
winblend = 10,
|
||||||
|
previewer = false,
|
||||||
|
})
|
||||||
|
end, { desc = '[/] Fuzzily search in current buffer' })
|
||||||
|
|
||||||
|
vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
|
||||||
|
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
|
||||||
|
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
|
||||||
|
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
|
||||||
|
vim.keymap.set('n', '<leader>sp', function()
|
||||||
|
require('telescope.builtin').grep_string({ search = vim.fn.input("Grep Search > ") })
|
||||||
|
end, { desc = '[S]search [P]roject' })
|
||||||
|
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
|
||||||
|
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
|
||||||
|
vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]resume' })
|
||||||
|
|
||||||
|
-- [ tree-sitter keymaps ]
|
||||||
|
-- Diagnostic keymaps
|
||||||
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
|
||||||
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
|
||||||
|
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
|
||||||
|
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
|
|
@ -1,7 +1,7 @@
|
||||||
local opt = vim.opt
|
local opt = vim.opt
|
||||||
local g = vim.g
|
local g = vim.g
|
||||||
local options = {
|
local options = {
|
||||||
-- change cursor in insert mode
|
-- change cursor in insert mode
|
||||||
guicursor = "",
|
guicursor = "",
|
||||||
|
|
||||||
-- Make line numbers default
|
-- Make line numbers default
|
||||||
|
@ -75,11 +75,11 @@ local disabled_built_ins = {
|
||||||
"gzip",
|
"gzip",
|
||||||
"logipat",
|
"logipat",
|
||||||
"matchit",
|
"matchit",
|
||||||
-- "netrw",
|
-- "netrw",
|
||||||
"netrwFileHandlers",
|
"netrwFileHandlers",
|
||||||
"loaded_remote_plugins",
|
"loaded_remote_plugins",
|
||||||
"loaded_tutor_mode_plugin",
|
"loaded_tutor_mode_plugin",
|
||||||
-- "netrwPlugin",
|
"netrwPlugin",
|
||||||
"netrwSettings",
|
"netrwSettings",
|
||||||
"rrhelper",
|
"rrhelper",
|
||||||
"spellfile_plugin",
|
"spellfile_plugin",
|
||||||
|
@ -127,11 +127,11 @@ opt.formatoptions = opt.formatoptions
|
||||||
+ "j" -- Auto-remove comments if possible.
|
+ "j" -- Auto-remove comments if possible.
|
||||||
- "2" -- I'm not in gradeschool anymore
|
- "2" -- I'm not in gradeschool anymore
|
||||||
|
|
||||||
-- opt.guicursor = {
|
opt.guicursor = {
|
||||||
-- "n-v:block",
|
"n-v:block",
|
||||||
-- "i-c-ci-ve:ver25",
|
"i-c-ci-ve:ver25",
|
||||||
-- "r-cr:hor20",
|
"r-cr:hor20",
|
||||||
-- "o:hor50",
|
"o:hor50",
|
||||||
-- "i:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor",
|
"i:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor",
|
||||||
-- "sm:block-blinkwait175-blinkoff150-blinkon175",
|
"sm:block-blinkwait175-blinkoff150-blinkon175",
|
||||||
-- }
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
-- return {
|
||||||
|
-- Theme inspired by Atom
|
||||||
|
-- 'navarasu/onedark.nvim',
|
||||||
|
-- priority = 1000,
|
||||||
|
-- config = function()
|
||||||
|
-- vim.cmd.colorscheme 'onedark'
|
||||||
|
-- end,
|
||||||
|
-- },
|
|
@ -0,0 +1,5 @@
|
||||||
|
return {
|
||||||
|
'numToStr/Comment.nvim',
|
||||||
|
opts = {},
|
||||||
|
lazy = false
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
return {
|
||||||
|
-- Adds git related signs to the gutter, as well as utilities for managing changes
|
||||||
|
'lewis6991/gitsigns.nvim',
|
||||||
|
opts = {
|
||||||
|
-- See `:help gitsigns.txt`
|
||||||
|
signs = {
|
||||||
|
add = { text = '+' },
|
||||||
|
change = { text = '~' },
|
||||||
|
delete = { text = '_' },
|
||||||
|
topdelete = { text = '‾' },
|
||||||
|
changedelete = { text = '~' },
|
||||||
|
},
|
||||||
|
on_attach = function(bufnr)
|
||||||
|
vim.keymap.set('n', '<leader>hp', require('gitsigns').preview_hunk, {
|
||||||
|
buffer = bufnr, desc = 'Preview git hunk'
|
||||||
|
})
|
||||||
|
|
||||||
|
-- don't override the built-in and fugitive keymaps
|
||||||
|
local gs = package.loaded.gitsigns
|
||||||
|
vim.keymap.set({ 'n', 'v' }, ']c', function()
|
||||||
|
if vim.wo.diff then return ']c' end
|
||||||
|
vim.schedule(function() gs.next_hunk() end)
|
||||||
|
return '<Ignore>'
|
||||||
|
end, { expr = true, buffer = bufnr, desc = "Jump to next hunk" })
|
||||||
|
vim.keymap.set({ 'n', 'v' }, '[c', function()
|
||||||
|
if vim.wo.diff then return '[c' end
|
||||||
|
vim.schedule(function() gs.prev_hunk() end)
|
||||||
|
return '<Ignore>'
|
||||||
|
end, { expr = true, buffer = bufnr, desc = "Jump to previous hunk" })
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
return {
|
||||||
|
-- Add indentation guides even on blank lines
|
||||||
|
'lukas-reineke/indent-blankline.nvim',
|
||||||
|
-- Enable `lukas-reineke/indent-blankline.nvim`
|
||||||
|
-- See `:help indent_blankline.txt`
|
||||||
|
main = "ibl",
|
||||||
|
opts = {
|
||||||
|
indent = {
|
||||||
|
--[[ highlight = highlight ]]
|
||||||
|
char = "┆",
|
||||||
|
smart_indent_cap = true,
|
||||||
|
},
|
||||||
|
whitespace = {
|
||||||
|
--[[ highlight = highlight, ]]
|
||||||
|
remove_blankline_trail = false,
|
||||||
|
},
|
||||||
|
scope = { enabled = true },
|
||||||
|
},
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
return {
|
||||||
|
-- LSP Configuration & Plugin
|
||||||
|
'neovim/nvim-lspconfig',
|
||||||
|
dependencies = {
|
||||||
|
-- Automatically install LSPs to stdpath for neovim
|
||||||
|
{ 'williamboman/mason.nvim', config = true },
|
||||||
|
'williamboman/mason-lspconfig.nvim',
|
||||||
|
'WhoIsSethDaniel/mason-tool-installer.nvim',
|
||||||
|
|
||||||
|
-- Useful status updates for LSP
|
||||||
|
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
||||||
|
{
|
||||||
|
'j-hui/fidget.nvim',
|
||||||
|
tag = 'legacy',
|
||||||
|
opts = {}
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Additional lua configuration, makes nvim stuff amazing!
|
||||||
|
'folke/neodev.nvim',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
-- These are some example plugins that I've included in the kickstart repository.
|
|
@ -0,0 +1,13 @@
|
||||||
|
return {
|
||||||
|
-- Set lualine as statusline
|
||||||
|
'nvim-lualine/lualine.nvim',
|
||||||
|
-- See `:help lualine.txt`
|
||||||
|
opts = {
|
||||||
|
options = {
|
||||||
|
icons_enabled = false,
|
||||||
|
theme = 'onedark',
|
||||||
|
component_separators = '|',
|
||||||
|
section_separators = '',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
return {
|
||||||
|
'tanvirtin/monokai.nvim',
|
||||||
|
priority = 1000,
|
||||||
|
config = function()
|
||||||
|
vim.cmd.colorscheme('monokai')
|
||||||
|
end,
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
return {
|
||||||
|
-- Autocompletion
|
||||||
|
'hrsh7th/nvim-cmp',
|
||||||
|
dependencies = {
|
||||||
|
-- Snippet Engine & its associated nvim-cmp source
|
||||||
|
'L3MON4D3/LuaSnip',
|
||||||
|
'saadparwaiz1/cmp_luasnip',
|
||||||
|
|
||||||
|
-- Adds LSP completion capabilities
|
||||||
|
'hrsh7th/cmp-nvim-lsp',
|
||||||
|
|
||||||
|
-- Adds a number of user-friendly snippets
|
||||||
|
'rafamadriz/friendly-snippets',
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
-- See `:help cmp`
|
||||||
|
local cmp = require 'cmp'
|
||||||
|
local luasnip = require 'luasnip'
|
||||||
|
require('luasnip.loaders.from_vscode').lazy_load()
|
||||||
|
luasnip.config.setup {}
|
||||||
|
|
||||||
|
cmp.setup {
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
luasnip.lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert {
|
||||||
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||||
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||||
|
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
['<C-Space>'] = cmp.mapping.complete {},
|
||||||
|
['<CR>'] = cmp.mapping.confirm {
|
||||||
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
|
select = true,
|
||||||
|
},
|
||||||
|
['<Tab>'] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif luasnip.expand_or_locally_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' }),
|
||||||
|
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif luasnip.locally_jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' }),
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'luasnip' },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
return {
|
||||||
|
-- Fuzzy Finder (files, lsp, etc)
|
||||||
|
'nvim-telescope/telescope.nvim',
|
||||||
|
branch = '0.1.x',
|
||||||
|
dependencies = {
|
||||||
|
'nvim-lua/plenary.nvim',
|
||||||
|
-- Fuzzy Finder Algorithm which requires local dependencies to be built.
|
||||||
|
-- Only load if `make` is available. Make sure you have the system
|
||||||
|
-- requirements installed.
|
||||||
|
{
|
||||||
|
'nvim-telescope/telescope-fzf-native.nvim',
|
||||||
|
-- NOTE: If you are having trouble with this installation,
|
||||||
|
-- refer to the README for telescope-fzf-native for more instructions.
|
||||||
|
build = 'make',
|
||||||
|
cond = function()
|
||||||
|
return vim.fn.executable 'make' == 1
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
'nvim-tree/nvim-web-devicons',
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require('telescope').setup {
|
||||||
|
defaults = {
|
||||||
|
mappings = {
|
||||||
|
i = {
|
||||||
|
['<C-u>'] = false,
|
||||||
|
['<C-d>'] = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
-- Enable telescope fzf native, if installed
|
||||||
|
pcall(require('telescope').load_extension, 'fzf')
|
||||||
|
end,
|
||||||
|
} -- See `:help telescope` and `:help telescope.setup()`
|
|
@ -0,0 +1,79 @@
|
||||||
|
return {
|
||||||
|
-- Highlight, edit, and navigate code
|
||||||
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
dependencies = {
|
||||||
|
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||||
|
'windwp/nvim-ts-autotag',
|
||||||
|
},
|
||||||
|
build = ':TSUpdate',
|
||||||
|
-- setup autotag with default options
|
||||||
|
opts = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
-- See `:help nvim-treesitter`
|
||||||
|
require('nvim-treesitter.configs').setup {
|
||||||
|
-- Add languages to be installed here that you want installed for treesitter
|
||||||
|
ensure_installed = { 'c', 'cpp', 'lua', 'python', 'go', 'vimdoc', 'vim' },
|
||||||
|
|
||||||
|
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
|
||||||
|
auto_install = false,
|
||||||
|
|
||||||
|
highlight = { enable = true },
|
||||||
|
indent = { enable = true },
|
||||||
|
incremental_selection = {
|
||||||
|
enable = true,
|
||||||
|
keymaps = {
|
||||||
|
init_selection = '<c-space>',
|
||||||
|
node_incremental = '<c-space>',
|
||||||
|
scope_incremental = '<c-s>',
|
||||||
|
node_decremental = '<M-space>',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
textobjects = {
|
||||||
|
select = {
|
||||||
|
enable = true,
|
||||||
|
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
|
||||||
|
keymaps = {
|
||||||
|
-- You can use the capture groups defined in textobjects.scm
|
||||||
|
['aa'] = '@parameter.outer',
|
||||||
|
['ia'] = '@parameter.inner',
|
||||||
|
['af'] = '@function.outer',
|
||||||
|
['if'] = '@function.inner',
|
||||||
|
['ac'] = '@class.outer',
|
||||||
|
['ic'] = '@class.inner',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
move = {
|
||||||
|
enable = true,
|
||||||
|
set_jumps = true, -- whether to set jumps in the jumplist
|
||||||
|
goto_next_start = {
|
||||||
|
[']m'] = '@function.outer',
|
||||||
|
[']]'] = '@class.outer',
|
||||||
|
},
|
||||||
|
goto_next_end = {
|
||||||
|
[']M'] = '@function.outer',
|
||||||
|
[']['] = '@class.outer',
|
||||||
|
},
|
||||||
|
goto_previous_start = {
|
||||||
|
['[m'] = '@function.outer',
|
||||||
|
['[['] = '@class.outer',
|
||||||
|
},
|
||||||
|
goto_previous_end = {
|
||||||
|
['[M'] = '@function.outer',
|
||||||
|
['[]'] = '@class.outer',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
swap = {
|
||||||
|
enable = true,
|
||||||
|
swap_next = {
|
||||||
|
['<leader>i'] = '@parameter.inner',
|
||||||
|
},
|
||||||
|
swap_previous = {
|
||||||
|
['<leader>I'] = '@parameter.inner',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
return {
|
||||||
|
'folke/which-key.nvim',
|
||||||
|
opts = {}
|
||||||
|
}
|
Loading…
Reference in New Issue