current good
This commit is contained in:
317
init.lua
317
init.lua
@@ -1,89 +1,3 @@
|
||||
--[[
|
||||
|
||||
=====================================================================
|
||||
==================== READ THIS BEFORE CONTINUING ====================
|
||||
=====================================================================
|
||||
======== .-----. ========
|
||||
======== .----------------------. | === | ========
|
||||
======== |.-""""""""""""""""""-.| |-----| ========
|
||||
======== || || | === | ========
|
||||
======== || KICKSTART.NVIM || |-----| ========
|
||||
======== || || | === | ========
|
||||
======== || || |-----| ========
|
||||
======== ||:Tutor || |:::::| ========
|
||||
======== |'-..................-'| |____o| ========
|
||||
======== `"")----------------(""` ___________ ========
|
||||
======== /::::::::::| |::::::::::\ \ no mouse \ ========
|
||||
======== /:::========| |==hjkl==:::\ \ required \ ========
|
||||
======== '""""""""""""' '""""""""""""' '""""""""""' ========
|
||||
======== ========
|
||||
=====================================================================
|
||||
=====================================================================
|
||||
|
||||
What is Kickstart?
|
||||
|
||||
Kickstart.nvim is *not* a distribution.
|
||||
|
||||
Kickstart.nvim is a starting point 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 can start exploring, configuring and tinkering to
|
||||
make Neovim your own! That might mean leaving Kickstart just the way it is for a while
|
||||
or immediately breaking it into modular pieces. It's up to you!
|
||||
|
||||
If you don't know anything about Lua, I recommend taking some time to read through
|
||||
a guide. One possible example which will only take 10-15 minutes:
|
||||
- https://learnxinyminutes.com/docs/lua/
|
||||
|
||||
After understanding a bit more about Lua, you can use `:help lua-guide` as a
|
||||
reference for how Neovim integrates Lua.
|
||||
- :help lua-guide
|
||||
- (or HTML version): https://neovim.io/doc/user/lua-guide.html
|
||||
|
||||
Kickstart Guide:
|
||||
|
||||
TODO: The very first thing you should do is to run the command `:Tutor` in Neovim.
|
||||
|
||||
If you don't know what this means, type the following:
|
||||
- <escape key>
|
||||
- :
|
||||
- Tutor
|
||||
- <enter key>
|
||||
|
||||
(If you already know the Neovim basics, you can skip this step.)
|
||||
|
||||
Once you've completed that, you can continue working through **AND READING** the rest
|
||||
of the kickstart init.lua.
|
||||
|
||||
Next, run AND READ `:help`.
|
||||
This will open up a help window with some basic information
|
||||
about reading, navigating and searching the builtin help documentation.
|
||||
|
||||
This should be the first place you go to look when you're stuck or confused
|
||||
with something. It's one of my favorite Neovim features.
|
||||
|
||||
MOST IMPORTANTLY, we provide a keymap "<space>sh" to [s]earch the [h]elp documentation,
|
||||
which is very useful when you're not exactly sure of what you're looking for.
|
||||
|
||||
I have left several `:help X` comments throughout the init.lua
|
||||
These are hints about where to find more information about the relevant settings,
|
||||
plugins or Neovim features used in Kickstart.
|
||||
|
||||
NOTE: Look for lines like this
|
||||
|
||||
Throughout the file. These are for you, the reader, to help you 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 Neovim config.
|
||||
|
||||
If you experience any errors while trying to install kickstart, run `:checkhealth` for more info.
|
||||
|
||||
I hope you enjoy your Neovim journey,
|
||||
- TJ
|
||||
|
||||
P.S. You can delete this when you're done too. It's your config now! :)
|
||||
--]]
|
||||
|
||||
-- ============================================================
|
||||
-- SECTION 1: FOUNDATION
|
||||
-- Core Neovim settings, leaders, options, basic keymaps, basic autocmds
|
||||
@@ -91,7 +5,6 @@ P.S. You can delete this when you're done too. It's your config now! :)
|
||||
do
|
||||
-- Enable faster startup by caching compiled Lua modules
|
||||
vim.loader.enable()
|
||||
|
||||
-- Set <space> as the leader key
|
||||
-- See `:help mapleader`
|
||||
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
|
||||
@@ -99,19 +12,43 @@ do
|
||||
vim.g.maplocalleader = ' '
|
||||
|
||||
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
||||
vim.g.have_nerd_font = false
|
||||
vim.g.have_nerd_font = true
|
||||
|
||||
-- [[ Setting options ]]
|
||||
-- See `:help vim.o`
|
||||
-- NOTE: You can change these options as you wish!
|
||||
-- For more options, you can see `:help option-list`
|
||||
|
||||
-- Make line numbers default
|
||||
vim.o.number = true
|
||||
-- You can also add relative line numbers, to help with jumping.
|
||||
-- Experiment for yourself to see if you like it!
|
||||
-- vim.o.relativenumber = true
|
||||
|
||||
vim.o.allowrevins = true
|
||||
|
||||
vim.o.autocompletedelay = 10
|
||||
vim.o.autoindent = true
|
||||
vim.o.autoread = true
|
||||
vim.o.background = 'dark'
|
||||
vim.o.backspace = 'indent,eol,start'
|
||||
vim.o.wrap = true
|
||||
vim.o.linebreak = true
|
||||
vim.o.breakat = ' I!@*-+;:,./?'
|
||||
vim.o.tabstop = 4
|
||||
vim.o.shiftwidth = 4
|
||||
vim.o.expandtab = true
|
||||
vim.o.smartindent = true
|
||||
vim.o.hlsearch = true
|
||||
vim.o.incsearch = true
|
||||
vim.o.signcolumn = 'yes'
|
||||
vim.o.relativenumber = true
|
||||
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||
vim.o.wildmode = 'longest:full,full'
|
||||
vim.o.virtualedit = 'block'
|
||||
vim.o.winborder = 'rounded'
|
||||
|
||||
vim.opt.termguicolors = true
|
||||
|
||||
-- Enable mouse mode, can be useful for resizing splits for example!
|
||||
vim.o.mouse = 'a'
|
||||
|
||||
@@ -165,7 +102,7 @@ do
|
||||
vim.o.cursorline = true
|
||||
|
||||
-- Minimal number of screen lines to keep above and below the cursor.
|
||||
vim.o.scrolloff = 10
|
||||
vim.o.scrolloff = 5
|
||||
|
||||
-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
|
||||
-- instead raise a dialog asking if you wish to save the current file(s)
|
||||
@@ -205,35 +142,19 @@ do
|
||||
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
|
||||
|
||||
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
|
||||
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
|
||||
-- is not what someone will guess without a bit more experience.
|
||||
--
|
||||
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
|
||||
-- or just use <C-\><C-n> to exit terminal mode
|
||||
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
|
||||
|
||||
-- TIP: Disable arrow keys in normal mode
|
||||
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
|
||||
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
|
||||
-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
|
||||
-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
|
||||
vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
|
||||
vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
|
||||
vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
|
||||
vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
|
||||
|
||||
-- Keybinds to make split navigation easier.
|
||||
-- Use CTRL+<hjkl> to switch between windows
|
||||
--
|
||||
-- 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-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-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
|
||||
|
||||
-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes
|
||||
-- vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" })
|
||||
-- vim.keymap.set("n", "<C-S-l>", "<C-w>L", { desc = "Move window to the right" })
|
||||
-- vim.keymap.set("n", "<C-S-j>", "<C-w>J", { desc = "Move window to the lower" })
|
||||
-- vim.keymap.set("n", "<C-S-k>", "<C-w>K", { desc = "Move window to the upper" })
|
||||
|
||||
-- [[ Basic Autocommands ]]
|
||||
-- See `:help lua-guide-autocommands`
|
||||
|
||||
@@ -391,10 +312,14 @@ do
|
||||
},
|
||||
}
|
||||
|
||||
vim.pack.add { gh 'navarasu/onedark.nvim' }
|
||||
require('onedark').setup {
|
||||
style = 'deep',
|
||||
}
|
||||
-- Load the colorscheme here.
|
||||
-- Like many other themes, this one has different styles, and you could load
|
||||
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
|
||||
vim.cmd.colorscheme 'tokyonight-night'
|
||||
vim.cmd.colorscheme 'onedark'
|
||||
|
||||
-- Highlight todo, notes, etc in comments
|
||||
vim.pack.add { gh 'folke/todo-comments.nvim' }
|
||||
@@ -404,6 +329,10 @@ do
|
||||
-- A collection of various small independent plugins/modules
|
||||
vim.pack.add { gh 'nvim-mini/mini.nvim' }
|
||||
|
||||
vim.pack.add {
|
||||
gh 'nvim-treesitter/nvim-treesitter-textobjects',
|
||||
}
|
||||
|
||||
-- Better Around/Inside textobjects
|
||||
--
|
||||
-- Examples:
|
||||
@@ -686,10 +615,42 @@ do
|
||||
-- See `:help lsp-config` for information about keys and how to configure
|
||||
---@type table<string, vim.lsp.Config>
|
||||
local servers = {
|
||||
-- clangd = {},
|
||||
clangd = {
|
||||
cmd = {
|
||||
'clangd',
|
||||
'--background-index',
|
||||
'--clang-tidy',
|
||||
'--header-insertion=iwyu',
|
||||
'--completion-style=detailed',
|
||||
},
|
||||
},
|
||||
-- gopls = {},
|
||||
-- pyright = {},
|
||||
-- rust_analyzer = {},
|
||||
pyright = {
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
typeCheckingMode = 'basic',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
rust_analyzer = {
|
||||
settings = {
|
||||
['rust-analyzer'] = {
|
||||
cargo = {
|
||||
allFeatures = true,
|
||||
},
|
||||
|
||||
checkOnSave = true,
|
||||
|
||||
procMacro = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
marksman = {},
|
||||
cmake = {},
|
||||
--
|
||||
-- Some languages (like typescript) have entire language plugins that can be useful:
|
||||
-- https://github.com/pmizio/typescript-tools.nvim
|
||||
@@ -776,8 +737,12 @@ do
|
||||
format_on_save = function(bufnr)
|
||||
-- You can specify filetypes to autoformat on save here:
|
||||
local enabled_filetypes = {
|
||||
-- lua = true,
|
||||
-- python = true,
|
||||
lua = true,
|
||||
python = true,
|
||||
rust = true,
|
||||
c = true,
|
||||
cpp = true,
|
||||
cmake = true,
|
||||
}
|
||||
if enabled_filetypes[vim.bo[bufnr].filetype] then
|
||||
return { timeout_ms = 500 }
|
||||
@@ -790,9 +755,16 @@ do
|
||||
},
|
||||
-- You can also specify external formatters in here.
|
||||
formatters_by_ft = {
|
||||
-- rust = { 'rustfmt' },
|
||||
lua = { 'stylua' },
|
||||
rust = { 'rustfmt' },
|
||||
-- Conform can also run multiple formatters sequentially
|
||||
-- python = { "isort", "black" },
|
||||
python = { 'isort', 'black' },
|
||||
|
||||
c = { 'clang_format' },
|
||||
cpp = { 'clang_format' },
|
||||
cmake = { 'cmake_format' },
|
||||
|
||||
markdown = { 'prettier' },
|
||||
--
|
||||
-- You can use 'stop_after_first' to run the first available formatter from the list
|
||||
-- javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||
@@ -818,38 +790,35 @@ do
|
||||
-- See the README about individual language/framework/plugin snippets:
|
||||
-- https://github.com/rafamadriz/friendly-snippets
|
||||
--
|
||||
-- vim.pack.add { gh 'rafamadriz/friendly-snippets' }
|
||||
-- require('luasnip.loaders.from_vscode').lazy_load()
|
||||
vim.pack.add { gh 'rafamadriz/friendly-snippets' }
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
|
||||
-- [[ Autocomplete Engine ]]
|
||||
vim.pack.add { { src = gh 'saghen/blink.cmp', version = vim.version.range '1.*' } }
|
||||
require('blink.cmp').setup {
|
||||
keymap = {
|
||||
-- 'default' (recommended) for mappings similar to built-in completions
|
||||
-- <c-y> to accept ([y]es) the completion.
|
||||
-- This will auto-import if your LSP supports it.
|
||||
-- This will expand snippets if the LSP sent a snippet.
|
||||
-- 'super-tab' for tab to accept
|
||||
-- 'enter' for enter to accept
|
||||
-- 'none' for no mappings
|
||||
--
|
||||
-- For an understanding of why the 'default' preset is recommended,
|
||||
-- you will need to read `:help ins-completion`
|
||||
--
|
||||
-- No, but seriously. Please read `:help ins-completion`, it is really good!
|
||||
--
|
||||
-- All presets have the following mappings:
|
||||
-- <tab>/<s-tab>: move to right/left of your snippet expansion
|
||||
-- <c-space>: Open menu or open docs if already open
|
||||
-- <c-n>/<c-p> or <up>/<down>: Select next/previous item
|
||||
-- <c-e>: Hide menu
|
||||
-- <c-k>: Toggle signature help
|
||||
--
|
||||
-- See `:help blink-cmp-config-keymap` for defining your own keymap
|
||||
preset = 'default',
|
||||
preset = 'none',
|
||||
|
||||
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
|
||||
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
|
||||
['<Tab>'] = {
|
||||
'select_next',
|
||||
'snippet_forward',
|
||||
'fallback',
|
||||
},
|
||||
|
||||
['<S-Tab>'] = {
|
||||
'select_prev',
|
||||
'snippet_backward',
|
||||
'fallback',
|
||||
},
|
||||
|
||||
['<CR>'] = {
|
||||
'accept',
|
||||
'fallback',
|
||||
},
|
||||
|
||||
['<C-space>'] = { 'show', 'show_documentation', 'hide_documentation' },
|
||||
|
||||
['<C-e>'] = { 'hide' },
|
||||
},
|
||||
|
||||
appearance = {
|
||||
@@ -859,13 +828,25 @@ do
|
||||
},
|
||||
|
||||
completion = {
|
||||
menu = {
|
||||
border = 'rounded',
|
||||
},
|
||||
-- By default, you may press `<c-space>` to show the documentation.
|
||||
-- Optionally, set `auto_show = true` to show the documentation after a delay.
|
||||
documentation = { auto_show = false, auto_show_delay_ms = 500 },
|
||||
documentation = {
|
||||
window = {
|
||||
border = 'rounded',
|
||||
},
|
||||
auto_show = true,
|
||||
auto_show_delay_ms = 500,
|
||||
},
|
||||
ghost_text = {
|
||||
enabled = true,
|
||||
},
|
||||
},
|
||||
|
||||
sources = {
|
||||
default = { 'lsp', 'path', 'snippets' },
|
||||
default = { 'lsp', 'path', 'snippets', 'buffer' },
|
||||
},
|
||||
|
||||
snippets = { preset = 'luasnip' },
|
||||
@@ -898,7 +879,30 @@ do
|
||||
vim.pack.add { { src = gh 'nvim-treesitter/nvim-treesitter', version = 'main' } }
|
||||
|
||||
-- Ensure basic parsers are installed
|
||||
local parsers = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }
|
||||
local parsers = {
|
||||
'bash',
|
||||
'c',
|
||||
'cpp',
|
||||
'rust',
|
||||
'python',
|
||||
'cmake',
|
||||
'markdown',
|
||||
'markdown_inline',
|
||||
'diff',
|
||||
'html',
|
||||
'css',
|
||||
'javascript',
|
||||
'json',
|
||||
'yaml',
|
||||
'toml',
|
||||
'lua',
|
||||
'luadoc',
|
||||
'markdown',
|
||||
'markdown_inline',
|
||||
'query',
|
||||
'vim',
|
||||
'vimdoc',
|
||||
}
|
||||
require('nvim-treesitter').install(parsers)
|
||||
|
||||
---@param buf integer
|
||||
@@ -911,8 +915,9 @@ do
|
||||
|
||||
-- Enable treesitter based folds
|
||||
-- For more info on folds see `:help folds`
|
||||
-- vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
|
||||
-- vim.wo.foldmethod = 'expr'
|
||||
vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
|
||||
vim.wo.foldmethod = 'expr'
|
||||
vim.opt.foldlevel = 99
|
||||
|
||||
-- Check if treesitter indentation is available for this language, and if so enable it
|
||||
-- in case there is no indent query, the indentexpr will fallback to the vim's built in one
|
||||
@@ -960,17 +965,17 @@ do
|
||||
-- Here are some example plugins that I've included in the Kickstart repository.
|
||||
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
|
||||
--
|
||||
-- require 'kickstart.plugins.debug'
|
||||
-- require 'kickstart.plugins.indent_line'
|
||||
-- require 'kickstart.plugins.lint'
|
||||
-- require 'kickstart.plugins.autopairs'
|
||||
-- require 'kickstart.plugins.neo-tree'
|
||||
-- require 'kickstart.plugins.gitsigns' -- adds gitsigns recommended keymaps
|
||||
require 'kickstart.plugins.debug'
|
||||
require 'kickstart.plugins.indent_line'
|
||||
require 'kickstart.plugins.lint'
|
||||
require 'kickstart.plugins.autopairs'
|
||||
require 'kickstart.plugins.neo-tree'
|
||||
require 'kickstart.plugins.gitsigns' -- adds gitsigns recommended keymaps
|
||||
|
||||
-- NOTE: You can add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
|
||||
--
|
||||
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
|
||||
-- require 'custom.plugins'
|
||||
require 'custom.plugins'
|
||||
end
|
||||
|
||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||
|
||||
Reference in New Issue
Block a user