config catppuccin
This commit is contained in:
parent
48f2cd89cc
commit
4c0c61640d
258
init.lua
258
init.lua
|
@ -162,10 +162,30 @@ vim.opt.hlsearch = true
|
|||
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
||||
|
||||
-- Diagnostic keymaps
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
|
||||
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',
|
||||
'[d',
|
||||
vim.diagnostic.goto_prev,
|
||||
{ desc = 'Go to previous [D]iagnostic message' }
|
||||
)
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
']d',
|
||||
vim.diagnostic.goto_next,
|
||||
{ desc = 'Go to next [D]iagnostic message' }
|
||||
)
|
||||
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' }
|
||||
)
|
||||
|
||||
-- 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
|
||||
|
@ -173,7 +193,12 @@ vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagn
|
|||
--
|
||||
-- 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' })
|
||||
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>')
|
||||
|
@ -185,10 +210,30 @@ vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' }
|
|||
-- 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' })
|
||||
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' }
|
||||
)
|
||||
|
||||
-- [[ Basic Autocommands ]]
|
||||
-- See `:help lua-guide-autocommands`
|
||||
|
@ -198,7 +243,10 @@ vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper win
|
|||
-- See `:help vim.highlight.on_yank()`
|
||||
vim.api.nvim_create_autocmd('TextYankPost', {
|
||||
desc = 'Highlight when yanking (copying) text',
|
||||
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
|
||||
group = vim.api.nvim_create_augroup(
|
||||
'kickstart-highlight-yank',
|
||||
{ clear = true }
|
||||
),
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
|
@ -209,7 +257,14 @@ vim.api.nvim_create_autocmd('TextYankPost', {
|
|||
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
|
||||
vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
|
||||
vim.fn.system {
|
||||
'git',
|
||||
'clone',
|
||||
'--filter=blob:none',
|
||||
'--branch=stable',
|
||||
lazyrepo,
|
||||
lazypath,
|
||||
}
|
||||
end ---@diagnostic disable-next-line: undefined-field
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
|
@ -376,16 +431,66 @@ require('lazy').setup({
|
|||
|
||||
-- See `:help telescope.builtin`
|
||||
local builtin = require 'telescope.builtin'
|
||||
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
|
||||
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
|
||||
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
|
||||
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
|
||||
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
|
||||
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
|
||||
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
|
||||
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
||||
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
||||
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
'<leader>sh',
|
||||
builtin.help_tags,
|
||||
{ desc = '[S]earch [H]elp' }
|
||||
)
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
'<leader>sk',
|
||||
builtin.keymaps,
|
||||
{ desc = '[S]earch [K]eymaps' }
|
||||
)
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
'<leader>sf',
|
||||
builtin.find_files,
|
||||
{ desc = '[S]earch [F]iles' }
|
||||
)
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
'<leader>ss',
|
||||
builtin.builtin,
|
||||
{ desc = '[S]earch [S]elect Telescope' }
|
||||
)
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
'<leader>sw',
|
||||
builtin.grep_string,
|
||||
{ desc = '[S]earch current [W]ord' }
|
||||
)
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
'<leader>sg',
|
||||
builtin.live_grep,
|
||||
{ desc = '[S]earch by [G]rep' }
|
||||
)
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
'<leader>sd',
|
||||
builtin.diagnostics,
|
||||
{ desc = '[S]earch [D]iagnostics' }
|
||||
)
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
'<leader>sr',
|
||||
builtin.resume,
|
||||
{ desc = '[S]earch [R]esume' }
|
||||
)
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
'<leader>s.',
|
||||
builtin.oldfiles,
|
||||
{ desc = '[S]earch Recent Files ("." for repeat)' }
|
||||
)
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
'<leader><leader>',
|
||||
builtin.buffers,
|
||||
{ desc = '[ ] Find existing buffers' }
|
||||
)
|
||||
|
||||
-- Slightly advanced example of overriding default behavior and theme
|
||||
vim.keymap.set('n', '<leader>/', function()
|
||||
|
@ -459,7 +564,10 @@ require('lazy').setup({
|
|||
-- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
|
||||
-- function will be executed to configure the current buffer
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
|
||||
group = vim.api.nvim_create_augroup(
|
||||
'kickstart-lsp-attach',
|
||||
{ clear = true }
|
||||
),
|
||||
callback = function(event)
|
||||
-- NOTE: Remember that Lua is a real programming language, and as such it is possible
|
||||
-- to define small helper and utility functions so you don't have to repeat yourself.
|
||||
|
@ -467,33 +575,62 @@ require('lazy').setup({
|
|||
-- In this case, we create a function that lets us more easily define mappings specific
|
||||
-- for LSP related items. It sets the mode, buffer and description for us each time.
|
||||
local map = function(keys, func, desc)
|
||||
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
keys,
|
||||
func,
|
||||
{ buffer = event.buf, desc = 'LSP: ' .. desc }
|
||||
)
|
||||
end
|
||||
|
||||
-- Jump to the definition of the word under your cursor.
|
||||
-- This is where a variable was first declared, or where a function is defined, etc.
|
||||
-- To jump back, press <C-t>.
|
||||
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
|
||||
map(
|
||||
'gd',
|
||||
require('telescope.builtin').lsp_definitions,
|
||||
'[G]oto [D]efinition'
|
||||
)
|
||||
|
||||
-- Find references for the word under your cursor.
|
||||
map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
||||
map(
|
||||
'gr',
|
||||
require('telescope.builtin').lsp_references,
|
||||
'[G]oto [R]eferences'
|
||||
)
|
||||
|
||||
-- Jump to the implementation of the word under your cursor.
|
||||
-- Useful when your language has ways of declaring types without an actual implementation.
|
||||
map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
|
||||
map(
|
||||
'gI',
|
||||
require('telescope.builtin').lsp_implementations,
|
||||
'[G]oto [I]mplementation'
|
||||
)
|
||||
|
||||
-- Jump to the type of the word under your cursor.
|
||||
-- Useful when you're not sure what type a variable is and you want to see
|
||||
-- the definition of its *type*, not where it was *defined*.
|
||||
map('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
|
||||
map(
|
||||
'<leader>D',
|
||||
require('telescope.builtin').lsp_type_definitions,
|
||||
'Type [D]efinition'
|
||||
)
|
||||
|
||||
-- Fuzzy find all the symbols in your current document.
|
||||
-- Symbols are things like variables, functions, types, etc.
|
||||
map('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
||||
map(
|
||||
'<leader>ds',
|
||||
require('telescope.builtin').lsp_document_symbols,
|
||||
'[D]ocument [S]ymbols'
|
||||
)
|
||||
|
||||
-- Fuzzy find all the symbols in your current workspace.
|
||||
-- Similar to document symbols, except searches over your entire project.
|
||||
map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||
map(
|
||||
'<leader>ws',
|
||||
require('telescope.builtin').lsp_dynamic_workspace_symbols,
|
||||
'[W]orkspace [S]ymbols'
|
||||
)
|
||||
|
||||
-- Rename the variable under your cursor.
|
||||
-- Most Language Servers support renaming across files, etc.
|
||||
|
@ -518,7 +655,8 @@ require('lazy').setup({
|
|||
-- 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)
|
||||
if client and client.server_capabilities.documentHighlightProvider then
|
||||
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
|
||||
local highlight_augroup =
|
||||
vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
|
||||
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augroup,
|
||||
|
@ -532,10 +670,16 @@ require('lazy').setup({
|
|||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('LspDetach', {
|
||||
group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
|
||||
group = vim.api.nvim_create_augroup(
|
||||
'kickstart-lsp-detach',
|
||||
{ clear = true }
|
||||
),
|
||||
callback = function(event2)
|
||||
vim.lsp.buf.clear_references()
|
||||
vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf }
|
||||
vim.api.nvim_clear_autocmds {
|
||||
group = 'kickstart-lsp-highlight',
|
||||
buffer = event2.buf,
|
||||
}
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
@ -544,7 +688,11 @@ require('lazy').setup({
|
|||
-- 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
|
||||
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')
|
||||
|
@ -557,7 +705,11 @@ require('lazy').setup({
|
|||
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
|
||||
-- So, we create new capabilities with nvim cmp, and then broadcast that to the servers.
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())
|
||||
capabilities = vim.tbl_deep_extend(
|
||||
'force',
|
||||
capabilities,
|
||||
require('cmp_nvim_lsp').default_capabilities()
|
||||
)
|
||||
|
||||
-- Enable the following language servers
|
||||
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
||||
|
@ -628,7 +780,8 @@ require('lazy').setup({
|
|||
-- This handles overriding only values explicitly passed
|
||||
-- by the server configuration above. Useful when disabling
|
||||
-- certain features of an LSP (for example, turning off formatting for tsserver)
|
||||
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
|
||||
server.capabilities =
|
||||
vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
|
||||
require('lspconfig')[server_name].setup(server)
|
||||
end,
|
||||
},
|
||||
|
@ -678,7 +831,7 @@ require('lazy').setup({
|
|||
markdown = { 'prettier' },
|
||||
graphql = { 'prettier' },
|
||||
javascript = { 'prettier', 'prettierd' },
|
||||
lua = {'stylua'},
|
||||
lua = { 'stylua' },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -821,6 +974,10 @@ require('lazy').setup({
|
|||
nvimtree = true,
|
||||
treesitter = true,
|
||||
notify = false,
|
||||
rainbow_delimiters = true,
|
||||
telescope = {
|
||||
enabled = true,
|
||||
},
|
||||
mini = {
|
||||
enabled = true,
|
||||
indentscope_color = '',
|
||||
|
@ -893,7 +1050,15 @@ require('lazy').setup({
|
|||
footer = function()
|
||||
local stats = require('lazy').stats()
|
||||
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
|
||||
return { '⚡ Neovim loaded ' .. stats.loaded .. '/' .. stats.count .. ' plugins in ' .. ms .. 'ms' }
|
||||
return {
|
||||
'⚡ Neovim loaded '
|
||||
.. stats.loaded
|
||||
.. '/'
|
||||
.. stats.count
|
||||
.. ' plugins in '
|
||||
.. ms
|
||||
.. 'ms',
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
@ -919,7 +1084,12 @@ require('lazy').setup({
|
|||
},
|
||||
|
||||
-- Highlight todo, notes, etc in comments
|
||||
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
|
||||
{
|
||||
'folke/todo-comments.nvim',
|
||||
event = 'VimEnter',
|
||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
||||
opts = { signs = false },
|
||||
},
|
||||
|
||||
{ -- Collection of various small independent plugins/modules
|
||||
'echasnovski/mini.nvim',
|
||||
|
@ -967,6 +1137,7 @@ require('lazy').setup({
|
|||
'bash',
|
||||
'c',
|
||||
'html',
|
||||
'css',
|
||||
'lua',
|
||||
'luadoc',
|
||||
'javascript',
|
||||
|
@ -1006,12 +1177,15 @@ require('lazy').setup({
|
|||
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
|
||||
end,
|
||||
},
|
||||
{'romgrk/barbar.nvim',
|
||||
{
|
||||
'romgrk/barbar.nvim',
|
||||
dependencies = {
|
||||
'lewis6991/gitsigns.nvim', -- OPTIONAL: for git status
|
||||
'nvim-tree/nvim-web-devicons', -- OPTIONAL: for file icons
|
||||
},
|
||||
init = function() vim.g.barbar_auto_setup = false end,
|
||||
init = function()
|
||||
vim.g.barbar_auto_setup = false
|
||||
end,
|
||||
opts = {
|
||||
-- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default:
|
||||
-- animation = true,
|
||||
|
@ -1020,8 +1194,8 @@ require('lazy').setup({
|
|||
},
|
||||
version = '^1.0.0', -- optional: only update when a new 1.x version is released
|
||||
},
|
||||
{'tpope/vim-fugitive'},
|
||||
{'HiPhish/rainbow-delimiters.nvim'},
|
||||
{ 'tpope/vim-fugitive' },
|
||||
{ 'HiPhish/rainbow-delimiters.nvim' },
|
||||
-- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the
|
||||
-- init.lua. If you want these files, they are in the repository, so you can just download them and
|
||||
-- place them in the correct locations.
|
||||
|
|
Loading…
Reference in New Issue