Skip to content

Commit ad5d345

Browse files
nvim-config
1 parent 3338d39 commit ad5d345

File tree

14 files changed

+563
-33
lines changed

14 files changed

+563
-33
lines changed

Makefile

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
.PHONY: install update clean backup install-fonts install-brew link help
2+
3+
NVIM_DIR := $(HOME)/.config/nvim
4+
BACKUP_DIR := $(HOME)/.config/nvim-backup-$(shell date +%Y%m%d-%H%M%S)
5+
6+
# Detect OS
7+
UNAME_S := $(shell uname -s)
8+
9+
# Default Nerd Fonts to install (can be overridden)
10+
NERD_FONTS ?= font-jetbrains-mono-nerd-font font-fira-code-nerd-font font-hack-nerd-font font-meslo-lg-nerd-font
11+
12+
help:
13+
@echo "Neovim Configuration Management"
14+
@echo "================================"
15+
@echo "install - Install/sync all plugins via lazy.nvim"
16+
@echo "update - Update all plugins to latest versions"
17+
@echo "clean - Clean plugin cache and unused plugins"
18+
@echo "backup - Backup current configuration"
19+
@echo "link - Create symlink from current directory to ~/.config/nvim"
20+
@echo "install-fonts - Install Nerd Fonts (macOS: via brew)"
21+
@echo "install-brew - Install Homebrew (macOS only)"
22+
@echo ""
23+
@echo "Environment Variables:"
24+
@echo " NERD_FONTS - Space-separated list of fonts to install"
25+
@echo " Default: JetBrains Mono, Fira Code, Hack, Meslo LG"
26+
27+
install:
28+
@echo "Installing/syncing Neovim plugins..."
29+
nvim --headless "+Lazy! sync" +qa
30+
@echo "✓ Plugins installed successfully"
31+
32+
update:
33+
@echo "Updating Neovim plugins..."
34+
nvim --headless "+Lazy! update" +qa
35+
@echo "✓ Plugins updated successfully"
36+
37+
clean:
38+
@echo "Cleaning plugin cache..."
39+
nvim --headless "+Lazy! clean" +qa
40+
@echo "✓ Cache cleaned successfully"
41+
42+
backup:
43+
@echo "Backing up configuration to $(BACKUP_DIR)..."
44+
@cp -r $(NVIM_DIR) $(BACKUP_DIR)
45+
@echo "✓ Backup created at $(BACKUP_DIR)"
46+
47+
link:
48+
@echo "Creating symlink to ~/.config/nvim..."
49+
@if [ -e $(NVIM_DIR) ] || [ -L $(NVIM_DIR) ]; then \
50+
if [ -L $(NVIM_DIR) ]; then \
51+
current_target=$$(readlink $(NVIM_DIR)); \
52+
if [ "$$current_target" = "$(CURDIR)" ]; then \
53+
echo "✓ Symlink already points to $(CURDIR)"; \
54+
exit 0; \
55+
fi; \
56+
fi; \
57+
echo "$(NVIM_DIR) already exists"; \
58+
backup_dir=$(HOME)/.config/nvim-backup-$$(date +%Y%m%d-%H%M%S); \
59+
echo "Creating backup at $$backup_dir..."; \
60+
mv $(NVIM_DIR) $$backup_dir; \
61+
echo "✓ Backup created at $$backup_dir"; \
62+
fi
63+
@mkdir -p $(HOME)/.config
64+
@ln -s $(CURDIR) $(NVIM_DIR)
65+
@echo "✓ Symlink created: $(NVIM_DIR) -> $(CURDIR)"
66+
67+
install-brew:
68+
ifeq ($(UNAME_S),Darwin)
69+
@if ! command -v brew >/dev/null 2>&1; then \
70+
echo "Installing Homebrew..."; \
71+
/bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; \
72+
echo "✓ Homebrew installed successfully"; \
73+
else \
74+
echo "✓ Homebrew already installed"; \
75+
fi
76+
else
77+
@echo "⚠ Homebrew installation is only supported on macOS"
78+
endif
79+
80+
install-fonts: install-brew
81+
ifeq ($(UNAME_S),Darwin)
82+
@echo "Installing Nerd Fonts on macOS..."
83+
@for font in $(NERD_FONTS); do \
84+
echo "Installing $$font..."; \
85+
brew install --cask $$font || echo "⚠ Failed to install $$font"; \
86+
done
87+
@echo "✓ Nerd Fonts installation complete"
88+
else ifeq ($(UNAME_S),Linux)
89+
@echo "Installing Nerd Fonts on Linux..."
90+
@mkdir -p $(HOME)/.local/share/fonts
91+
@for font in $(NERD_FONTS); do \
92+
font_name=$$(echo $$font | sed 's/font-//;s/-nerd-font//;s/-/ /g'); \
93+
echo "Downloading $$font_name..."; \
94+
curl -fLo "$(HOME)/.local/share/fonts/$$font.zip" \
95+
"https://github.com/ryanoasis/nerd-fonts/releases/latest/download/$$font_name.zip" || \
96+
echo "⚠ Failed to download $$font"; \
97+
unzip -o "$(HOME)/.local/share/fonts/$$font.zip" -d "$(HOME)/.local/share/fonts/" 2>/dev/null || true; \
98+
rm -f "$(HOME)/.local/share/fonts/$$font.zip"; \
99+
done
100+
@fc-cache -fv
101+
@echo "✓ Nerd Fonts installation complete"
102+
else
103+
@echo "⚠ Unsupported OS: $(UNAME_S)"
104+
endif

init.lua

Lines changed: 94 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,59 @@ require('lazy').setup({
698698
},
699699
},
700700
},
701+
702+
-- TypeScript
703+
ts_ls = {
704+
settings = {
705+
typescript = {
706+
inlayHints = {
707+
includeInlayParameterNameHints = 'all',
708+
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
709+
includeInlayFunctionParameterTypeHints = true,
710+
includeInlayVariableTypeHints = true,
711+
includeInlayPropertyDeclarationTypeHints = true,
712+
includeInlayFunctionLikeReturnTypeHints = true,
713+
includeInlayEnumMemberValueHints = true,
714+
},
715+
},
716+
javascript = {
717+
inlayHints = {
718+
includeInlayParameterNameHints = 'all',
719+
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
720+
includeInlayFunctionParameterTypeHints = true,
721+
includeInlayVariableTypeHints = true,
722+
includeInlayPropertyDeclarationTypeHints = true,
723+
includeInlayFunctionLikeReturnTypeHints = true,
724+
includeInlayEnumMemberValueHints = true,
725+
},
726+
},
727+
},
728+
},
729+
730+
-- Python
731+
pyright = {
732+
settings = {
733+
python = {
734+
analysis = {
735+
autoSearchPaths = true,
736+
diagnosticMode = 'workspace',
737+
useLibraryCodeForTypes = true,
738+
typeCheckingMode = 'basic',
739+
},
740+
},
741+
},
742+
},
743+
744+
-- Terraform
745+
terraformls = {
746+
settings = {
747+
terraform = {
748+
experimentalFeatures = {
749+
validateOnSave = true,
750+
},
751+
},
752+
},
753+
},
701754
}
702755

703756
-- Ensure the servers and tools above are installed
@@ -716,6 +769,9 @@ require('lazy').setup({
716769
local ensure_installed = vim.tbl_keys(servers or {})
717770
vim.list_extend(ensure_installed, {
718771
'stylua', -- Used to format Lua code
772+
'prettier', -- Formatter for TypeScript/JavaScript
773+
'black', -- Formatter for Python
774+
'isort', -- Python import sorting
719775
})
720776
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
721777

@@ -876,27 +932,28 @@ require('lazy').setup({
876932
},
877933
},
878934

879-
{ -- You can easily change to a different colorscheme.
880-
-- Change the name of the colorscheme plugin below, and then
881-
-- change the command in the config to whatever the name of that colorscheme is.
882-
--
883-
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
884-
'folke/tokyonight.nvim',
885-
priority = 1000, -- Make sure to load this before all the other start plugins.
886-
config = function()
887-
---@diagnostic disable-next-line: missing-fields
888-
require('tokyonight').setup {
889-
styles = {
890-
comments = { italic = false }, -- Disable italics in comments
891-
},
892-
}
893-
894-
-- Load the colorscheme here.
895-
-- Like many other themes, this one has different styles, and you could load
896-
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
897-
vim.cmd.colorscheme 'tokyonight-night'
898-
end,
899-
},
935+
-- { -- You can easily change to a different colorscheme.
936+
-- -- Change the name of the colorscheme plugin below, and then
937+
-- -- change the command in the config to whatever the name of that colorscheme is.
938+
-- --
939+
-- -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
940+
-- 'folke/tokyonight.nvim',
941+
-- priority = 1000, -- Make sure to load this before all the other start plugins.
942+
-- config = function()
943+
-- ---@diagnostic disable-next-line: missing-fields
944+
-- require('tokyonight').setup {
945+
-- styles = {
946+
-- comments = { italic = false }, -- Disable italics in comments
947+
-- },
948+
-- }
949+
--
950+
-- -- Load the colorscheme here.
951+
-- -- Like many other themes, this one has different styles, and you could load
952+
-- -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
953+
-- vim.cmd.colorscheme 'tokyonight-night'
954+
-- end,
955+
-- },
956+
-- NOTE: TokyoNight is disabled in favor of Gruvbox (configured in lua/custom/plugins/gruvbox.lua)
900957

901958
-- Highlight todo, notes, etc in comments
902959
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
@@ -922,17 +979,18 @@ require('lazy').setup({
922979
-- Simple and easy statusline.
923980
-- You could remove this setup call if you don't like it,
924981
-- and try some other statusline plugin
925-
local statusline = require 'mini.statusline'
926-
-- set use_icons to true if you have a Nerd Font
927-
statusline.setup { use_icons = vim.g.have_nerd_font }
928-
929-
-- You can configure sections in the statusline by overriding their
930-
-- default behavior. For example, here we set the section for
931-
-- cursor location to LINE:COLUMN
932-
---@diagnostic disable-next-line: duplicate-set-field
933-
statusline.section_location = function()
934-
return '%2l:%-2v'
935-
end
982+
-- NOTE: mini.statusline is disabled in favor of lualine (configured in lua/custom/plugins/lualine.lua)
983+
-- local statusline = require 'mini.statusline'
984+
-- -- set use_icons to true if you have a Nerd Font
985+
-- statusline.setup { use_icons = vim.g.have_nerd_font }
986+
--
987+
-- -- You can configure sections in the statusline by overriding their
988+
-- -- default behavior. For example, here we set the section for
989+
-- -- cursor location to LINE:COLUMN
990+
-- ---@diagnostic disable-next-line: duplicate-set-field
991+
-- statusline.section_location = function()
992+
-- return '%2l:%-2v'
993+
-- end
936994

937995
-- ... and there is more!
938996
-- Check out: https://github.com/echasnovski/mini.nvim
@@ -984,7 +1042,7 @@ require('lazy').setup({
9841042
-- This is the easiest way to modularize your config.
9851043
--
9861044
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
987-
-- { import = 'custom.plugins' },
1045+
{ import = 'custom.plugins' },
9881046
--
9891047
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
9901048
-- Or use telescope!
@@ -1012,5 +1070,8 @@ require('lazy').setup({
10121070
},
10131071
})
10141072

1073+
-- Load custom keymaps
1074+
require('custom.keymaps')
1075+
10151076
-- The line beneath this is called `modeline`. See `:help modeline`
10161077
-- vim: ts=2 sts=2 sw=2 et

lua/custom/keymaps/files.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- File navigation and Telescope-related keybindings
2+
3+
-- File explorer
4+
vim.keymap.set('n', '<leader>e', ':NvimTreeToggle<CR>', { desc = 'Toggle file explorer' })
5+
vim.keymap.set('n', '<leader>fb', ':Telescope file_browser<CR>', { desc = 'Telescope file browser' })
6+
7+
-- Telescope pickers (additional to Kickstart defaults)
8+
-- Note: These require telescope to be loaded, so we'll use pcall for safety
9+
local ok, telescope_builtin = pcall(require, 'telescope.builtin')
10+
if ok then
11+
vim.keymap.set('n', '<leader>ff', telescope_builtin.find_files, { desc = 'Find files' })
12+
vim.keymap.set('n', '<leader>fg', telescope_builtin.live_grep, { desc = 'Live grep' })
13+
vim.keymap.set('n', '<leader>fh', telescope_builtin.help_tags, { desc = 'Search help' })
14+
vim.keymap.set('n', '<leader>fr', telescope_builtin.oldfiles, { desc = 'Recent files' })
15+
vim.keymap.set('n', '<leader>fc', telescope_builtin.current_buffer_fuzzy_find, { desc = 'Search in current buffer' })
16+
end

lua/custom/keymaps/general.lua

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
-- General keymaps for navigation, editing, and window management
2+
3+
-- Exit insert mode with jj
4+
vim.keymap.set('i', 'jj', '<Esc>', { desc = 'Exit insert mode' })
5+
6+
-- Split management
7+
vim.keymap.set('n', 'sj', '<C-W>w', { desc = 'Move to next window' })
8+
vim.keymap.set('n', 'sk', '<C-W>W', { desc = 'Move to previous window' })
9+
vim.keymap.set('n', 'su', ':resize +5<CR>', { desc = 'Increase window height' })
10+
vim.keymap.set('n', 'si', ':resize -5<CR>', { desc = 'Decrease window height' })
11+
vim.keymap.set('n', 'sh', ':vertical resize +5<CR>', { desc = 'Increase window width' })
12+
vim.keymap.set('n', 'sl', ':vertical resize -5<CR>', { desc = 'Decrease window width' })
13+
vim.keymap.set('n', 'sd', ':hide<CR>', { desc = 'Hide current window' })
14+
vim.keymap.set('n', 'so', ':', { desc = 'Open command mode' })
15+
vim.keymap.set('n', 'ss', ':split ', { desc = 'Horizontal split' })
16+
vim.keymap.set('n', 'sv', ':vsplit ', { desc = 'Vertical split' })
17+
18+
-- Tab management
19+
vim.keymap.set('n', 'th', ':tabfirst<CR>', { desc = 'Go to first tab' })
20+
vim.keymap.set('n', 'tj', ':tabnext<CR>', { desc = 'Go to next tab' })
21+
vim.keymap.set('n', 'tk', ':tabprev<CR>', { desc = 'Go to previous tab' })
22+
vim.keymap.set('n', 'tl', ':tablast<CR>', { desc = 'Go to last tab' })
23+
vim.keymap.set('n', 'tt', ':tabedit ', { desc = 'Create new tab' })
24+
vim.keymap.set('n', 'tn', ':tabnext<CR>', { desc = 'Go to next tab' })
25+
vim.keymap.set('n', 'tm', ':tabm ', { desc = 'Move tab' })
26+
vim.keymap.set('n', 'td', ':tabclose<CR>', { desc = 'Close tab' })
27+
28+
-- Buffer management
29+
vim.keymap.set('n', '<C-k>', ':bnext<CR>', { desc = 'Next buffer' })
30+
vim.keymap.set('n', '<C-j>', ':bprev<CR>', { desc = 'Previous buffer' })
31+
vim.keymap.set('n', '<leader>bd', ':bdelete<CR>', { desc = 'Close current buffer' })
32+
33+
-- Python debugging
34+
vim.keymap.set('n', '<leader>p', 'oimport ipdb; ipdb.set_trace()<Esc>', { desc = 'Insert Python debugger breakpoint' })

lua/custom/keymaps/git.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Git-related keymaps
2+
3+
-- LazyGit
4+
vim.keymap.set('n', '<leader>gg', ':LazyGit<CR>', { desc = 'Open LazyGit' })
5+
vim.keymap.set('n', '<leader>gc', ':LazyGitCurrentFile<CR>', { desc = 'LazyGit current file' })
6+
vim.keymap.set('n', '<leader>gf', ':LazyGitFilter<CR>', { desc = 'LazyGit filter' })

lua/custom/keymaps/init.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Central loader for all keymap modules
2+
require('custom.keymaps.general')
3+
require('custom.keymaps.files')
4+
require('custom.keymaps.git')
5+
require('custom.keymaps.terminal')

lua/custom/keymaps/terminal.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- Terminal and code execution keymaps
2+
3+
-- ToggleTerm keybindings
4+
-- Note: <c-\> is already mapped in toggleterm config for opening terminal
5+
vim.keymap.set('n', '<leader>tt', ':ToggleTerm<CR>', { desc = 'Toggle terminal' })
6+
vim.keymap.set('n', '<leader>tf', ':ToggleTerm direction=float<CR>', { desc = 'Toggle floating terminal' })
7+
vim.keymap.set('n', '<leader>th', ':ToggleTerm direction=horizontal<CR>', { desc = 'Toggle horizontal terminal' })
8+
vim.keymap.set('n', '<leader>tv', ':ToggleTerm direction=vertical<CR>', { desc = 'Toggle vertical terminal' })
9+
10+
-- Terminal mode mappings to escape easily
11+
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
12+
vim.keymap.set('t', 'jj', '<C-\\><C-n>', { desc = 'Exit terminal mode with jj' })

0 commit comments

Comments
 (0)