Skip to content

Commit 3e6a648

Browse files
Split config into multiple files based on kickstart.modular
1 parent 62f8ac3 commit 3e6a648

23 files changed

+1254
-1102
lines changed

init.lua

Lines changed: 4 additions & 936 deletions
Large diffs are not rendered by default.

lua/keymaps.lua

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
-- [[ Basic Keymaps ]]
2+
-- See `:help vim.keymap.set()`
3+
4+
-- Clear highlights on search when pressing <Esc> in normal mode
5+
-- See `:help hlsearch`
6+
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
7+
8+
-- Diagnostic keymaps
9+
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
10+
11+
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
12+
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
13+
-- is not what someone will guess without a bit more experience.
14+
--
15+
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
16+
-- or just use <C-\><C-n> to exit terminal mode
17+
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
18+
19+
-- Keybinds to make split navigation easier.
20+
-- Use CTRL+<hjkl> to switch between windows
21+
--
22+
-- See `:help wincmd` for a list of all window commands
23+
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
24+
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
25+
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
26+
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
27+
28+
-- [[ Basic Autocommands ]]
29+
-- See `:help lua-guide-autocommands`
30+
31+
-- Highlight when yanking (copying) text
32+
-- Try it with `yap` in normal mode
33+
-- See `:help vim.highlight.on_yank()`
34+
vim.api.nvim_create_autocmd('TextYankPost', {
35+
desc = 'Highlight when yanking (copying) text',
36+
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
37+
callback = function()
38+
vim.highlight.on_yank()
39+
end,
40+
})
41+
42+
-- Disables virtual_text and turns virtual_line on
43+
-- when there is a diagnostic on the current line
44+
-- Taken from :
45+
-- https://www.reddit.com/r/neovim/comments/1jpbc7s/disable_virtual_text_if_there_is_diagnostic_in/
46+
local og_virt_text
47+
local og_virt_line
48+
vim.api.nvim_create_autocmd({ 'CursorMoved', 'DiagnosticChanged' }, {
49+
group = vim.api.nvim_create_augroup('diagnostic_only_virtlines', {}),
50+
callback = function()
51+
if og_virt_line == nil then
52+
og_virt_line = vim.diagnostic.config().virtual_lines
53+
end
54+
55+
-- ignore if virtual_lines.current_line is disabled
56+
if not (og_virt_line and og_virt_line.current_line) then
57+
if og_virt_text then
58+
vim.diagnostic.config { virtual_text = og_virt_text }
59+
og_virt_text = nil
60+
end
61+
return
62+
end
63+
64+
if og_virt_text == nil then
65+
og_virt_text = vim.diagnostic.config().virtual_text
66+
end
67+
68+
local lnum = vim.api.nvim_win_get_cursor(0)[1] - 1
69+
70+
if vim.tbl_isempty(vim.diagnostic.get(0, { lnum = lnum })) then
71+
vim.diagnostic.config { virtual_text = og_virt_text }
72+
else
73+
vim.diagnostic.config { virtual_text = false }
74+
end
75+
end,
76+
})
77+
78+
-- immediately redraw the diagnostics when the mode changes
79+
-- Taken from :
80+
-- https://www.reddit.com/r/neovim/comments/1jpbc7s/disable_virtual_text_if_there_is_diagnostic_in/
81+
vim.api.nvim_create_autocmd('ModeChanged', {
82+
group = vim.api.nvim_create_augroup('diagnostic_redraw', {}),
83+
callback = function()
84+
pcall(vim.diagnostic.show)
85+
end,
86+
})
87+
88+
-- Auto import for gopls
89+
vim.api.nvim_create_autocmd('BufWritePre', {
90+
pattern = '*.go',
91+
callback = function()
92+
local params = vim.lsp.util.make_range_params()
93+
params.context = { only = { 'source.organizeImports' } }
94+
-- buf_request_sync defaults to a 1000ms timeout. Depending on your
95+
-- machine and codebase, you may want longer. Add an additional
96+
-- argument after params if you find that you have to write the file
97+
-- twice for changes to be saved.
98+
-- E.g., vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 3000)
99+
local result = vim.lsp.buf_request_sync(0, 'textDocument/codeAction', params)
100+
for cid, res in pairs(result or {}) do
101+
for _, r in pairs(res.result or {}) do
102+
if r.edit then
103+
local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or 'utf-16'
104+
vim.lsp.util.apply_workspace_edit(r.edit, enc)
105+
end
106+
end
107+
end
108+
vim.lsp.buf.format { async = false }
109+
end,
110+
})
111+
112+
-- adding the .slint filetype to the list of filetypes that neovim can recognize
113+
vim.cmd [[
114+
augroup _slint
115+
autocmd!
116+
autocmd BufRead,BufEnter *.slint set filetype=slint
117+
augroup end
118+
]]

lua/kickstart/plugins/autopairs.lua

Lines changed: 0 additions & 16 deletions
This file was deleted.

lua/kickstart/plugins/gitsigns.lua

Lines changed: 0 additions & 61 deletions
This file was deleted.

lua/kickstart/plugins/indent_line.lua

Lines changed: 0 additions & 9 deletions
This file was deleted.

lua/kickstart/plugins/lint.lua

Lines changed: 0 additions & 55 deletions
This file was deleted.

lua/kickstart/plugins/neo-tree.lua

Lines changed: 0 additions & 25 deletions
This file was deleted.

lua/lazy-bootstrap.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- [[ Install `lazy.nvim` plugin manager ]]
2+
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
3+
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
4+
if not (vim.uv or vim.loop).fs_stat(lazypath) then
5+
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
6+
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
7+
if vim.v.shell_error ~= 0 then
8+
error('Error cloning lazy.nvim:\n' .. out)
9+
end
10+
end ---@diagnostic disable-next-line: undefined-field
11+
vim.opt.rtp:prepend(lazypath)

lua/lazy-plugins.lua

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
-- [[ Configure and install plugins ]]
2+
--
3+
-- To check the current status of your plugins, run
4+
-- :Lazy
5+
--
6+
-- You can press `?` in this menu for help. Use `:q` to close the window
7+
--
8+
-- To update plugins you can run
9+
-- :Lazy update
10+
--
11+
-- NOTE: Here is where you install your plugins.
12+
require('lazy').setup({
13+
-- Themes
14+
require 'themes/catppuccin',
15+
16+
-- Big Config Plugins
17+
require 'plugins/snacks',
18+
require 'plugins/which-key',
19+
require 'plugins/telescope',
20+
21+
-- LSP Plugins
22+
require 'plugins/lazydev',
23+
{ 'Bilal2453/luvit-meta', lazy = true }, -- I don't remember what this does and I am too scared to remove it
24+
{
25+
'brenoprata10/nvim-highlight-colors',
26+
config = function()
27+
require('nvim-highlight-colors').turnOn()
28+
end,
29+
},
30+
require 'plugins/lspconfig', -- Main LSP Configuration
31+
require 'plugins/conform', -- Autoformat
32+
require 'plugins/treesitter',
33+
-- TODO: Eventually replace with blink.cmp
34+
require 'plugins/nvim-cmp', -- Autocompletion
35+
-- Highlight todo, notes, etc in comments
36+
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
37+
38+
-- General Plugins
39+
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
40+
'sitiom/nvim-numbertoggle',
41+
require 'plugins/gitsigns', -- Adds git related signs to the gutter, as well as utilities for managing changes
42+
require 'plugins/mini',
43+
require 'plugins/oil', -- Edit files like a vim buffer
44+
require 'plugins/vimtex', -- Latex file editing
45+
-- TODO: properly configure nvim dap
46+
require 'kickstart.plugins.debug', -- Neovim debug adapter
47+
48+
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
49+
-- This is the easiest way to modularize your config.
50+
--
51+
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
52+
-- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
53+
-- { import = 'custom.plugins' },
54+
}, {
55+
ui = {
56+
-- If you are using a Nerd Font: set icons to an empty table which will use the
57+
-- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table
58+
icons = vim.g.have_nerd_font and {} or {
59+
cmd = '',
60+
config = '🛠',
61+
event = '📅',
62+
ft = '📂',
63+
init = '',
64+
keys = '🗝',
65+
plugin = '🔌',
66+
runtime = '💻',
67+
require = '🌙',
68+
source = '📄',
69+
start = '🚀',
70+
task = '📌',
71+
lazy = '💤 ',
72+
},
73+
},
74+
})

0 commit comments

Comments
 (0)