new keymap and bg
This commit is contained in:
parent
8df3deb6fe
commit
e9d83b045d
137
init.lua
137
init.lua
|
|
@ -22,59 +22,59 @@
|
||||||
|
|
||||||
What is Kickstart?
|
What is Kickstart?
|
||||||
|
|
||||||
Kickstart.nvim is *not* a distribution.
|
Kickstart.nvim is *not* a distribution.
|
||||||
|
|
||||||
Kickstart.nvim is a starting point for your own configuration.
|
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
|
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.
|
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
|
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
|
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!
|
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
|
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:
|
a guide. One possible example which will only take 10-15 minutes:
|
||||||
- https://learnxinyminutes.com/docs/lua/
|
- https://learnxinyminutes.com/docs/lua/
|
||||||
|
|
||||||
After understanding a bit more about Lua, you can use `:help lua-guide` as a
|
After understanding a bit more about Lua, you can use `:help lua-guide` as a
|
||||||
reference for how Neovim integrates Lua.
|
reference for how Neovim integrates Lua.
|
||||||
- :help lua-guide
|
- :help lua-guide
|
||||||
- (or HTML version): https://neovim.io/doc/user/lua-guide.html
|
- (or HTML version): https://neovim.io/doc/user/lua-guide.html
|
||||||
|
|
||||||
Kickstart Guide:
|
Kickstart Guide:
|
||||||
|
|
||||||
TODO: The very first thing you should do is to run the command `:Tutor` in Neovim.
|
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:
|
If you don't know what this means, type the following:
|
||||||
- <escape key>
|
- <escape key>
|
||||||
- :
|
- :
|
||||||
- Tutor
|
- Tutor
|
||||||
- <enter key>
|
- <enter key>
|
||||||
|
|
||||||
(If you already know the Neovim basics, you can skip this step.)
|
(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
|
Once you've completed that, you can continue working through **AND READING** the rest
|
||||||
of the kickstart init.lua.
|
of the kickstart init.lua.
|
||||||
|
|
||||||
Next, run AND READ `:help`.
|
Next, run AND READ `:help`.
|
||||||
This will open up a help window with some basic information
|
This will open up a help window with some basic information
|
||||||
about reading, navigating and searching the builtin help documentation.
|
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
|
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.
|
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,
|
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.
|
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
|
I have left several `:help X` comments throughout the init.lua
|
||||||
These are hints about where to find more information about the relevant settings,
|
These are hints about where to find more information about the relevant settings,
|
||||||
plugins or Neovim features used in Kickstart.
|
plugins or Neovim features used in Kickstart.
|
||||||
|
|
||||||
NOTE: Look for lines like this
|
NOTE: Look for lines like this
|
||||||
|
|
||||||
Throughout the file. These are for you, the reader, to help you understand what is happening.
|
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
|
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.
|
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.
|
If you experience any errors while trying to install kickstart, run `:checkhealth` for more info.
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ P.S. You can delete this when you're done too. It's your config now! :)
|
||||||
vim.g.mapleader = ' '
|
vim.g.mapleader = ' '
|
||||||
vim.g.maplocalleader = ' '
|
vim.g.maplocalleader = ' '
|
||||||
|
|
||||||
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
-- Set to true if you have a Nerd Font installed
|
||||||
vim.g.have_nerd_font = false
|
vim.g.have_nerd_font = false
|
||||||
|
|
||||||
-- [[ Setting options ]]
|
-- [[ Setting options ]]
|
||||||
|
|
@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
|
||||||
vim.opt.number = true
|
vim.opt.number = true
|
||||||
-- You can also add relative line numbers, to help with jumping.
|
-- You can also add relative line numbers, to help with jumping.
|
||||||
-- Experiment for yourself to see if you like it!
|
-- Experiment for yourself to see if you like it!
|
||||||
-- vim.opt.relativenumber = true
|
vim.opt.relativenumber = true
|
||||||
|
|
||||||
-- Enable mouse mode, can be useful for resizing splits for example!
|
-- Enable mouse mode, can be useful for resizing splits for example!
|
||||||
vim.opt.mouse = 'a'
|
vim.opt.mouse = 'a'
|
||||||
|
|
@ -159,6 +159,7 @@ vim.opt.scrolloff = 10
|
||||||
|
|
||||||
-- Set highlight on search, but clear on pressing <Esc> in normal mode
|
-- Set highlight on search, but clear on pressing <Esc> in normal mode
|
||||||
vim.opt.hlsearch = true
|
vim.opt.hlsearch = true
|
||||||
|
vim.opt.incsearch = true
|
||||||
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
||||||
|
|
||||||
-- Diagnostic keymaps
|
-- Diagnostic keymaps
|
||||||
|
|
@ -167,6 +168,21 @@ vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagn
|
||||||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
|
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
|
||||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
|
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
|
||||||
|
|
||||||
|
-- Move highlighted text
|
||||||
|
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv")
|
||||||
|
vim.keymap.set('v', 'K', ":m '<-2<CR>gv=gv")
|
||||||
|
|
||||||
|
-- Move half page jumping with cursor in middle
|
||||||
|
vim.keymap.set('n', 'n', 'nzzzv')
|
||||||
|
vim.keymap.set('n', 'N', 'Nzzzv')
|
||||||
|
|
||||||
|
-- Search with cursor in the middle
|
||||||
|
vim.keymap.set('n', '<C-d>', '<C-d>zz')
|
||||||
|
vim.keymap.set('n', '<C-u>', '<C-u>zz')
|
||||||
|
|
||||||
|
-- Greatest remap ever
|
||||||
|
vim.keymap.set('x', '<leader>p', '"_dP')
|
||||||
|
|
||||||
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
|
-- 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
|
-- 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.
|
-- is not what someone will guess without a bit more experience.
|
||||||
|
|
@ -286,13 +302,7 @@ require('lazy').setup({
|
||||||
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
|
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
|
||||||
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
|
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
|
||||||
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
|
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
|
||||||
['<leader>t'] = { name = '[T]oggle', _ = 'which_key_ignore' },
|
|
||||||
['<leader>h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' },
|
|
||||||
}
|
}
|
||||||
-- visual mode
|
|
||||||
require('which-key').register({
|
|
||||||
['<leader>h'] = { 'Git [H]unk' },
|
|
||||||
}, { mode = 'v' })
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -412,7 +422,7 @@ require('lazy').setup({
|
||||||
'neovim/nvim-lspconfig',
|
'neovim/nvim-lspconfig',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
-- Automatically install LSPs and related tools to stdpath for Neovim
|
-- Automatically install LSPs and related tools to stdpath for Neovim
|
||||||
{ 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants
|
'williamboman/mason.nvim',
|
||||||
'williamboman/mason-lspconfig.nvim',
|
'williamboman/mason-lspconfig.nvim',
|
||||||
'WhoIsSethDaniel/mason-tool-installer.nvim',
|
'WhoIsSethDaniel/mason-tool-installer.nvim',
|
||||||
|
|
||||||
|
|
@ -514,37 +524,16 @@ require('lazy').setup({
|
||||||
-- When you move your cursor, the highlights will be cleared (the second autocommand).
|
-- When you move your cursor, the highlights will be cleared (the second autocommand).
|
||||||
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
||||||
if client and client.server_capabilities.documentHighlightProvider then
|
if client and client.server_capabilities.documentHighlightProvider then
|
||||||
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
|
|
||||||
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
|
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
|
||||||
buffer = event.buf,
|
buffer = event.buf,
|
||||||
group = highlight_augroup,
|
|
||||||
callback = vim.lsp.buf.document_highlight,
|
callback = vim.lsp.buf.document_highlight,
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
|
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
|
||||||
buffer = event.buf,
|
buffer = event.buf,
|
||||||
group = highlight_augroup,
|
|
||||||
callback = vim.lsp.buf.clear_references,
|
callback = vim.lsp.buf.clear_references,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- The following autocommand is used to enable inlay hints in your
|
|
||||||
-- code, if the language server you are using supports them
|
|
||||||
--
|
|
||||||
-- This may be unwanted, since they displace some of your code
|
|
||||||
if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
|
|
||||||
map('<leader>th', function()
|
|
||||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
|
|
||||||
end, '[T]oggle Inlay [H]ints')
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('LspDetach', {
|
|
||||||
group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
|
|
||||||
callback = function(event)
|
|
||||||
vim.lsp.buf.clear_references()
|
|
||||||
vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event.buf }
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -731,12 +720,6 @@ require('lazy').setup({
|
||||||
-- This will expand snippets if the LSP sent a snippet.
|
-- This will expand snippets if the LSP sent a snippet.
|
||||||
['<C-y>'] = cmp.mapping.confirm { select = true },
|
['<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.
|
-- Manually trigger a completion from nvim-cmp.
|
||||||
-- Generally you don't need this, because nvim-cmp will display
|
-- Generally you don't need this, because nvim-cmp will display
|
||||||
-- completions whenever it has completion options available.
|
-- completions whenever it has completion options available.
|
||||||
|
|
@ -785,7 +768,8 @@ require('lazy').setup({
|
||||||
-- Like many other themes, this one has different styles, and you could load
|
-- Like many other themes, this one has different styles, and you could load
|
||||||
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
|
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
|
||||||
vim.cmd.colorscheme 'tokyonight-night'
|
vim.cmd.colorscheme 'tokyonight-night'
|
||||||
|
vim.api.nvim_set_hl(0, 'Normal', { bg = 'none' })
|
||||||
|
vim.api.nvim_set_hl(0, 'NormalFloat', { bg = 'none' })
|
||||||
-- You can configure highlights by doing something like:
|
-- You can configure highlights by doing something like:
|
||||||
vim.cmd.hi 'Comment gui=none'
|
vim.cmd.hi 'Comment gui=none'
|
||||||
end,
|
end,
|
||||||
|
|
@ -850,8 +834,6 @@ require('lazy').setup({
|
||||||
config = function(_, opts)
|
config = function(_, opts)
|
||||||
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
||||||
|
|
||||||
-- Prefer git instead of curl in order to improve connectivity in some environments
|
|
||||||
require('nvim-treesitter.install').prefer_git = true
|
|
||||||
---@diagnostic disable-next-line: missing-fields
|
---@diagnostic disable-next-line: missing-fields
|
||||||
require('nvim-treesitter.configs').setup(opts)
|
require('nvim-treesitter.configs').setup(opts)
|
||||||
|
|
||||||
|
|
@ -876,9 +858,6 @@ require('lazy').setup({
|
||||||
-- require 'kickstart.plugins.debug',
|
-- require 'kickstart.plugins.debug',
|
||||||
-- require 'kickstart.plugins.indent_line',
|
-- require 'kickstart.plugins.indent_line',
|
||||||
-- require 'kickstart.plugins.lint',
|
-- require 'kickstart.plugins.lint',
|
||||||
-- require 'kickstart.plugins.autopairs',
|
|
||||||
-- require 'kickstart.plugins.neo-tree',
|
|
||||||
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
|
|
||||||
|
|
||||||
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
|
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
|
||||||
-- This is the easiest way to modularize your config.
|
-- This is the easiest way to modularize your config.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue