From 102f9a5608cbb7b5553cd0d1862b6bd8e40c8075 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 11 May 2025 00:43:32 +0200 Subject: refractored neovim config --- nvim_old/lua/codev.lua | 11 ++ nvim_old/lua/keybindings.lua | 162 +++++++++++++++++++++++++++ nvim_old/lua/options.lua | 43 ++++++++ nvim_old/lua/plugins.lua | 256 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 472 insertions(+) create mode 100644 nvim_old/lua/codev.lua create mode 100644 nvim_old/lua/keybindings.lua create mode 100644 nvim_old/lua/options.lua create mode 100644 nvim_old/lua/plugins.lua (limited to 'nvim_old/lua') diff --git a/nvim_old/lua/codev.lua b/nvim_old/lua/codev.lua new file mode 100644 index 0000000..ed6c330 --- /dev/null +++ b/nvim_old/lua/codev.lua @@ -0,0 +1,11 @@ +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_old/lua/keybindings.lua b/nvim_old/lua/keybindings.lua new file mode 100644 index 0000000..9a9d0f0 --- /dev/null +++ b/nvim_old/lua/keybindings.lua @@ -0,0 +1,162 @@ +vim.g.mapleader = " " +--Telescope keys +-- local builtin = require('telescope.builtin') +-- vim.keymap.set('n', 'ps', function() +-- builtin.grep_string({ search = vim.fn.input("Grep > ") }) +-- end) + +-- vim.keymap.set('n', 'pf', builtin.find_files, {}) +-- vim.keymap.set("n", "pv", vim.cmd.Ex) +-- vim.keymap.set('n', "ps", builtin.live_grep,{}) +-- vim.keymap.set('n', "pb", builtin.buffers,{}) + +-- vim.keymap.set('n', 'ff', 'Telescope find_files search_dirs=[".","D:/Optics/CODEV/Macros","C:/CODEV202403/macro","C:/CODEV202403/lens"] theme=dropdown') +vim.keymap.set('n', 'ff', "Telescope find_files theme=dropdown") +vim.keymap.set('n', 'fm', "Telescope find_files cwd=D:/Optics/CODEV/Macros theme=dropdown") +vim.keymap.set('n', 'fc', "Telescope find_files cwd=C:/CODEV202403/macro theme=dropdown") +vim.keymap.set('n', 'fl', "Telescope find_files cwd=C:/CODEV202403/lens theme=dropdown") + +vim.keymap.set("n", "pp", "Telescope file_browser theme=dropdown") +vim.keymap.set("n", "pm", "Telescope file_browser cwd=D:/Optics/CODEV/Macros theme=dropdown") +vim.keymap.set("n", "pc", "Telescope file_browser cwd=C:/CODEV202403/macro theme=dropdown") +vim.keymap.set("n", "pl", "Telescope file_browser cwd=C:/CODEV202403/lens theme=dropdown") + +vim.keymap.set('n', "gg", "Telescope live_grep theme=dropdown") +vim.keymap.set('n', "gm", "Telescope live_grep cwd=D:/Optics/CODEV/Macros theme=dropdown") +vim.keymap.set('n', "gc", "Telescope live_grep cwd=C:/CODEV202403/macro theme=dropdown") +vim.keymap.set('n', "gl", "Telescope live_grep cwd=C:/CODEV202403/lens theme=dropdown") + + +vim.keymap.set('n', "b", "Telescope buffers theme=dropdown") + +vim.keymap.set('n', 'u', vim.cmd.UndotreeToggle) +vim.keymap.set('n', '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", "vws", function() vim.lsp.buf.workspace_symbol() end, opts) + vim.keymap.set("n", "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", "vca", function() vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "vrr", function() vim.lsp.buf.references() end, opts) + vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, opts) + vim.keymap.set("i", "", 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({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.complete(), + }), +}) +-- General Keybindings +vim.keymap.set("i", "jk", "") +vim.keymap.set("n","w", "w") +vim.keymap.set("n","q", "q") +vim.keymap.set("n","", "bd") +vim.keymap.set("i","", "bd") +vim.keymap.set("n","Q", "q!") +vim.keymap.set("n","o", "o") +vim.keymap.set("n","O", "O") +vim.keymap.set("i", "e", "e") +--File Formatting +vim.keymap.set("n","S", "ggVG=") +-- Moving Lines around +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") +vim.keymap.set("n", "J", "mzJ`z") +--Fast Vertical Navigation +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "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", "p", [["_dP]]) +-- copying into system clipboard +vim.keymap.set({"n", "v"}, "y", [["+y]]) +vim.keymap.set("n", "Y", [["+Y]]) +-- Put into Void Register +vim.keymap.set({"n", "v"}, "d", [["_d]]) +-- Quick Fix List Navingation +--vim.keymap.set("n", "", "cnextzz") +--vim.keymap.set("n", "", "cprevzz") +vim.keymap.set("n", "k", "lnextzz") +vim.keymap.set("n", "j", "lprevzz") +-- Terminal Navigation +-- vim.keymap.set("n", "tt", "ToggleTerm size=60 direction=horizontal shell=powershell") +vim.keymap.set("n", "t", "ToggleTerm") +-- vim.keymap.set("n", "", "ToggleTerm") +-- vim.keymap.set("i", "", "ToggleTerm") +-- vim.keymap.set("n", "tt", "vertical 60 vsplit | terminal pwsh.exe") +-- vim.keymap.set("n", "tj", "term pwsh.exe") +vim.keymap.set("t", "jk", [[]]) +vim.keymap.set("t", "", [[h]]) +vim.keymap.set("t", "", [[j]]) +vim.keymap.set("t", "", [[k]]) +vim.keymap.set("t", "", [[l]]) +--Sending lines and file to the internal terminal I had before to make the cursor move to the previous position but this doesnt seem to be a good option +vim.keymap.set({"n", "i"},"", "ToggleTermSendCurrentLinej") +vim.keymap.set("n","", "ggVG:'<,'>ToggleTermSendVisualLines") +vim.keymap.set("i","", "ggVG:'<,'>ToggleTermSendVisualLinesi") +vim.keymap.set("v","", ":ToggleTermSendVisualLines") +-- Buffer Navigation +vim.keymap.set("n", "", [[h]]) +vim.keymap.set("n", "", [[j]]) +vim.keymap.set("n", "", [[k]]) +vim.keymap.set("n", "", [[l]]) +-- Undo Remapping +vim.keymap.set("n", "U", "") +-- Replace the Current Word everywhere +vim.keymap.set("n", "s", [[:%s/\<\>//gI]]) +-- Nvim-Tree +-- vim.keymap.set("n", "e", "NvimTreeToggle") +-- BufferLine Navigation +-- vim.keymap.set("n", "", "BufferLineCycleNext") +-- vim.keymap.set("n", "", "BufferLineCyclePrev") +-- vim.keymap.set("n", "", "BufferLineCloseOthers") +-- Treesitter Context +vim.keymap.set("n", "[c", function() + require("treesitter-context").go_to_context() +end, { silent = true }) +-- Docstring commands +vim.keymap.set("n","dc",[[i"""oo#Information:oo#Arguments:oo#Returns:oo"""7k]]) + + + +--vim.keymap.set('n', '', bultin.git_files,{}) +--Oil.nvim keybinds +vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) + +vim.keymap.set("n","m","silent make") diff --git a/nvim_old/lua/options.lua b/nvim_old/lua/options.lua new file mode 100644 index 0000000..944ea6d --- /dev/null +++ b/nvim_old/lua/options.lua @@ -0,0 +1,43 @@ +--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_old/lua/plugins.lua b/nvim_old/lua/plugins.lua new file mode 100644 index 0000000..79b4c5f --- /dev/null +++ b/nvim_old/lua/plugins.lua @@ -0,0 +1,256 @@ +-- lazy plugin manager +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", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", + lazypath, + }) +end +vim.opt.rtp:prepend(vim.env.LAZY or lazypath) + +require("lazy").setup({ + -- Colorscheme + { + "folke/tokyonight.nvim", + init = function() + vim.cmd.colorscheme("tokyonight-night") + end + }, + + { + 'tpope/vim-fugitive', + }, + + { + { + '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({ + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp_action.luasnip_jump_forward(), + [''] = 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 + } + + }, + + { + 'nvim-telescope/telescope.nvim', + -- or , branch = '0.1.x', + dependencies = { 'nvim-lua/plenary.nvim' } + }, + + { + '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 + }, + + { + 'mbbill/undotree' + }, + + {'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, + } + }, + { + 'windwp/nvim-autopairs', + event = "InsertEnter", + config = true + -- use opts = {} for passing setup options + -- this is equivalent to setup({}) function +}, + + { + '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 = '/', + ---Block-comment toggle keymap + block = 'gbc', + }, + ---LHS of operator-pending mappings in NORMAL and VISUAL mode + opleader = { + ---Line-comment keymap + line = '/', + ---Block-comment keymap + block = 'gb', + }} + }, + + + { + 'nvim-treesitter/nvim-treesitter-context' + }, + { + "lervag/vimtex", + lazy = false, -- we don't want to lazy load VimTeX + -- tag = "v2.15", -- uncomment to pin to a specific release + 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" }, + -- + -- }, + + { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim" } + }, + { + 'stevearc/oil.nvim', + opts = {}, + -- Optional dependencies + -- dependencies = { "echasnovski/mini.icons" }, + dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if prefer nvim-web-devicons + } +}) -- cgit v1.2.3