summaryrefslogtreecommitdiff
path: root/.config/nvim_old/lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim_old/lua')
-rw-r--r--.config/nvim_old/lua/configs/basic.lua84
-rw-r--r--.config/nvim_old/lua/configs/filetype.lua7
-rw-r--r--.config/nvim_old/lua/configs/lazyvim.lua40
-rw-r--r--.config/nvim_old/lua/plugins/completions.lua53
-rw-r--r--.config/nvim_old/lua/plugins/lsp.lua62
-rw-r--r--.config/nvim_old/lua/plugins/marks.lua9
-rw-r--r--.config/nvim_old/lua/plugins/none-ls.lua29
-rw-r--r--.config/nvim_old/lua/plugins/nvim-dap.lua142
-rw-r--r--.config/nvim_old/lua/plugins/render-markdown.lua25
-rw-r--r--.config/nvim_old/lua/plugins/rust_analyzer.lua56
-rw-r--r--.config/nvim_old/lua/plugins/telescope.lua8
-rw-r--r--.config/nvim_old/lua/plugins/treesitter.lua14
12 files changed, 529 insertions, 0 deletions
diff --git a/.config/nvim_old/lua/configs/basic.lua b/.config/nvim_old/lua/configs/basic.lua
new file mode 100644
index 0000000..f4ccce1
--- /dev/null
+++ b/.config/nvim_old/lua/configs/basic.lua
@@ -0,0 +1,84 @@
+-----------
+-- Basic --
+-----------
+vim.g.mapleader = " "
+vim.opt.mouse = ''
+vim.opt.wrap = true
+vim.opt.number = true
+vim.opt.relativenumber = true
+vim.opt.laststatus = 2
+vim.opt.hlsearch = true
+vim.opt.incsearch = true
+-- Directory for swap files
+vim.opt.directory = vim.fn.expand("~/.local/share/nvim/swap//")
+-- Search into subfolders
+-- Provides tab completion for file related tasks
+vim.opt.path:append '**'
+-- Display all matching files when we tab complete
+vim.opt.wildmenu = true
+vim.cmd("filetype plugin on")
+vim.api.nvim_set_keymap('v', '<C-c>', '"+y', { noremap = true, silent = true })
+
+------------------------------------
+-- Native Neovim tabs and windows --
+------------------------------------
+vim.keymap.set('n', '<leader>f', '<cmd>Explore<CR>', { desc = 'Open Neotree' })
+vim.keymap.set("n", '<leader>c',function()
+ vim.cmd("Tex")
+ vim.cmd("wincmd r")
+end, { desc = "Open tab"})
+vim.keymap.set("n", '<leader>v', function()
+ vim.cmd("Vex")
+ vim.cmd("wincmd x")
+ vim.cmd("wincmd l")
+ vim.cmd("enew")
+end, { desc = "Open vertical split" })
+vim.keymap.set("n", '<leader>h', function()
+ vim.cmd("Sex")
+ vim.cmd("wincmd x")
+ vim.cmd("wincmd j")
+end, { desc = "Open horizontal split" })
+-- Open terminal
+local term_buf = nil
+vim.keymap.set('n', '<leader>t', function()
+ if term_buf and vim.api.nvim_buf_is_valid(term_buf) then
+ -- Reuse existing terminal
+ vim.cmd('rightbelow vsplit')
+ vim.cmd('buffer ' .. term_buf)
+ else
+ -- Create a new terminal
+ vim.cmd('rightbelow vsplit | terminal')
+ term_buf = vim.api.nvim_get_current_buf()
+ end
+ vim.cmd('startinsert')
+end, { desc = 'Open terminal in vertical split' })
+vim.keymap.set('t', '<Esc>', [[<C-\><C-n>:q<CR>]], { desc = 'Exit terminal mode' })
+vim.keymap.set('n', '<C-l>', '<cmd>tabnext +<CR>', { desc = 'Switch next tab' })
+vim.keymap.set('n', '<C-h>', '<cmd>tabnext -<CR>', { desc = 'Switch prev tab' })
+vim.keymap.set('n', '<C-A-h>', '<cmd>tabmove -1<CR>', { desc = 'Move current tab left' })
+vim.keymap.set('n', '<C-A-l>', '<cmd>tabmove +1<CR>', { desc = 'Move current tab right' })
+vim.keymap.set('n', '<A-k>', '<cmd>wincmd k<CR>', { desc = 'Move cursor to window above' })
+vim.keymap.set('n', '<A-j>', '<cmd>wincmd j<CR>', { desc = 'Move cursor to window below' })
+vim.keymap.set('n', '<A-h>', '<cmd>wincmd h<CR>', { desc = 'Move cursor to window left' })
+vim.keymap.set('n', '<A-l>', '<cmd>wincmd l<CR>', { desc = 'Move cursor to window right' })
+--------------------------------------------
+
+-----------------
+-- Diagnostics --
+-----------------
+vim.diagnostic.config({
+ virtual_text = false, -- Disable inline text diagnostics
+ signs = true, -- Keep signs in the sign column
+ update_in_insert = false,
+ underline = true,
+ severity_sort = true,
+})
+
+-- Show diagnostics on hover
+vim.o.updatetime = 250 -- Faster update time for hover
+vim.api.nvim_create_autocmd("CursorHold", {
+ pattern = "*",
+ callback = function()
+ vim.diagnostic.open_float(nil, { focus = false, scope = "cursor" })
+ end,
+})
diff --git a/.config/nvim_old/lua/configs/filetype.lua b/.config/nvim_old/lua/configs/filetype.lua
new file mode 100644
index 0000000..82725e2
--- /dev/null
+++ b/.config/nvim_old/lua/configs/filetype.lua
@@ -0,0 +1,7 @@
+vim.filetype.add({
+ extension = {
+ mq4 = "c",
+ mq5 = "cpp",
+ mqh = "cpp",
+ }
+})
diff --git a/.config/nvim_old/lua/configs/lazyvim.lua b/.config/nvim_old/lua/configs/lazyvim.lua
new file mode 100644
index 0000000..0b643b4
--- /dev/null
+++ b/.config/nvim_old/lua/configs/lazyvim.lua
@@ -0,0 +1,40 @@
+local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
+if not vim.loop.fs_stat(lazypath) then
+ vim.fn.system({
+ "git",
+ "clone",
+ "--filter=blob:none",
+ "https://github.com/folke/lazy.nvim.git",
+ "--branch=stable", -- latest stable release
+ lazypath,
+ })
+end
+vim.opt.rtp:prepend(lazypath)
+
+-- Rename Tmux Window to File Opened by Neovim
+-- https://github.com/Dyslectric/neovim-tmux-window-rename
+if vim.env.TMUX ~= nil then
+ -- Define an autocommand for BufEnter and FocusGained events
+ vim.api.nvim_create_autocmd({"BufEnter", "FocusGained"}, {
+ pattern = "*",
+ callback = function()
+ local file_name = vim.fn.expand("%:t")
+ local folder_name = vim.fn.expand("%:p:h:t")
+ local tmux_command = string.format(
+ "tmux rename-window 'Nv:%s/%s'", folder_name, file_name
+ )
+ vim.fn.system(tmux_command)
+ end
+ })
+
+ -- Define an autocommand for the VimLeave event
+ vim.api.nvim_create_autocmd("VimLeave", {
+ pattern = "*",
+ callback = function()
+ local shell = vim.env.SHELL or "sh"
+ vim.fn.system("tmux set-window-option automatic-rename on")
+ end
+ })
+end
+
+require("lazy").setup("plugins")
diff --git a/.config/nvim_old/lua/plugins/completions.lua b/.config/nvim_old/lua/plugins/completions.lua
new file mode 100644
index 0000000..483fac7
--- /dev/null
+++ b/.config/nvim_old/lua/plugins/completions.lua
@@ -0,0 +1,53 @@
+-- Autocompletions
+-- https://github.com/hrsh7th/nvim-cmp
+-- https://github.com/L3MON4D3/LuaSnip
+-- https://github.com/saadparwaiz1/cmp_luasnip
+-- https://github.com/rafamadriz/friendly-snippets
+-- https://github.com/hrsh7th/cmp-nvim-lsp
+
+return {
+ {
+ "hrsh7th/cmp-nvim-lsp",
+ },
+ {
+ 'L3MON4D3/LuaSnip',
+ dependencies = {
+ 'saadparwaiz1/cmp_luasnip',
+ 'rafamadriz/friendly-snippets',
+ }
+ },
+ {
+ "hrsh7th/nvim-cmp",
+ config = function()
+ local cmp = require'cmp'
+ require("luasnip.loaders.from_vscode").lazy_load()
+
+ cmp.setup({
+ snippet = {
+ expand = function(args)
+ require('luasnip').lsp_expand(args.body)
+ end,
+ },
+ window = {
+ completion = cmp.config.window.bordered(),
+ documentation = cmp.config.window.bordered(),
+ },
+ mapping = cmp.mapping.preset.insert({
+ ['<C-b>'] = cmp.mapping.scroll_docs(-4),
+ ['<C-f>'] = cmp.mapping.scroll_docs(4),
+ ['<C-Space>'] = cmp.mapping.complete(),
+ ['<C-e>'] = cmp.mapping.abort(),
+ ['<CR>'] = cmp.mapping.confirm({ select = true }),
+ ['<C-j>'] = cmp.mapping.select_next_item(),
+ ['<C-k>'] = cmp.mapping.select_prev_item(),
+ }),
+ sources = cmp.config.sources({
+ { name = 'nvim_lsp' },
+ { name = 'luasnip' },
+ }, {
+ { name = 'buffer' },
+ })
+ })
+ end,
+ }
+}
diff --git a/.config/nvim_old/lua/plugins/lsp.lua b/.config/nvim_old/lua/plugins/lsp.lua
new file mode 100644
index 0000000..0314c42
--- /dev/null
+++ b/.config/nvim_old/lua/plugins/lsp.lua
@@ -0,0 +1,62 @@
+-- Language server for specified languages
+-- Hover with 'K'
+-- Goto definition with :Goto
+-- Open code action with :Codeact
+
+local servers = {
+ "lua_ls", "bashls", "clangd", "marksman", "pyright", "lemminx",
+}
+
+return {
+ {
+ "williamboman/mason.nvim",
+ config = function()
+ require("mason").setup()
+ end
+ },
+
+ {
+ "williamboman/mason-lspconfig.nvim",
+ config = function()
+ require("mason-lspconfig").setup {
+ ensure_installed = servers,
+ automatic_installation = true,
+ }
+ end
+ },
+
+ {
+ "neovim/nvim-lspconfig",
+ config = function()
+ -- Advertise autocompletion to lsp
+ local capabilities = require('cmp_nvim_lsp').default_capabilities()
+ for _, server in ipairs(servers) do
+ vim.lsp.config(server, {
+ capabilities = capabilities,
+ })
+ end
+
+ -- Key mapping
+ -- Hover for definition
+ vim.keymap.set('n', 'K', vim.lsp.buf.hover, {})
+
+ -- Move to definition
+ vim.api.nvim_create_user_command(
+ "Goto",
+ function()
+ vim.lsp.buf.definition()
+ end,
+ {}
+ )
+
+ -- Code action
+ vim.api.nvim_create_user_command(
+ "Codeact",
+ function()
+ vim.lsp.buf.code_action()
+ end,
+ {}
+ )
+ end
+ }
+}
diff --git a/.config/nvim_old/lua/plugins/marks.lua b/.config/nvim_old/lua/plugins/marks.lua
new file mode 100644
index 0000000..1d452ce
--- /dev/null
+++ b/.config/nvim_old/lua/plugins/marks.lua
@@ -0,0 +1,9 @@
+return {
+ {
+ -- https://github.com/chentoast/marks.nvim
+ -- Makes marks visible
+ "chentoast/marks.nvim",
+ event = "VeryLazy",
+ opts = {},
+ }
+}
diff --git a/.config/nvim_old/lua/plugins/none-ls.lua b/.config/nvim_old/lua/plugins/none-ls.lua
new file mode 100644
index 0000000..ee6d859
--- /dev/null
+++ b/.config/nvim_old/lua/plugins/none-ls.lua
@@ -0,0 +1,29 @@
+-- Formatter
+-- https://github.com/nvimtools/none-ls.nvim
+-- Press '=' to format highlighted code
+return {
+ "nvimtools/none-ls.nvim",
+ config = function()
+ local null_ls = require("null-ls")
+ null_ls.setup({
+ sources = {
+ -- Formatting
+ null_ls.builtins.formatting.black,
+ --
+ -- Diagnostics
+ -- null_ls.builtins.diagnostics.<package>,
+ --
+ -- Completion
+ -- null_ls.builtins.completion.<package>,
+ }
+ })
+
+ vim.api.nvim_create_user_command(
+ "Format",
+ function()
+ vim.lsp.buf.format()
+ end,
+ {}
+ )
+ end
+}
diff --git a/.config/nvim_old/lua/plugins/nvim-dap.lua b/.config/nvim_old/lua/plugins/nvim-dap.lua
new file mode 100644
index 0000000..5a6d1ae
--- /dev/null
+++ b/.config/nvim_old/lua/plugins/nvim-dap.lua
@@ -0,0 +1,142 @@
+-- Debugger
+-- https://github.com/mfussenegger/nvim-dap
+return {
+ "mfussenegger/nvim-dap",
+ event = "BufRead",
+ dependencies = {
+ "rcarriga/nvim-dap-ui",
+ "theHamsta/nvim-dap-virtual-text",
+ "nvim-telescope/telescope-dap.nvim",
+ "nvim-neotest/nvim-nio"
+ },
+ config = function()
+ local dap = require("dap")
+ local dapui = require("dapui")
+ local virtual_text = require("nvim-dap-virtual-text")
+
+ dap.adapters.lldb = {
+ type = 'executable',
+ command = '/usr/bin/lldb-dap',
+ name = 'lldb'
+ }
+
+ local lldb = {
+ name = "Launch lldb",
+ type = "lldb",
+ request = "launch",
+ program = function()
+ return vim.fn.input(
+ "Path to executable: ", vim.fn.getcwd() .. "/", "file"
+ )
+ end,
+ cwd = "${workspaceFolder}",
+ stopOnEntry = false,
+ args = {},
+ runInTerminal = false,
+ }
+
+ dap.configurations.rust = {lldb}
+ dap.configurations.c = {lldb}
+
+ dapui.setup(
+ {
+ controls = {
+ element = "repl",
+ enabled = true,
+ icons = {
+ disconnect = "🔗❌",
+ pause = "⏸",
+ play = "▶",
+ run_last = "⏭",
+ step_back = "↶",
+ step_into = "↓",
+ step_out = "↑",
+ step_over = "↷",
+ terminate = "⏹"
+ }
+ },
+ element_mappings = {},
+ expand_lines = true,
+ floating = {
+ border = "single",
+ mappings = {
+ close = { "q", "<Esc>" }
+ }
+ },
+ force_buffers = true,
+ icons = {
+ collapsed = "",
+ current_frame = "",
+ expanded = ""
+ },
+ layouts = {
+ {
+ elements = {
+ {
+ id = "scopes",
+ size = 0.25
+ },
+ {
+ id = "breakpoints",
+ size = 0.25
+ },
+ {
+ id = "stacks",
+ size = 0.25
+ },
+ {
+ id = "watches",
+ size = 0.25
+ }
+ },
+ position = "left",
+ size = 40
+ },
+ {
+ elements = {
+ {
+ id = "repl",
+ size = 0.5
+ },
+ {
+ id = "console",
+ size = 0.5
+ }
+ },
+ position = "bottom",
+ size = 10
+ }
+ },
+ mappings = {
+ edit = "e",
+ expand = { "<CR>", "<2-LeftMouse>" },
+ open = "o",
+ remove = "d",
+ repl = "r",
+ toggle = "t"
+ },
+ render = {
+ indent = 1,
+ max_value_lines = 100
+ }
+ }
+ )
+
+ virtual_text.setup()
+
+ vim.api.nvim_create_user_command(
+ "Debug",
+ function()
+ dapui.toggle()
+ end,
+ {}
+ )
+ vim.keymap.set('n', "<Leader>b", dap.toggle_breakpoint, {})
+ vim.keymap.set('n', "<F2>", dap.continue, {})
+ vim.keymap.set('n', "<F3>", dap.step_over, {})
+ vim.keymap.set('n', "<F4>", dap.step_back, {})
+ vim.keymap.set('n', "<F5>", dap.step_into, {})
+ vim.keymap.set('n', "<F6>", dap.step_out, {})
+ vim.keymap.set('n', "<Leader>n", dap.restart, {})
+ end
+}
diff --git a/.config/nvim_old/lua/plugins/render-markdown.lua b/.config/nvim_old/lua/plugins/render-markdown.lua
new file mode 100644
index 0000000..d0d0639
--- /dev/null
+++ b/.config/nvim_old/lua/plugins/render-markdown.lua
@@ -0,0 +1,25 @@
+-- https://github.com/MeanderingProgrammer/render-markdown.nvim
+return {
+ {
+ 'MeanderingProgrammer/render-markdown.nvim',
+ opts = {},
+ dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.nvim' }
+ },
+ {
+ 'ChuufMaster/markdown-toc', --https://github.com/ChuufMaster/markdown-toc
+ -- ":GenerateTOC"
+ -- ":DeleteTOC"
+ opts = {
+
+ -- The heading level to match (i.e the number of "#"s to match to) max 6
+ heading_level_to_match = -1,
+
+ -- Set to True display a dropdown to allow you to select the heading level
+ ask_for_heading_level = false,
+
+ -- TOC default string
+ -- WARN
+ toc_format = '%s- [%s](<%s#%s>)',
+ }
+ }
+}
diff --git a/.config/nvim_old/lua/plugins/rust_analyzer.lua b/.config/nvim_old/lua/plugins/rust_analyzer.lua
new file mode 100644
index 0000000..914befe
--- /dev/null
+++ b/.config/nvim_old/lua/plugins/rust_analyzer.lua
@@ -0,0 +1,56 @@
+-- https://github.com/mrcjkb/rustaceanvim
+
+return {
+ {
+ 'mrcjkb/rustaceanvim',
+ version = '^6', -- Recommended
+ lazy = false, -- This plugin is already lazy
+ config = function ()
+ vim.g.rustaceanvim = {
+ -- Plugin configuration
+ tools = {
+ },
+ -- LSP configuration
+ server = {
+ default_settings = {
+ -- rust-analyzer language server configuration
+ -- https://rust-analyzer.github.io/book/configuration.html
+ ['rust-analyzer'] = {
+ checkOnSave = true,
+ check = {
+ enable = true,
+ command = "clippy",
+ features = "all",
+ },
+ completion = {
+ autoimport = {
+ enable = false;
+ }
+ },
+ files = {
+ exclude = {
+ "build-dir/",
+ ".flatpak-builder",
+ }
+ }
+ --settings = {
+ -- cargo = { allFeatures = true },
+ -- imports = { group = { enable = false } },
+ -- completion = { postfix = { enable = false } },
+ -- -- https://www.reddit.com/r/rust/comments/1e978l7/comment/led7ibp/
+ -- -- checkOnSave = { command = "clippy" },
+ -- checkOnSave = { command = false },
+
+ -- diagnostics = { enable = true },
+ -- rustfmt = { enable = true },
+ --}
+ },
+ },
+ },
+ -- DAP configuration
+ dap = {
+ },
+ }
+ end
+ },
+}
diff --git a/.config/nvim_old/lua/plugins/telescope.lua b/.config/nvim_old/lua/plugins/telescope.lua
new file mode 100644
index 0000000..e3ab856
--- /dev/null
+++ b/.config/nvim_old/lua/plugins/telescope.lua
@@ -0,0 +1,8 @@
+return {
+ -- https://github.com/nvim-telescope/telescope.nvim
+ 'nvim-telescope/telescope.nvim',
+ tag = '0.1.8',
+ dependencies = {
+ 'nvim-lua/plenary.nvim'
+ }
+}
diff --git a/.config/nvim_old/lua/plugins/treesitter.lua b/.config/nvim_old/lua/plugins/treesitter.lua
new file mode 100644
index 0000000..f04198f
--- /dev/null
+++ b/.config/nvim_old/lua/plugins/treesitter.lua
@@ -0,0 +1,14 @@
+-- Syntax highlighting
+-- https://github.com/nvim-treesitter/nvim-treesitter
+return {
+ "nvim-treesitter/nvim-treesitter",
+ build = ":TSUpdate",
+
+ config = function()
+ require("nvim-treesitter.configs").setup({
+ auto_install = true,
+ highlight = { enable = true },
+ indent = { enable = true },
+ })
+ end
+}