281 lines
9.7 KiB
Lua
281 lines
9.7 KiB
Lua
--[[
|
|
|
|
=====================================================================
|
|
==================== READ THIS BEFORE CONTINUING ====================
|
|
=====================================================================
|
|
|
|
Kickstart.nvim is *not* a distribution.
|
|
|
|
Kickstart.nvim is a template for your own configuration.
|
|
The goal is that you can read every line of code, top-to-bottom, understand
|
|
what your configuration is doing, and modify it to suit your needs.
|
|
|
|
Once you've done that, you should start exploring, configuring and tinkering to
|
|
explore Neovim!
|
|
|
|
If you don't know anything about Lua, I recommend taking some time to read through
|
|
a guide. One possible example:
|
|
- https://learnxinyminutes.com/docs/lua/
|
|
|
|
|
|
And then you can explore or search through `:help lua-guide`
|
|
- https://neovim.io/doc/user/lua-guide.html
|
|
|
|
|
|
Kickstart Guide:
|
|
|
|
I have left several `:help X` comments throughout the init.lua
|
|
You should run that command and read that help section for more information.
|
|
|
|
In addition, I have some `NOTE:` items throughout the file.
|
|
These are for you, the reader to help understand what is happening. Feel free to delete
|
|
them once you know what you're doing, but they should serve as a guide for when you
|
|
are first encountering a few different constructs in your nvim config.
|
|
|
|
I hope you enjoy your Neovim journey,
|
|
- TJ
|
|
|
|
P.S. You can delete this when you're done too. It's your config now :)
|
|
--]]
|
|
-- Set <space> as the leader key
|
|
-- See `:help mapleader`
|
|
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
|
|
vim.g.mapleader = ' '
|
|
vim.g.maplocalleader = ' '
|
|
vim.cmd([[source ~/repos/nvim-kickstart/lua/custom/vimrc]])
|
|
|
|
---------- treesitter.start guard >------------------------------
|
|
-- Neovim's own bundled ftplugin/<lang>.lua calls vim.treesitter.start()
|
|
-- unconditionally. When the system's bundled highlight queries are ahead of
|
|
-- the currently available parser/grammar (a packaging/version skew, not a
|
|
-- config issue), that call throws and takes down the whole FileType autocmd
|
|
-- chain for the buffer (breaking omnifunc/foldexpr along with it). Guard it
|
|
-- here, before any buffer can trigger it, so a mismatch just falls back to
|
|
-- regex syntax highlighting instead of erroring.
|
|
do
|
|
local orig_start = vim.treesitter.start
|
|
vim.treesitter.start = function(...)
|
|
local ok, err = pcall(orig_start, ...)
|
|
if not ok then
|
|
vim.notify_once('treesitter.start failed, falling back to regex highlighting: ' .. tostring(err),
|
|
vim.log.levels.WARN)
|
|
end
|
|
end
|
|
end
|
|
---------- </treesitter.start guard ------------------------------
|
|
|
|
-- Install package manager
|
|
-- https://github.com/folke/lazy.nvim
|
|
-- `:help lazy.nvim.txt` for more info
|
|
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
|
if not vim.uv.fs_stat(lazypath) then
|
|
vim.fn.system {
|
|
'git',
|
|
'clone',
|
|
'--filter=blob:none',
|
|
'https://github.com/folke/lazy.nvim.git',
|
|
'--branch=stable', -- latest stable release
|
|
lazypath,
|
|
}
|
|
end
|
|
vim.opt.rtp:prepend(lazypath)
|
|
|
|
-- 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({
|
|
-- NOTE: First, some plugins that don't require any configuration
|
|
|
|
-- Git related plugins
|
|
'tpope/vim-fugitive',
|
|
'tpope/vim-rhubarb',
|
|
|
|
-- Detect tabstop and shiftwidth automatically
|
|
'tpope/vim-sleuth',
|
|
|
|
-- seems i need this regardless
|
|
'neovim/nvim-lspconfig',
|
|
'williamboman/mason.nvim',
|
|
'williamboman/mason-lspconfig.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 = {
|
|
signs = {
|
|
add = { text = '+' },
|
|
change = { text = '~' },
|
|
delete = { text = '_' },
|
|
topdelete = { text = '‾' },
|
|
changedelete = { text = '~' },
|
|
},
|
|
},
|
|
},
|
|
|
|
{
|
|
-- Set lualine as statusline
|
|
'nvim-lualine/lualine.nvim',
|
|
-- See `:help lualine.txt`
|
|
opts = {
|
|
options = {
|
|
icons_enabled = false,
|
|
component_separators = '|',
|
|
section_separators = '',
|
|
},
|
|
},
|
|
},
|
|
|
|
|
|
|
|
-- "gc" to comment visual regions/lines
|
|
{ 'numToStr/Comment.nvim', opts = {} },
|
|
|
|
-- Fuzzy Finder (files, lsp, etc)
|
|
{
|
|
'nvim-telescope/telescope.nvim',
|
|
version = '*',
|
|
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,
|
|
},
|
|
},
|
|
},
|
|
|
|
{ -- Highlight, edit, and navigate code
|
|
'nvim-treesitter/nvim-treesitter',
|
|
branch = "main",
|
|
lazy = false,
|
|
build = ':TSUpdate',
|
|
dependencies = {
|
|
'nvim-treesitter/nvim-treesitter-textobjects',
|
|
branch = "main"
|
|
},
|
|
init = function()
|
|
local ensureInstalled = {
|
|
'lua', 'python', 'typescript',
|
|
-- ... your parsers
|
|
}
|
|
local alreadyInstalled = require('nvim-treesitter.config').get_installed()
|
|
local parsersToInstall = vim.iter(ensureInstalled)
|
|
:filter(function(parser)
|
|
return not vim.tbl_contains(alreadyInstalled, parser)
|
|
end)
|
|
:totable()
|
|
require('nvim-treesitter').install(parsersToInstall)
|
|
end,
|
|
},
|
|
|
|
-- 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',
|
|
require 'kickstart.plugins.filetree',
|
|
|
|
-- 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' },
|
|
}, {})
|
|
|
|
-- [[ Basic Keymaps ]]
|
|
-- See lua/custom/options.lua for vim.opt settings
|
|
|
|
-- Keymaps for better default experience
|
|
-- See `:help vim.keymap.set()`
|
|
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
|
|
|
|
-- 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 })
|
|
|
|
-- [[ Highlight on yank ]]
|
|
-- See `:help vim.highlight.on_yank()`
|
|
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
|
|
vim.api.nvim_create_autocmd('TextYankPost', {
|
|
callback = function()
|
|
vim.highlight.on_yank()
|
|
end,
|
|
group = highlight_group,
|
|
pattern = '*',
|
|
})
|
|
|
|
-- [[ Configure Telescope ]]
|
|
-- See `:help telescope` and `:help telescope.setup()`
|
|
|
|
-- Enable telescope fzf native, if installed
|
|
|
|
-- See `:help telescope.builtin`
|
|
|
|
-- Diagnostic keymaps
|
|
vim.keymap.set('n', '[d', function() vim.diagnostic.jump({ count = -1 }) end,
|
|
{ desc = 'Go to previous diagnostic message' })
|
|
vim.keymap.set('n', ']d', function() vim.diagnostic.jump({ count = 1 }) end, { desc = 'Go to next diagnostic message' })
|
|
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
|
|
|
|
-- [[ Configure nvim-cmp ]]
|
|
-- See `:help cmp`
|
|
local luasnip = require 'luasnip'
|
|
require('luasnip.loaders.from_vscode').lazy_load()
|
|
luasnip.config.setup {}
|
|
|
|
-- local nvim config (project level, debug mapping etc.)
|
|
local local_config = vim.fn.getcwd() .. "/.nvim.lua"
|
|
if vim.fn.filereadable(local_config) == 1 then
|
|
dofile(local_config)
|
|
end
|
|
|
|
-- The line beneath this is called `modeline`. See `:help modeline`
|
|
-- vim: ts=2 sts=2 sw=2 et
|
|
|
|
-- options.lua sets vim.opt.termguicolors, which colorizer.lua (and others) need
|
|
-- already set by the time they run their setup() calls, so it loads first
|
|
require('custom.options')
|
|
require('custom.catppuccin')
|
|
require('custom.lua-line')
|
|
require('custom.telescope')
|
|
require('custom.lspconfig')
|
|
require('custom.nvim-cmp')
|
|
require('custom.toggleterm')
|
|
require('custom.autopairs')
|
|
require('custom.colorizer')
|
|
require('custom.keymaps')
|
|
require('custom.mason')
|
|
require('custom.kulala')
|
|
require('custom.rainbow')
|
|
require('custom.none-ls')
|
|
require('custom.gitsigns')
|
|
require('custom.colortheme')
|