diff options
Diffstat (limited to 'nvim/lua')
-rw-r--r-- | nvim/lua/codev.lua | 11 | ||||
-rw-r--r-- | nvim/lua/configs.lua | 285 | ||||
-rw-r--r-- | nvim/lua/core/autocmds.lua | 98 | ||||
-rw-r--r-- | nvim/lua/core/keymaps.lua | 113 | ||||
-rw-r--r-- | nvim/lua/core/options.lua | 37 | ||||
-rw-r--r-- | nvim/lua/keybindings.lua | 162 | ||||
-rw-r--r-- | nvim/lua/options.lua | 43 | ||||
-rw-r--r-- | nvim/lua/plugins.lua | 359 |
8 files changed, 689 insertions, 419 deletions
diff --git a/nvim/lua/codev.lua b/nvim/lua/codev.lua deleted file mode 100644 index ed6c330..0000000 --- a/nvim/lua/codev.lua +++ /dev/null @@ -1,11 +0,0 @@ -vim.api.nvim_exec2([[
- augroup SeqFileType
- autocmd!
- autocmd BufRead,BufNewFile *.seq set filetype=seq
- autocmd BufRead,BufNewFile *.seq set syntax=codev
- autocmd BufRead,BufNewFile *.lis set filetype=lis
- autocmd BufRead,BufNewFile *.lis set syntax=codelis
- augroup END
-]], {})
-
-vim.api.nvim_exec2([[autocmd FileType seq set commentstring=!%s]], {})
diff --git a/nvim/lua/configs.lua b/nvim/lua/configs.lua new file mode 100644 index 0000000..92d26f7 --- /dev/null +++ b/nvim/lua/configs.lua @@ -0,0 +1,285 @@ +-- Plugin configurations
+-- All plugin-specific settings are configured here
+
+--------------------------------
+-- TELESCOPE
+--------------------------------
+local function setup_telescope()
+ local actions = require("telescope.actions")
+
+ -- Function to open selected file in external program
+ local function open_in_external_program(prompt_bufnr)
+ local entry = require('telescope.actions.state').get_selected_entry()
+ local file_path = entry.path or entry.filename
+ if file_path then
+ os.execute(string.format('start "" "%s"', file_path))
+ else
+ print("No file selected")
+ end
+ actions.close(prompt_bufnr)
+ end
+
+ require('telescope').setup({
+ defaults = {
+ layout_config = {
+ vertical = { width = 0.5 }
+ },
+ mappings = {
+ n = {
+ ["q"] = actions.close,
+ ["o"] = open_in_external_program,
+ },
+ i = {
+ ["<C-c>"] = actions.close,
+ ["<C-n>"] = actions.cycle_history_next,
+ ["<C-p>"] = actions.cycle_history_prev,
+ ["<C-j>"] = actions.move_selection_next,
+ ["<C-k>"] = actions.move_selection_previous,
+ ["<C-o>"] = open_in_external_program,
+ }
+ },
+ },
+ pickers = {
+ live_grep = {
+ file_ignore_patterns = { 'node_modules', '.git', '.venv' },
+ additional_args = function(_)
+ return { "--hidden" }
+ end
+ },
+ find_files = {
+ file_ignore_patterns = { 'node_modules', '.git', '.venv' },
+ hidden = true
+ }
+ }
+ })
+end
+
+--------------------------------
+-- HARPOON
+--------------------------------
+local function setup_harpoon()
+ local harpoon = require("harpoon")
+
+ -- Initialize harpoon
+ harpoon:setup({
+ settings = {
+ save_on_toggle = true,
+ sync_on_ui_close = true,
+ }
+ })
+end
+
+--------------------------------
+-- OIL
+--------------------------------
+local function setup_oil()
+ require("oil").setup({
+ -- Default file explorer settings
+ default_file_explorer = true,
+
+ -- Columns to display
+ columns = { "icon" },
+
+ -- Buffer options
+ buf_options = {
+ buflisted = false,
+ bufhidden = "hide",
+ },
+
+ -- Window options
+ win_options = {
+ wrap = false,
+ signcolumn = "no",
+ cursorcolumn = false,
+ foldcolumn = "0",
+ spell = false,
+ list = false,
+ conceallevel = 3,
+ concealcursor = "nvic",
+ },
+
+ -- File operations
+ delete_to_trash = true,
+ skip_confirm_for_simple_edits = false,
+ prompt_save_on_select_new_entry = true,
+ cleanup_delay_ms = 2000,
+
+ -- UI behavior
+ constrain_cursor = "editable",
+ watch_for_changes = false,
+
+ -- Custom keymaps
+ keymaps = {
+ ["g?"] = "actions.show_help",
+ ["<CR>"] = "actions.select",
+ ["<C-S>"] = { "actions.select", opts = { vertical = true } },
+ ["<C-H>"] = { "actions.select", opts = { horizontal = true } },
+ ["<C-p>"] = "actions.preview",
+ ["<C-c>"] = "actions.close",
+ ["<C-l>"] = "actions.refresh",
+ ["-"] = "actions.parent",
+ ["_"] = "actions.open_cwd",
+ ["`"] = "actions.cd",
+ ["~"] = { "actions.cd", opts = { scope = "tab" } },
+ ["gs"] = "actions.change_sort",
+ ["<C-o>"] = "actions.open_external",
+ ["g."] = "actions.toggle_hidden",
+ ["g\\"] = "actions.toggle_trash",
+ ['yp'] = {
+ desc = 'Copy filepath to system clipboard',
+ callback = function ()
+ require('oil.actions').copy_entry_path.callback()
+ vim.fn.setreg("+", vim.fn.getreg(vim.v.register))
+ end,
+ },
+ },
+
+ -- Disable default keymaps
+ use_default_keymaps = false,
+
+ -- View options
+ view_options = {
+ show_hidden = false,
+ natural_order = true,
+ case_insensitive = false,
+ sort = {
+ { "type", "asc" },
+ { "name", "asc" },
+ },
+ },
+
+ -- Preview window settings
+ preview = {
+ max_width = 0.9,
+ min_width = { 40, 0.4 },
+ max_height = 0.9,
+ min_height = { 5, 0.1 },
+ border = "rounded",
+ win_options = { winblend = 0 },
+ },
+
+ -- Floating window settings
+ float = {
+ padding = 2,
+ max_width = 0,
+ max_height = 0,
+ border = "rounded",
+ win_options = { winblend = 0 },
+ },
+ })
+end
+
+--------------------------------
+-- TOGGLETERM
+--------------------------------
+local function setup_toggleterm()
+ require("toggleterm").setup({
+ -- Shell to use in the terminal
+ shell = "pwsh.exe -NoLogo",
+
+ -- Display options
+ direction = "float",
+ float_opts = {
+ border = "rounded",
+ },
+
+ -- Window appearance
+ winbar = {
+ enabled = false
+ },
+
+ -- Behavior
+ start_in_insert = true,
+ close_on_exit = true,
+
+ -- Integration with tmux
+ persist_size = true,
+ persist_mode = true,
+ })
+end
+
+--------------------------------
+-- TREESITTER
+--------------------------------
+local function setup_treesitter()
+ require('nvim-treesitter.configs').setup({
+ ensure_installed = { "c", "lua", "vim", "vimdoc", "cpp", "python" },
+ sync_install = false,
+ auto_install = false,
+ highlight = { enable = true },
+ indent = { enable = true },
+ })
+end
+
+--------------------------------
+-- COMMENTS
+--------------------------------
+local function setup_comments()
+ require('Comment').setup({
+ padding = true,
+ sticky = true,
+ ignore = nil,
+ toggler = {
+ line = '<leader>/',
+ block = 'gbc',
+ },
+ opleader = {
+ line = '<leader>/',
+ block = 'gb',
+ }
+ })
+end
+
+--------------------------------
+-- LSP Configuration
+--------------------------------
+local function setup_lsp()
+ -- Configure Mason LSP installer/manager
+ require('mason').setup({
+ ensure_installed = {
+ 'lua_ls', -- Lua
+ 'clangd', -- C/C++
+ 'pyright', -- Python
+ 'marksman', -- Markdown
+ },
+ handlers = {
+ -- Lua LSP settings
+ lua_ls = function()
+ require('lspconfig').lua_ls.setup({})
+ end,
+
+ -- C/C++ LSP settings (clangd)
+ clangd = function()
+ require('lspconfig').clangd.setup({})
+ end,
+
+ -- Markdown LSP settings
+ marksman = function()
+ require('lspconfig').marksman.setup({})
+ end,
+ }
+ })
+ require("mason-lspconfig").setup {}
+
+ -- Configure diagnostics appearance
+ vim.diagnostic.config({
+ virtual_lines=true,
+ signs = true,
+ underline = true,
+ update_in_insert = false,
+ severity_sort = true,
+ })
+end
+
+--------------------------------
+-- INITIALIZE ALL CONFIGS
+--------------------------------
+
+-- Set up all plugin configurations
+setup_telescope()
+setup_harpoon()
+setup_oil()
+setup_toggleterm()
+setup_treesitter()
+setup_comments()
+setup_lsp()
diff --git a/nvim/lua/core/autocmds.lua b/nvim/lua/core/autocmds.lua new file mode 100644 index 0000000..898aeb7 --- /dev/null +++ b/nvim/lua/core/autocmds.lua @@ -0,0 +1,98 @@ +-- Core autocommands
+-- Centralized place for all autocommands
+
+--------------------------------
+-- FILE DETECTION & RELOADING
+--------------------------------
+
+-- Auto-reload files when changed externally
+local file_change_detect = vim.api.nvim_create_augroup("FileChangeDetect", { clear = true })
+vim.api.nvim_create_autocmd({"FocusGained", "BufEnter", "BufWinEnter", "WinEnter", "CursorHold", "CursorHoldI"}, {
+ group = file_change_detect,
+ callback = function()
+ vim.cmd("checktime")
+ end,
+})
+
+vim.api.nvim_create_autocmd("FileChangedShellPost", {
+ group = file_change_detect,
+ callback = function()
+ vim.notify("File changed on disk. Buffer reloaded.", vim.log.levels.WARN)
+ vim.cmd("checktime")
+ end,
+})
+
+--------------------------------
+-- TERMINAL BEHAVIOR
+--------------------------------
+
+-- Terminal settings and keymaps
+local terminal_settings = vim.api.nvim_create_augroup("TerminalSettings", { clear = true })
+vim.api.nvim_create_autocmd({"TermOpen", "BufEnter"}, {
+ group = terminal_settings,
+ callback = function()
+ if vim.opt.buftype:get() == "terminal" then
+ vim.cmd("startinsert")
+
+ -- Terminal keymaps
+ local opts = { noremap = true, silent = true, buffer = true }
+ vim.keymap.set("t", "<C-d>", [[<C-\><C-n><cmd>ToggleTerm<CR>]], opts)
+ vim.keymap.set("t", "<C-q>", [[<C-\><C-n><cmd>ToggleTerm<CR>]], opts)
+ vim.keymap.set("t", "jk", [[<C-\><C-n>]], opts)
+ vim.keymap.set("t", "<C-h>", [[<C-\><C-n><C-W>h]], opts)
+ vim.keymap.set("t", "<C-j>", [[<C-\><C-n><C-W>j]], opts)
+ vim.keymap.set("t", "<C-k>", [[<C-\><C-n><C-W>k]], opts)
+ vim.keymap.set("t", "<C-l>", [[<C-\><C-n><C-W>l]], opts)
+ end
+ end,
+})
+
+--------------------------------
+-- CUSTOM FILETYPES
+--------------------------------
+
+-- Custom filetype detection
+local filetype_group = vim.api.nvim_create_augroup("CustomFileTypes", { clear = true })
+
+-- Set up .seq files to use codev syntax
+vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, {
+ group = filetype_group,
+ pattern = "*.seq",
+ callback = function()
+ vim.bo.filetype = "seq"
+ vim.bo.syntax = "codev"
+ vim.bo.commentstring = "!%s"
+ end,
+})
+
+-- Set up .lis files to use codelis syntax
+vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, {
+ group = filetype_group,
+ pattern = "*.lis",
+ callback = function()
+ vim.bo.filetype = "lis"
+ vim.bo.syntax = "codelis"
+ end,
+})
+
+--------------------------------
+-- CUSTOM COMMANDS
+--------------------------------
+
+-- Python docstring helper
+vim.api.nvim_create_user_command("PythonDocstring", function()
+ local docstring = [["""
+
+# Information:
+
+# Arguments:
+
+# Returns:
+
+"""]]
+ -- Insert the docstring at the cursor position
+ local line = vim.api.nvim_win_get_cursor(0)[1]
+ vim.api.nvim_buf_set_lines(0, line-1, line-1, false, vim.split(docstring, "\n"))
+ -- Position cursor at the right spot
+ vim.api.nvim_win_set_cursor(0, {line+1, 0})
+end, {})
diff --git a/nvim/lua/core/keymaps.lua b/nvim/lua/core/keymaps.lua new file mode 100644 index 0000000..0ab02ff --- /dev/null +++ b/nvim/lua/core/keymaps.lua @@ -0,0 +1,113 @@ +-- Core keymaps
+-- General key mappings not tied to specific plugins
+
+-- Leader key
+vim.g.mapleader = " "
+
+----------------
+-- NORMAL MODE
+----------------
+
+-- File operations
+vim.keymap.set("n", "<leader>w", "<cmd>w<cr>", { desc = "Save file" })
+vim.keymap.set("n", "<leader>q", "<cmd>q<cr>", { desc = "Quit" })
+vim.keymap.set("n", "<leader>Q", "<cmd>q!<cr>", { desc = "Force quit" })
+vim.keymap.set("n", "<C-c>", "<cmd>bd<cr>", { desc = "Close buffer" })
+
+-- Quick buffer navigation
+vim.keymap.set("n", "<C-h>", "<C-w>h", { desc = "Move to left window" })
+vim.keymap.set("n", "<C-j>", "<C-w>j", { desc = "Move to bottom window" })
+vim.keymap.set("n", "<C-k>", "<C-w>k", { desc = "Move to top window" })
+vim.keymap.set("n", "<C-l>", "<C-w>l", { desc = "Move to right window" })
+
+-- Quick formatting
+vim.keymap.set("n", "<leader>S", "ggVG=", { desc = "Format entire file" })
+
+-- Quick line operations
+vim.keymap.set("n", "<leader>o", "o<Esc>", { desc = "New line below" })
+vim.keymap.set("n", "<leader>O", "O<Esc>", { desc = "New line above" })
+vim.keymap.set("n", "J", "mzJ`z", { desc = "Join lines and maintain cursor" })
+
+-- Better vertical navigation
+vim.keymap.set("n", "<C-d>", "<C-d>zz", { desc = "Half page down and center" })
+vim.keymap.set("n", "<C-u>", "<C-u>zz", { desc = "Half page up and center" })
+vim.keymap.set("n", "n", "nzzzv", { desc = "Next search result and center" })
+vim.keymap.set("n", "N", "Nzzzv", { desc = "Prev search result and center" })
+
+-- Clipboard operations
+vim.keymap.set({"n", "v"}, "<leader>y", [["+y]], { desc = "Copy to system clipboard" })
+vim.keymap.set("n", "<leader>Y", [["+Y]], { desc = "Copy line to system clipboard" })
+vim.keymap.set({"n", "v"}, "<leader>d", [["_d]], { desc = "Delete to void register" })
+vim.keymap.set("x", "<leader>p", [["_dP]], { desc = "Paste over selection" })
+
+-- Quickfix navigation
+vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz", { desc = "Next quickfix item" })
+vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz", { desc = "Previous quickfix item" })
+
+-- Undo remap
+vim.keymap.set("n", "U", "<C-r>", { desc = "Redo" })
+
+-- Search and replace current word
+vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]],
+ { desc = "Replace current word" })
+
+-- Terminal keymaps
+vim.keymap.set("n", "<leader>t", "<cmd>ToggleTerm<cr>", { desc = "Toggle terminal" })
+vim.keymap.set({"n", "i"},"<C-r><C-k>", "<cmd>ToggleTermSendCurrentLine<cr>j", { desc = "Send line to terminal" })
+vim.keymap.set("n","<C-r><C-j>", "ggVG:'<,'>ToggleTermSendVisualLines<cr>", { desc = "Send file to terminal" })
+vim.keymap.set("i","<C-r><C-j>", "<Esc>ggVG:'<,'>ToggleTermSendVisualLines<cr><Esc>i", { desc = "Send file to terminal" })
+vim.keymap.set("v","<C-r><C-k>", ":ToggleTermSendVisualLines<cr><Esc>", { desc = "Send selection to terminal" })
+
+-- File browser
+vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory with Oil" })
+
+-- LSP quick diagnostics
+vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, { noremap=true, silent=true, desc = "Show diagnostics" })
+
+-- Python docstring helper
+vim.keymap.set("n", "<leader>dc", ":PythonDocstring<CR>", {
+ silent = true,
+ desc = "Insert Python docstring template"
+})
+
+----------------
+-- INSERT MODE
+----------------
+
+vim.keymap.set("i", "jk", "<Esc>", { desc = "Exit insert mode" })
+vim.keymap.set("i", "<leader>e", "<Space>e", { desc = "Insert e after leader" })
+vim.keymap.set("i", "<C-c>", "<cmd>bd<cr>", { desc = "Close buffer" })
+
+----------------
+-- VISUAL MODE
+----------------
+
+-- Move selected lines
+vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv", { desc = "Move selection down" })
+vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv", { desc = "Move selection up" })
+
+-- Telescope keymaps (grouped for related functionality)
+vim.keymap.set("n", "<leader>ff", "<cmd>Telescope find_files theme=dropdown<cr>", { desc = "Find files" })
+vim.keymap.set("n", "<leader>fm", "<cmd>Telescope find_files cwd=D:/Optics/CODEV/Macros theme=dropdown<cr>", { desc = "Find macro files" })
+vim.keymap.set("n", "<leader>fc", "<cmd>Telescope find_files cwd=C:/CODEV202403/macro theme=dropdown<cr>", { desc = "Find CODEV macro files" })
+vim.keymap.set("n", "<leader>fl", "<cmd>Telescope find_files cwd=C:/CODEV202403/lens theme=dropdown<cr>", { desc = "Find lens files" })
+vim.keymap.set("n", "<leader>gg", "<cmd>Telescope live_grep theme=dropdown<cr>", { desc = "Live grep" })
+vim.keymap.set("n", "<leader>gm", "<cmd>Telescope live_grep cwd=D:/Optics/CODEV/Macros theme=dropdown<cr>", { desc = "Grep in macro files" })
+vim.keymap.set("n", "<leader>gc", "<cmd>Telescope live_grep cwd=C:/CODEV202403/macro theme=dropdown<cr>", { desc = "Grep in CODEV macro files" })
+vim.keymap.set("n", "<leader>gl", "<cmd>Telescope live_grep cwd=C:/CODEV202403/lens theme=dropdown<cr>", { desc = "Grep in lens files" })
+vim.keymap.set("n", "<leader>b", "<cmd>Telescope buffers theme=dropdown<cr>", { desc = "List buffers" })
+
+-- Harpoon keymaps
+vim.keymap.set("n", "<leader>a", function() require("harpoon"):list():add() end, { desc = "Add file to harpoon" })
+vim.keymap.set("n", "<C-e>", function() require("harpoon").ui:toggle_quick_menu(require("harpoon"):list()) end, { desc = "Toggle harpoon menu" })
+vim.keymap.set("n", "<leader>h", function() require("harpoon"):list():select(1) end, { desc = "Harpoon file 1" })
+vim.keymap.set("n", "<leader>j", function() require("harpoon"):list():select(2) end, { desc = "Harpoon file 2" })
+vim.keymap.set("n", "<leader>k", function() require("harpoon"):list():select(3) end, { desc = "Harpoon file 3" })
+vim.keymap.set("n", "<leader>l", function() require("harpoon"):list():select(4) end, { desc = "Harpoon file 4" })
+vim.keymap.set("n", "<leader>N", function() require("harpoon"):list():prev() end, { desc = "Previous harpoon file" })
+vim.keymap.set("n", "<leader>P", function() require("harpoon"):list():next() end, { desc = "Next harpoon file" })
+
+-- Other tool keymaps
+vim.keymap.set("n", "<leader>G", vim.cmd.Git, { desc = "Open Git status" })
+vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle, { desc = "Toggle undo tree" })
+vim.keymap.set("n", "[c", function() require("treesitter-context").go_to_context() end, { desc = "Go to context", silent = true })
diff --git a/nvim/lua/core/options.lua b/nvim/lua/core/options.lua new file mode 100644 index 0000000..b05ad08 --- /dev/null +++ b/nvim/lua/core/options.lua @@ -0,0 +1,37 @@ +-- Core Neovim settings
+-- General options and settings
+
+-- UI settings
+vim.opt.termguicolors = true -- True color support
+vim.opt.number = true -- Show line numbers
+vim.opt.relativenumber = true -- Show relative line numbers
+vim.opt.scrolloff = 999 -- Keep cursor centered
+vim.opt.splitbelow = true -- Horizontal splits below
+vim.opt.splitright = true -- Vertical splits to the right
+vim.opt.wrap = true -- Line wrapping
+vim.opt.virtualedit = "block" -- Allow cursor beyond text in block mode
+
+-- Search settings
+vim.opt.hlsearch = false -- Don't highlight search results
+vim.opt.incsearch = true -- Incremental search
+vim.opt.ignorecase = true -- Case insensitive search
+
+-- Tab settings
+vim.opt.tabstop = 4 -- Tab width
+vim.opt.softtabstop = 4 -- Soft tab width
+vim.opt.shiftwidth = 4 -- Indentation width
+vim.opt.expandtab = true -- Use spaces instead of tabs
+
+-- File management
+vim.opt.swapfile = false -- No swap files
+vim.opt.backup = false -- No backup files
+vim.opt.undodir = os.getenv("USERPROFILE").."/.vim/undodir" -- Undo directory
+vim.opt.undofile = true -- Persistent undo history
+
+-- Performance and usability
+vim.opt.updatetime = 50 -- Faster update time
+vim.opt.inccommand = "split" -- Live substitution preview
+
+-- Status line
+vim.cmd([[set laststatus=2]]) -- Always show statusline
+vim.cmd([[set shortmess=I]]) -- Don't show intro message
diff --git a/nvim/lua/keybindings.lua b/nvim/lua/keybindings.lua deleted file mode 100644 index 9a9d0f0..0000000 --- a/nvim/lua/keybindings.lua +++ /dev/null @@ -1,162 +0,0 @@ -vim.g.mapleader = " " ---Telescope keys --- local builtin = require('telescope.builtin') --- vim.keymap.set('n', '<leader>ps', function() --- builtin.grep_string({ search = vim.fn.input("Grep > ") }) --- end) - --- vim.keymap.set('n', '<leader>pf', builtin.find_files, {}) --- vim.keymap.set("n", "<leader>pv", vim.cmd.Ex) --- vim.keymap.set('n', "<leader>ps", builtin.live_grep,{}) --- vim.keymap.set('n', "<leader>pb", builtin.buffers,{}) - --- vim.keymap.set('n', '<leader>ff', '<cmd>Telescope find_files search_dirs=[".","D:/Optics/CODEV/Macros","C:/CODEV202403/macro","C:/CODEV202403/lens"] theme=dropdown<cr>') -vim.keymap.set('n', '<leader>ff', "<cmd>Telescope find_files theme=dropdown<cr>") -vim.keymap.set('n', '<leader>fm', "<cmd>Telescope find_files cwd=D:/Optics/CODEV/Macros theme=dropdown<cr>") -vim.keymap.set('n', '<leader>fc', "<cmd>Telescope find_files cwd=C:/CODEV202403/macro theme=dropdown<cr>") -vim.keymap.set('n', '<leader>fl', "<cmd>Telescope find_files cwd=C:/CODEV202403/lens theme=dropdown<cr>") - -vim.keymap.set("n", "<leader>pp", "<cmd>Telescope file_browser theme=dropdown<cr>") -vim.keymap.set("n", "<leader>pm", "<cmd>Telescope file_browser cwd=D:/Optics/CODEV/Macros theme=dropdown<cr>") -vim.keymap.set("n", "<leader>pc", "<cmd>Telescope file_browser cwd=C:/CODEV202403/macro theme=dropdown<cr>") -vim.keymap.set("n", "<leader>pl", "<cmd>Telescope file_browser cwd=C:/CODEV202403/lens theme=dropdown<cr>") - -vim.keymap.set('n', "<leader>gg", "<cmd>Telescope live_grep theme=dropdown<cr>") -vim.keymap.set('n', "<leader>gm", "<cmd>Telescope live_grep cwd=D:/Optics/CODEV/Macros theme=dropdown<cr>") -vim.keymap.set('n', "<leader>gc", "<cmd>Telescope live_grep cwd=C:/CODEV202403/macro theme=dropdown<cr>") -vim.keymap.set('n', "<leader>gl", "<cmd>Telescope live_grep cwd=C:/CODEV202403/lens theme=dropdown<cr>") - - -vim.keymap.set('n', "<leader>b", "<cmd>Telescope buffers theme=dropdown<cr>") - -vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle) -vim.keymap.set('n', '<leader>G', vim.cmd.Git) --- Language Server Keybindings -local lsp_zero = require('lsp-zero') - -lsp_zero.on_attach(function(client, bufnr) - local opts = {buffer = bufnr, remap = false} - - vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) - vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) - vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts) - vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts) - vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts) - vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts) - vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts) - vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts) - vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts) - vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts) -end) - -require('mason').setup({}) -require('mason-lspconfig').setup({ - ensure_installed = {'tsserver', 'rust_analyzer'}, - handlers = { - lsp_zero.default_setup, - lua_ls = function() - local lua_opts = lsp_zero.nvim_lua_ls() - require('lspconfig').lua_ls.setup(lua_opts) - end, - } -}) - -local cmp = require('cmp') -local cmp_select = {behavior = cmp.SelectBehavior.Select} - -cmp.setup({ - sources = { - {name = 'path'}, - {name = 'nvim_lsp'}, - {name = 'nvim_lua'}, - }, - formatting = lsp_zero.cmp_format(), - mapping = cmp.mapping.preset.insert({ - ['<C-p>'] = cmp.mapping.scroll_docs(-4), - ['<C-n>'] = cmp.mapping.scroll_docs(4), - ['<C-k>'] = cmp.mapping.select_prev_item(cmp_select), - ['<C-j>'] = cmp.mapping.select_next_item(cmp_select), - ['<C-i>'] = cmp.mapping.confirm({ select = true }), - ['<C-Space>'] = cmp.mapping.complete(), - }), -}) --- General Keybindings -vim.keymap.set("i", "jk", "<Esc>") -vim.keymap.set("n","<leader>w", "<cmd>w<cr>") -vim.keymap.set("n","<leader>q", "<cmd>q<cr>") -vim.keymap.set("n","<C-c>", "<cmd>bd<cr>") -vim.keymap.set("i","<C-c>", "<cmd>bd<cr>") -vim.keymap.set("n","<leader>Q", "<cmd>q!<cr>") -vim.keymap.set("n","<leader>o", "o<Esc>") -vim.keymap.set("n","<leader>O", "O<Esc>") -vim.keymap.set("i", "<leader>e", "<Space>e") ---File Formatting -vim.keymap.set("n","<leader>S", "ggVG=") --- Moving Lines around -vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv") -vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv") -vim.keymap.set("n", "J", "mzJ`z") ---Fast Vertical Navigation -vim.keymap.set("n", "<C-d>", "<C-d>zz") -vim.keymap.set("n", "<C-u>", "<C-u>zz") --- Search terms stay in the middle -vim.keymap.set("n", "n", "nzzzv") -vim.keymap.set("n", "N", "Nzzzv") --- pasting something instead of current text -vim.keymap.set("x", "<leader>p", [["_dP]]) --- copying into system clipboard -vim.keymap.set({"n", "v"}, "<leader>y", [["+y]]) -vim.keymap.set("n", "<leader>Y", [["+Y]]) --- Put into Void Register -vim.keymap.set({"n", "v"}, "<leader>d", [["_d]]) --- Quick Fix List Navingation ---vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz") ---vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz") -vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz") -vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz") --- Terminal Navigation --- vim.keymap.set("n", "<leader>tt", "<cmd>ToggleTerm size=60 direction=horizontal shell=powershell<cr>") -vim.keymap.set("n", "<leader>t", "<cmd>ToggleTerm<cr>") --- vim.keymap.set("n", "<C-t>", "<cmd>ToggleTerm<cr>") --- vim.keymap.set("i", "<C-t>", "<cmd>ToggleTerm<cr>") --- vim.keymap.set("n", "<leader>tt", "<cmd>vertical 60 vsplit | terminal pwsh.exe<cr>") --- vim.keymap.set("n", "<leader>tj", "<cmd>term pwsh.exe<cr>") -vim.keymap.set("t", "jk", [[<C-\><C-n>]]) -vim.keymap.set("t", "<C-h>", [[<C-\><C-n><C-W>h]]) -vim.keymap.set("t", "<C-j>", [[<C-\><C-n><C-W>j]]) -vim.keymap.set("t", "<C-k>", [[<C-\><C-n><C-W>k]]) -vim.keymap.set("t", "<C-l>", [[<C-\><C-n><C-W>l]]) ---Sending lines and file to the internal terminal I had before <C-O> to make the cursor move to the previous position but this doesnt seem to be a good option -vim.keymap.set({"n", "i"},"<C-r><C-k>", "<cmd>ToggleTermSendCurrentLine<cr>j") -vim.keymap.set("n","<C-r><C-j>", "ggVG:'<,'>ToggleTermSendVisualLines<cr>") -vim.keymap.set("i","<C-r><C-j>", "<Esc>ggVG:'<,'>ToggleTermSendVisualLines<cr><Esc>i") -vim.keymap.set("v","<C-r><C-k>", ":ToggleTermSendVisualLines<cr><Esc>") --- Buffer Navigation -vim.keymap.set("n", "<C-h>", [[<C-W>h]]) -vim.keymap.set("n", "<C-j>", [[<C-W>j]]) -vim.keymap.set("n", "<C-k>", [[<C-W>k]]) -vim.keymap.set("n", "<C-l>", [[<C-W>l]]) --- Undo Remapping -vim.keymap.set("n", "U", "<C-r>") --- Replace the Current Word everywhere -vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]]) --- Nvim-Tree --- vim.keymap.set("n", "<leader>e", "<cmd>NvimTreeToggle<cr>") --- BufferLine Navigation --- vim.keymap.set("n", "<Tab>", "<cmd>BufferLineCycleNext<cr>") --- vim.keymap.set("n", "<S-Tab>", "<cmd>BufferLineCyclePrev<cr>") --- vim.keymap.set("n", "<C-w>", "<cmd>BufferLineCloseOthers<cr>") --- Treesitter Context -vim.keymap.set("n", "[c", function() - require("treesitter-context").go_to_context() -end, { silent = true }) --- Docstring commands -vim.keymap.set("n","<leader>dc",[[i"""<Esc>o<Esc>o#<Space>Information:<Esc>o<Backspace><Backspace><Esc>o#<Space>Arguments:<Esc>o<Backspace><Backspace><Esc>o#<Space>Returns:<Esc>o<Backspace><Backspace><Esc>o"""<Esc>7k]]) - - - ---vim.keymap.set('n', '<C-p>', bultin.git_files,{}) ---Oil.nvim keybinds -vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" }) - -vim.keymap.set("n","<leader>m","<CMD>silent make<CR>") diff --git a/nvim/lua/options.lua b/nvim/lua/options.lua deleted file mode 100644 index 944ea6d..0000000 --- a/nvim/lua/options.lua +++ /dev/null @@ -1,43 +0,0 @@ ---Sets automatic update of the file internals
-vim.api.nvim_exec2([[
- autocmd FocusGained,BufEnter,BufWinEnter,WinEnter,CursorHold,CursorHoldI * checktime
- autocmd FileChangedShellPost * echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None | checktime
-]],{})
-vim.api.nvim_exec2([[set shortmess=I]],{})
-
--- vim.api.nvim_exec2([[autocmd TermOpen * startinsert]],{})
-
-vim.opt.termguicolors = true
--- vim.o.statusline = [[%<%f\ %h%m%r%=%-13.(%l,%c%V%)\ %P]]
--- vim.o.laststatus = 2
-
-vim.opt.splitbelow = true
-vim.opt.splitright = true
-
-vim.opt.relativenumber = true
-vim.opt.number = true
-vim.opt.tabstop = 4
-vim.opt.softtabstop = 4
-vim.opt.shiftwidth = 4
-vim.opt.expandtab = true
-
-vim.opt.swapfile = false
-vim.opt.backup = false
-vim.opt.undodir = os.getenv("USERPROFILE").."/.vim/undodir"
-vim.opt.undofile = true
-
-vim.opt.hlsearch = false
-vim.opt.incsearch = true
-
-vim.opt.scrolloff = 999
-vim.opt.updatetime = 50
-
-vim.opt.wrap = true
-
-vim.opt.virtualedit = "block"
-vim.opt.inccommand = "split"
-vim.opt.ignorecase = true
-
-vim.cmd[[set laststatus=2]]
--- vim.opt.clipboard = "unnamedplus"
---vim.opt.colorcolumn = "180"
diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index 79b4c5f..a04187c 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -1,8 +1,10 @@ --- lazy plugin manager
+-- Plugin declarations
+-- All plugins used in Neovim are defined here
+
+
+-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
- -- bootstrap lazy.nvim
- -- stylua: ignore
vim.fn.system({
"git",
"clone",
@@ -12,245 +14,196 @@ if not vim.loop.fs_stat(lazypath) then lazypath,
})
end
-vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
-
-require("lazy").setup({
+vim.opt.rtp:prepend(lazypath)
+
+-- Initialize lazy.nvim with plugins
+require("lazy").setup({
+ ------------------------------------------------------------
+ -- UI
+ ------------------------------------------------------------
+
-- Colorscheme
{
"folke/tokyonight.nvim",
- init = function()
+ lazy = false,
+ priority = 1000,
+ config = function()
vim.cmd.colorscheme("tokyonight-night")
- end
+ end,
},
+ -- File browser
{
- 'tpope/vim-fugitive',
+ 'stevearc/oil.nvim',
+ dependencies = { "nvim-tree/nvim-web-devicons" },
+ cmd = "Oil",
},
+ -- Terminal
{
- {
- 'VonHeikemen/lsp-zero.nvim',
- branch = 'v3.x',
- lazy = true,
- config = false,
- init = function()
- -- Disable automatic setup, we are doing it manually
- vim.g.lsp_zero_extend_cmp = 0
- vim.g.lsp_zero_extend_lspconfig = 0
- end,
- },
-
- {
- 'williamboman/mason.nvim',
- lazy = false,
- config = true,
- },
-
- {
- 'neovim/nvim-lspconfig',
- dependencies = {
- {'hrsh7th/cmp-nvim-lsp'},
- }
- },
-
- -- Autocompletion
- {
- 'hrsh7th/nvim-cmp',
- event = 'InsertEnter',
- dependencies = {
- {'L3MON4D3/LuaSnip',
- 'hrsh7th/cmp-path',
- },
- },
- config = function()
- -- Here is where you configure the autocompletion settings.
- local lsp_zero = require('lsp-zero')
- lsp_zero.extend_cmp()
-
- -- And you can configure cmp even more, if you want to.
- local cmp = require('cmp')
- local cmp_action = lsp_zero.cmp_action()
-
- cmp.setup({
- formatting = lsp_zero.cmp_format(),
- sources = {
- { name = 'nvim_lsp' }, -- Enable LSP-based completion
- { name = 'path' }, -- Enables path completion
- { name = 'buffer' }, -- Buffer source for plain text completion
- },
- mapping = cmp.mapping.preset.insert({
- ['<C-Space>'] = cmp.mapping.complete(),
- ['<C-u>'] = cmp.mapping.scroll_docs(-4),
- ['<C-d>'] = cmp.mapping.scroll_docs(4),
- ['<C-f>'] = cmp_action.luasnip_jump_forward(),
- ['<C-b>'] = cmp_action.luasnip_jump_backward(),
- }),
-
- -- },
- })
- end
- },
- -- LSP
- {
- 'neovim/nvim-lspconfig',
- cmd = {'LspInfo', 'LspInstall', 'LspStart'},
- event = {'BufReadPre', 'BufNewFile'},
- dependencies = {
- {'hrsh7th/cmp-nvim-lsp'},
- {'williamboman/mason-lspconfig.nvim'},
- },
- config = function()
- -- This is where all the LSP shenanigans will live
- local lsp_zero = require('lsp-zero')
- lsp_zero.extend_lspconfig()
-
- lsp_zero.on_attach(function(client, bufnr)
- -- see :help lsp-zero-keybindings
- -- to learn the available actions
- lsp_zero.default_keymaps({buffer = bufnr})
- end)
-
-
- require('mason-lspconfig').setup({
- ensure_installed = {},
- handlers = {
- lsp_zero.default_setup,
- lua_ls = function()
- -- (Optional) Configure lua language server for neovim
- local lua_opts = lsp_zero.nvim_lua_ls()
- require('lspconfig').lua_ls.setup(lua_opts)
- end,
- -- ADD THIS SECTION for clangd:
- clangd = function()
- require('lspconfig').clangd.setup({
- cmd = { "clangd", "--header-insertion=never" },
- -- No root_dir specification that requires compile_commands.json
- })
- end,
- }
- })
- end
- }
-
+ 'akinsho/toggleterm.nvim',
+ version = "*",
+ cmd = {"ToggleTerm", "ToggleTermSendCurrentLine", "ToggleTermSendVisualLines"},
},
+ ------------------------------------------------------------
+ -- EDITOR ENHANCEMENTS
+ ------------------------------------------------------------
+
+ -- Telescope (fuzzy finder)
{
'nvim-telescope/telescope.nvim',
- -- or , branch = '0.1.x',
- dependencies = { 'nvim-lua/plenary.nvim' }
+ dependencies = { 'nvim-lua/plenary.nvim' },
+ cmd = "Telescope",
},
+ -- Harpoon (quick file navigation)
{
- 'nvim-treesitter/nvim-treesitter',
- build = ':TSUpdate',
- config = function ()
- local configs = require("nvim-treesitter.configs")
-
- configs.setup({
- ensure_installed = { "c", "lua", "vim", "vimdoc", "cpp", "python"}, --add "neorg here"
- sync_install = false,
- highlight = {
- enable = true
- },
- indent = {
- enable = true
- },
- })
- end
+ "ThePrimeagen/harpoon",
+ branch = "harpoon2",
+ dependencies = { "nvim-lua/plenary.nvim" },
},
+ -- Git integration
{
- 'mbbill/undotree'
+ 'tpope/vim-fugitive',
+ cmd = {"Git", "Gstatus", "Gblame", "Gdiffsplit", "Gread", "Gwrite", "Ggrep", "GMove", "GDelete"},
},
- {'akinsho/toggleterm.nvim',
- version = "*",
- opts = {
- shell = "pwsh.exe -NoLogo",
- winbar = {
- enabled =false
- },
- direction = 'float',
- border = 'none', -- No border around the terminal
- -- width = function()
- -- return vim.o.columns -- Full width of the screen
- -- end,
- -- height = function()
- -- return vim.o.lines -- Full height minus command line
- -- end,
- -- width = 800,
- -- height = 700,
- }
+ -- Undo history visualization
+ {
+ 'mbbill/undotree',
+ cmd = "UndotreeToggle",
},
+
+ ------------------------------------------------------------
+ -- CODE EDITING
+ ------------------------------------------------------------
+
+ -- Syntax highlighting
{
- 'windwp/nvim-autopairs',
- event = "InsertEnter",
- config = true
- -- use opts = {} for passing setup options
- -- this is equivalent to setup({}) function
-},
+ 'nvim-treesitter/nvim-treesitter',
+ build = ':TSUpdate',
+ event = { "BufReadPost", "BufNewFile" },
+ cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" },
+ dependencies = {
+ 'nvim-treesitter/nvim-treesitter-context',
+ },
+ },
+ -- Comments
{
'numToStr/Comment.nvim',
- lazy = false,
- opts= {
- -- filetype = {
- -- seq ={
- -- commentstring ="! %s"
- -- }
- -- },
- ---Add a space b/w comment and the line
- padding = true,
- ---Whether the cursor should stay at its position
- sticky = true,
- ---Lines to be ignored while (un)comment
- ignore = nil,
- ---LHS of toggle mappings in NORMAL mode
- toggler = {
- ---Line-comment toggle keymap
- line = '<leader>/',
- ---Block-comment toggle keymap
- block = 'gbc',
- },
- ---LHS of operator-pending mappings in NORMAL and VISUAL mode
- opleader = {
- ---Line-comment keymap
- line = '<leader>/',
- ---Block-comment keymap
- block = 'gb',
- }}
+ event = { "BufReadPost", "BufNewFile" },
},
-
+ -- Auto brackets
{
- 'nvim-treesitter/nvim-treesitter-context'
+ 'windwp/nvim-autopairs',
+ event = "InsertEnter",
+ config = true,
},
+
+ -- LaTeX support
{
"lervag/vimtex",
- lazy = false, -- we don't want to lazy load VimTeX
- -- tag = "v2.15", -- uncomment to pin to a specific release
+ ft = {"tex", "latex"},
init = function()
- -- VimTeX configuration goes here, e.g.
vim.g.vimtex_view_method = "mupdf"
end
},
- -- {
- -- "nvim-telescope/telescope-file-browser.nvim",
- -- dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" },
- --
- -- },
-
+ ------------------------------------------------------------
+ -- LSP & COMPLETION
+ ------------------------------------------------------------
+
+ -- LSP Base
{
- "ThePrimeagen/harpoon",
- branch = "harpoon2",
- dependencies = { "nvim-lua/plenary.nvim" }
+ "mason-org/mason.nvim",
+ "mason-org/mason-lspconfig.nvim",
+ "neovim/nvim-lspconfig",
+},
+ {
+ "folke/lazydev.nvim",
+ ft = "lua", -- only load on lua files
+ opts = {
+ library = {
+ -- See the configuration section for more details
+ -- Load luvit types when the `vim.uv` word is found
+ { path = "${3rd}/luv/library", words = { "vim%.uv" } },
+ },
},
+ },
+
+ -- Autocompletion
{
- 'stevearc/oil.nvim',
- opts = {},
- -- Optional dependencies
- -- dependencies = { "echasnovski/mini.icons" },
- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if prefer nvim-web-devicons
- }
+ 'saghen/blink.cmp',
+ -- optional: provides snippets for the snippet source
+ dependencies = { 'rafamadriz/friendly-snippets' },
+
+ version = '1.*',
+ opts = {
+ -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept)
+ -- 'super-tab' for mappings similar to vscode (tab to accept)
+ -- 'enter' for enter to accept
+ -- 'none' for no mappings
+ --
+ -- All presets have the following mappings:
+ -- C-space: Open menu or open docs if already open
+ -- C-n/C-p or Up/Down: Select next/previous item
+ -- C-e: Hide menu
+ -- C-k: Toggle signature help (if signature.enabled = true)
+ --
+ -- See :h blink-cmp-config-keymap for defining your own keymap
+ keymap = { preset = 'default' },
+
+ appearance = {
+ -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
+ -- Adjusts spacing to ensure icons are aligned
+ nerd_font_variant = 'mono'
+ },
+
+ -- (Default) Only show the documentation popup when manually triggered
+ completion = { documentation = { auto_show = true} },
+
+ -- Default list of enabled providers defined so that you can extend it
+ -- elsewhere in your config, without redefining it, due to `opts_extend`
+sources = {
+ -- add lazydev to your completion providers
+ default = { "lazydev", "lsp", "path", "snippets", "buffer" },
+ providers = {
+ lazydev = {
+ name = "LazyDev",
+ module = "lazydev.integrations.blink",
+ -- make lazydev completions top priority (see `:h blink.cmp`)
+ score_offset = 100,
+ },
+ },
+ },
+ -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
+ -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
+ -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
+ --
+ -- See the fuzzy documentation for more information
+ fuzzy = { implementation = "prefer_rust_with_warning" }
+ },
+ opts_extend = { "sources.default" }
+},
+
+}, {
+ -- Lazy.nvim options
+ install = { colorscheme = { "tokyonight-night" } },
+ checker = { enabled = true, frequency = 86400 }, -- Check for updates once per day
+ change_detection = { notify = false },
+ performance = {
+ rtp = {
+ disabled_plugins = {
+ "gzip",
+ "tarPlugin",
+ "tohtml",
+ "tutor",
+ "zipPlugin",
+ },
+ },
+ },
})
|