refactor one 'term' to rule them all
This commit is contained in:
@@ -0,0 +1,172 @@
|
||||
--[[
|
||||
BASIC-SETTINGS.LUA
|
||||
|
||||
This file contains fundamental Neovim settings that don't require plugins.
|
||||
These are applied to Neovim globally and affect the core editing experience.
|
||||
|
||||
In Lua (this file), we use:
|
||||
- vim.opt.* for options that take values
|
||||
- vim.g.* for global variables
|
||||
- vim.go.* for global option shorthand
|
||||
]]
|
||||
|
||||
-- ============================================================================
|
||||
-- FOLDING SETTINGS (Code folding)
|
||||
-- ============================================================================
|
||||
-- Foldmethod determines how code blocks are detected and folded
|
||||
-- "expr" means folds are based on expressions (we use treesitter for this)
|
||||
vim.opt.foldmethod = "expr"
|
||||
|
||||
-- Foldexpr is the expression used to determine fold level
|
||||
-- v:lua.vim.treesitter.foldexpr() uses Treesitter to calculate folds
|
||||
vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
||||
|
||||
-- Foldlevel: Higher number = more folds are open by default
|
||||
-- 99 means almost all folds are open when opening a file
|
||||
vim.opt.foldlevel = 99
|
||||
|
||||
-- ============================================================================
|
||||
-- LINE NUMBERS
|
||||
-- ============================================================================
|
||||
-- Show line numbers (absolute numbering)
|
||||
vim.opt.number = true
|
||||
|
||||
-- Show relative line numbers (helps with motions like 5j, 3k, etc.)
|
||||
-- When combined with 'number', the current line shows absolute number
|
||||
vim.opt.relativenumber = true
|
||||
|
||||
-- ============================================================================
|
||||
-- INDENTATION SETTINGS
|
||||
-- ============================================================================
|
||||
-- Tabstop: How many spaces a TAB character counts for
|
||||
-- When viewing a file, TABs appear as this many spaces
|
||||
vim.opt.tabstop = 4
|
||||
|
||||
-- Shiftwidth: How many spaces to use for auto-indentation and >> << commands
|
||||
vim.opt.shiftwidth = 4
|
||||
|
||||
-- Expandtab: Convert TABs to spaces when typing
|
||||
-- true = pressing TAB inserts spaces; false = inserts actual TAB characters
|
||||
-- Recommendation: Use true (spaces) for better portability across systems
|
||||
vim.opt.expandtab = true
|
||||
|
||||
-- Smartindent: Auto-indent based on file type and syntax
|
||||
-- Automatically adds indent after lines ending with specific characters
|
||||
vim.opt.smartindent = true
|
||||
|
||||
-- ============================================================================
|
||||
-- UI/UX SETTINGS
|
||||
-- ============================================================================
|
||||
-- Show line length marker (optional, helps keep lines under 80/120 chars)
|
||||
-- Uncomment if you want: vim.opt.colorcolumn = "80"
|
||||
|
||||
-- Enable cursor line highlighting (subtle background on current line)
|
||||
vim.opt.cursorline = true
|
||||
|
||||
-- Enable cursor column highlighting (column where cursor is)
|
||||
vim.opt.cursorcolumn = true
|
||||
|
||||
-- Better command-line completion (popup menu for completions)
|
||||
vim.opt.wildmenu = true
|
||||
|
||||
-- Ignore case when searching UNLESS you include an uppercase letter
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
|
||||
-- Highlight search matches as you type
|
||||
vim.opt.incsearch = true
|
||||
|
||||
-- When search reaches end, wrap back to beginning
|
||||
vim.opt.wrapscan = true
|
||||
|
||||
-- Show matching brackets/parentheses
|
||||
vim.opt.showmatch = true
|
||||
|
||||
-- How long (ms) to show matching bracket
|
||||
vim.opt.matchtime = 2
|
||||
|
||||
-- Show current mode in last line (like -- INSERT --)
|
||||
vim.opt.showmode = true
|
||||
|
||||
-- Show incomplete commands at bottom
|
||||
vim.opt.showcmd = true
|
||||
|
||||
-- Command line height (number of lines for command area)
|
||||
vim.opt.cmdheight = 1
|
||||
|
||||
-- Always show status line (even in single window)
|
||||
vim.opt.laststatus = 3
|
||||
|
||||
-- Don't redraw while executing macros (faster)
|
||||
vim.opt.lazyredraw = false
|
||||
|
||||
-- Don't show mode in the window title (cleaner)
|
||||
vim.opt.title = false
|
||||
|
||||
-- ============================================================================
|
||||
-- EDITING BEHAVIOR
|
||||
-- ============================================================================
|
||||
-- Enable mouse support (click to move cursor, resize splits)
|
||||
vim.opt.mouse = "a"
|
||||
|
||||
-- Allow backspace to delete indent, eol, and start of line
|
||||
vim.opt.backspace = "indent,eol,start"
|
||||
|
||||
-- Auto-read file when changed externally (e.g., by another program)
|
||||
vim.opt.autoread = true
|
||||
|
||||
-- Auto-write when switching buffers or leaving
|
||||
-- 'a' = auto-write for all buffers; uncomment if you want:
|
||||
-- vim.opt.autowrite = true
|
||||
|
||||
-- Remember moreundo for longer undo history
|
||||
vim.opt.undofile = true
|
||||
|
||||
-- ============================================================================
|
||||
-- SPLIT AND TAB SETTINGS
|
||||
-- ============================================================================
|
||||
-- Split below (instead of above) when creating horizontal splits
|
||||
vim.opt.splitbelow = true
|
||||
|
||||
-- Split right (instead of left) when creating vertical splits
|
||||
vim.opt.splitright = true
|
||||
|
||||
-- ============================================================================
|
||||
-- PERFORMANCE SETTINGS
|
||||
-- ============================================================================
|
||||
-- Faster terminal response
|
||||
vim.opt.timeout = true
|
||||
vim.opt.timeoutlen = 300 -- Time in ms to wait for a mapped sequence
|
||||
|
||||
-- Async handling for some operations
|
||||
vim.opt.ttimeoutlen = 10
|
||||
|
||||
-- ============================================================================
|
||||
-- LEADER KEY
|
||||
-- ============================================================================
|
||||
-- The <Leader> key is used as a prefix for custom keybindings
|
||||
-- By convention, space is commonly used as the leader key
|
||||
vim.g.mapleader = " "
|
||||
|
||||
-- ============================================================================
|
||||
-- TERMINAL SETTINGS
|
||||
-- ============================================================================
|
||||
-- Exit terminal mode with Escape
|
||||
vim.keymap.set("t", "<Esc>", [[<C-\><C-n>]], {
|
||||
desc = "Exit terminal mode"
|
||||
})
|
||||
|
||||
-- Alternative: Exit with Alt key combinations as well
|
||||
vim.keymap.set("t", "<A-x>", [[<C-\><C-n>]], {
|
||||
desc = "Exit terminal mode with Alt"
|
||||
})
|
||||
|
||||
-- ============================================================================
|
||||
-- CLIPBOARD (System clipboard integration)
|
||||
-- ============================================================================
|
||||
-- Use system clipboard for yank/paste
|
||||
-- Requires +clipboard feature (check with: :echo has('clipboard'))
|
||||
if vim.fn.has("clipboard") == 1 then
|
||||
-- Use system clipboard for all yank/delete/paste operations
|
||||
vim.opt.clipboard = "unnamedplus"
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
return {
|
||||
"catppuccin/nvim",
|
||||
name = "catppuccin",
|
||||
lazy = false,
|
||||
priority = 1000,
|
||||
config = function()
|
||||
require("catppuccin").setup({ flavor = "mocha" })
|
||||
vim.cmd.colorscheme("catppuccin")
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
--[[
|
||||
DEBUGGING.LUA
|
||||
nvim-dap for Python debugging
|
||||
Requirements: pip install debugpy
|
||||
]]
|
||||
|
||||
return {
|
||||
{ "mfussenegger/nvim-dap" },
|
||||
{ "nvim-neotest/nvim-nio" },
|
||||
{
|
||||
"rcarriga/nvim-dap-ui",
|
||||
dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" },
|
||||
config = function()
|
||||
local dap, dapui = require("dap"), require("dapui")
|
||||
dapui.setup()
|
||||
dap.listeners.after.event_initialized["dapui_config"] = dapui.open
|
||||
vim.keymap.set("n", "<F5>", dap.continue, { desc = "Continue" })
|
||||
vim.keymap.set("n", "<F10>", dap.step_over, { desc = "Step over" })
|
||||
vim.keymap.set("n", "<F11>", dap.step_into, { desc = "Step into" })
|
||||
vim.keymap.set("n", "<S-F11>", dap.step_out, { desc = "Step out" })
|
||||
vim.keymap.set("n", "<F9>", dap.toggle_breakpoint, { desc = "Breakpoint" })
|
||||
vim.keymap.set("n", "<leader>du", dapui.toggle, { desc = "DAP UI" })
|
||||
end,
|
||||
},
|
||||
{ "mfussenegger/nvim-dap-python", dependencies = { "mfussenegger/nvim-dap" } },
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
return {
|
||||
"lewis6991/gitsigns.nvim",
|
||||
config = function()
|
||||
require('gitsigns').setup()
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
return {
|
||||
-- Mason (LSP server installer)
|
||||
{
|
||||
"mason-org/mason.nvim",
|
||||
config = function()
|
||||
require("mason").setup()
|
||||
end,
|
||||
},
|
||||
|
||||
-- Mason-LSPconfig (bridge Mason and nvim-lspconfig)
|
||||
{
|
||||
"mason-org/mason-lspconfig.nvim",
|
||||
config = function()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {
|
||||
"pyright", -- Python
|
||||
"jsonls", -- JSON
|
||||
"yamlls", -- YAML
|
||||
"html", -- HTML
|
||||
"cssls", -- CSS
|
||||
"bashls", -- Bash
|
||||
"lua_ls", -- Lua
|
||||
},
|
||||
automatic_enable = true,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- nvim-lspconfig
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
config = function()
|
||||
-- Lua
|
||||
vim.lsp.config('lua_ls', {
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = { version = "LuaJIT" },
|
||||
workspace = { library = vim.api.nvim_get_runtime_file("", true) },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Other languages
|
||||
vim.lsp.config('pyright', {
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
typeCheckingMode = "basic",
|
||||
extraPaths = {}, -- Add extra import paths if needed
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
vim.lsp.config('jsonls', {})
|
||||
vim.lsp.config('yamlls', {})
|
||||
vim.lsp.config('html', {})
|
||||
vim.lsp.config('cssls', {})
|
||||
vim.lsp.config('bashls', {})
|
||||
|
||||
-- Enable servers
|
||||
vim.lsp.enable('lua_ls')
|
||||
vim.lsp.enable('pyright')
|
||||
vim.lsp.enable('jsonls')
|
||||
vim.lsp.enable('yamlls')
|
||||
vim.lsp.enable('html')
|
||||
vim.lsp.enable('cssls')
|
||||
vim.lsp.enable('bashls')
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
return {
|
||||
"nvim-lualine/lualine.nvim",
|
||||
config = function()
|
||||
require('lualine').setup({
|
||||
options = {
|
||||
theme = "auto",
|
||||
globalstatus = true,
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { "mode" },
|
||||
lualine_b = { "branch", "diff" },
|
||||
lualine_c = { "diagnostics", "filename" },
|
||||
lualine_x = { "encoding", "fileformat", "filetype" },
|
||||
lualine_y = { "progress" },
|
||||
lualine_z = { "location" },
|
||||
},
|
||||
extensions = { "neo-tree" },
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
return {
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
branch = "v3.x",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"MunifTanjim/nui.nvim",
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
},
|
||||
config = function()
|
||||
require("neo-tree").setup({
|
||||
filesystem = {
|
||||
filtered_items = {
|
||||
visible = true,
|
||||
hide_dotfiles = false,
|
||||
hide_hidden = false,
|
||||
},
|
||||
},
|
||||
})
|
||||
vim.keymap.set('n', '<C-n>', ':Neotree filesystem reveal left<CR>', {})
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
return {
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
local builtin = require("telescope.builtin")
|
||||
require("telescope").setup({
|
||||
defaults = {
|
||||
prompt_prefix = " ",
|
||||
entry_prefix = " ",
|
||||
initial_mode = "insert",
|
||||
sorting_strategy = "ascending",
|
||||
file_ignore_patterns = {
|
||||
"node_modules", ".git", "__pycache__", "*.pyc", "dist", "build"
|
||||
},
|
||||
-- Disable treesitter in preview
|
||||
preview = {
|
||||
treesitter = false,
|
||||
},
|
||||
},
|
||||
})
|
||||
vim.keymap.set('n', '<C-p>', builtin.find_files, {})
|
||||
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
|
||||
end
|
||||
},
|
||||
{
|
||||
"nvim-telescope/telescope-ui-select.nvim",
|
||||
config = function()
|
||||
require("telescope").load_extension("ui-select")
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
lazy = true,
|
||||
build = ":TSUpdate",
|
||||
event = { "BufReadPost", "BufNewFile" },
|
||||
config = function()
|
||||
local ok, configs = pcall(require, "nvim-treesitter.configs")
|
||||
if ok then
|
||||
configs.setup({
|
||||
ensure_installed = { "python", "lua", "json", "yaml", "markdown" },
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
})
|
||||
end
|
||||
end,
|
||||
}
|
||||
Reference in New Issue
Block a user