From 271fe55b819fb941637e6be04e01afc63a235b62 Mon Sep 17 00:00:00 2001 From: Al-Hassan Abdel-Raouf Date: Fri, 28 Jul 2023 23:02:18 +0300 Subject: [PATCH] update git and nvim configs --- .config/git/config | 4 +- .config/nvim/init.lua | 117 +++++++++++++++--------- .config/nvim/lua/CMD.lua | 77 ++++++++++++++++ .config/nvim/lua/DAP.lua | 72 +++++++++++++++ .config/nvim/lua/LSP.lua | 12 +++ .config/nvim/lua/snippets.lua | 1 + .config/nvim/plugin/packer_compiled.lua | 73 +++++++++++++-- .config/zsh/.zsh_plugins.zsh | 8 +- 8 files changed, 307 insertions(+), 57 deletions(-) create mode 100644 .config/nvim/lua/CMD.lua create mode 100644 .config/nvim/lua/snippets.lua diff --git a/.config/git/config b/.config/git/config index e867a5e..3327909 100644 --- a/.config/git/config +++ b/.config/git/config @@ -1,6 +1,6 @@ [user] name = Al-Hassan Abdel-Raouf - email = alhassanaraouf@alhassanaraouf.me + email = alhassan@raoufs.me [filter "lfs"] @@ -8,3 +8,5 @@ clean = git-lfs clean -- %f smudge = git-lfs smudge -- %f process = git-lfs filter-process +[init] + defaultBranch = master diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index b1282c9..c213a8e 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,64 +1,95 @@ -local use = require('packer').use +local use = require("packer").use -- vim.opt.spell = true -require('packer').startup(function() - use 'wbthomason/packer.nvim' -- Package manager +require("packer").startup(function() + use("wbthomason/packer.nvim") -- Package manager - -- deps - use 'nvim-lua/plenary.nvim' + -- deps + use("nvim-lua/plenary.nvim") + use("folke/neodev.nvim") - -- LSP - use 'williamboman/mason.nvim' - use 'williamboman/mason-lspconfig.nvim' - use 'neovim/nvim-lspconfig' -- Configurations for Nvim LSP - use 'mfussenegger/nvim-dap' - use 'mfussenegger/nvim-lint' - use 'mhartington/formatter.nvim' + -- LSP + use("williamboman/mason.nvim") + use("williamboman/mason-lspconfig.nvim") + use("neovim/nvim-lspconfig") -- Configurations for Nvim LSP + use("mfussenegger/nvim-dap") + use("rcarriga/nvim-dap-ui") + use("mfussenegger/nvim-lint") + use("mhartington/formatter.nvim") - -- Treesitter - use 'nvim-treesitter/nvim-treesitter' - use 'nvim-treesitter/playground' + -- Treesitter + use("nvim-treesitter/nvim-treesitter") + use("nvim-treesitter/playground") - -- Coq Completion - use 'ms-jpq/coq_nvim' - use 'ms-jpq/coq.artifacts' - use 'ms-jpq/coq.thirdparty' + use("hrsh7th/cmp-nvim-lsp") + use("hrsh7th/cmp-buffer") + use("hrsh7th/cmp-path") + use("hrsh7th/cmp-cmdline") + use("petertriho/cmp-git") + use("andersevenrud/cmp-tmux") + use("rcarriga/cmp-dap") + use("hrsh7th/nvim-cmp") - -- Markdown Preview - use 'ellisonleao/glow.nvim' + use("L3MON4D3/LuaSnip") + use("saadparwaiz1/cmp_luasnip") + -- use("doxnit/cmp-luasnip-choice") - -- Vifm - use 'vifm/vifm.vim' + use("rafamadriz/friendly-snippets") + -- use("molleweide/LuaSnip-snippets.nvim") - -- Git - use 'TimUntersberger/neogit' - use 'f-person/git-blame.nvim' + -- Coq Completion + -- use 'ms-jpq/coq_nvim' + -- use 'ms-jpq/coq.artifacts' + -- use 'ms-jpq/coq.thirdparty' - -- Comments - use 'numToStr/Comment.nvim' + use("antoinemadec/FixCursorHold.nvim") + use("nvim-neotest/neotest") + use("olimorris/neotest-phpunit") - use 'mickael-menu/zk-nvim' + -- Markdown Preview + use("ellisonleao/glow.nvim") + + -- Vifm + use("vifm/vifm.vim") + + -- Git + use("TimUntersberger/neogit") + use("f-person/git-blame.nvim") + + -- Comments + use("numToStr/Comment.nvim") + + use("mickael-menu/zk-nvim") end) +require("Comment").setup() +require("neodev").setup({ + -- add any options here, or leave empty to use the default settings +}) -require('Comment').setup() require("mason").setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - } - } + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗", + }, + }, }) require("zk").setup() +require("neotest").setup({ + adapters = { + require("neotest-phpunit"), + }, +}) -require "LSP" -require "DAP" -require "treesitter" -require "formatting" -require "linting" - +require("CMD") +require("treesitter") +require("DAP") +require("formatting") +require("linting") +require("snippets") +require("LSP") diff --git a/.config/nvim/lua/CMD.lua b/.config/nvim/lua/CMD.lua new file mode 100644 index 0000000..234778e --- /dev/null +++ b/.config/nvim/lua/CMD.lua @@ -0,0 +1,77 @@ +require("cmp_git").setup() +local cmp = require("cmp") + +cmp.setup({ + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. + require("luasnip").lsp_expand(args.body) -- For `luasnip` users. + -- require('snippy').expand_snippet(args.body) -- For `snippy` users. + -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "path" }, + { name = "cmdline" }, + { name = "buffer" }, + { name = "tmux" }, + { name = "git" }, + }, { + { name = "buffer" }, + }), +}) + +-- Set configuration for specific filetype. +cmp.setup.filetype("gitcommit", { + sources = cmp.config.sources({ + { name = "cmp_git" }, -- You can specify the `cmp_git` source if you were installed it. + }, { + { name = "buffer" }, + }), +}) +cmp.setup.filetype({ "dap-repl", "dapui_watches", "dapui_hover" }, { + sources = { + { name = "dap" }, + }, +}) + +-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline({ "/", "?" }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, +}) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), +}) + + +require("cmp").setup({ + enabled = function() + return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt" + or require("cmp_dap").is_dap_buffer() + end +}) + diff --git a/.config/nvim/lua/DAP.lua b/.config/nvim/lua/DAP.lua index f450b53..a1c63ff 100644 --- a/.config/nvim/lua/DAP.lua +++ b/.config/nvim/lua/DAP.lua @@ -1,4 +1,5 @@ local dap = require("dap") +local dapui = require("dapui") dap.adapters.php = { type = "executable", @@ -42,3 +43,74 @@ dap.configurations.sh = { terminalKind = "integrated", }, } + +dap.adapters.python = { + type = "executable", + -- command = "path/to/virtualenvs/debugpy/bin/python", + command = "python", + args = { "-m", "debugpy.adapter" }, +} + +dap.configurations.python = { + { + -- The first three options are required by nvim-dap + type = "python", -- the type here established the link to the adapter definition: `dap.adapters.python` + request = "launch", + name = "Launch file", + }, +} + +dapui.setup() + +dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() +end +dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() +end +dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close() +end + + +vim.keymap.set("n", "", function() + require("dap").continue() +end) +vim.keymap.set("n", "", function() + require("dap").step_over() +end) +vim.keymap.set("n", "", function() + require("dap").step_into() +end) +vim.keymap.set("n", "", function() + require("dap").step_out() +end) +vim.keymap.set("n", "b", function() + require("dap").toggle_breakpoint() +end) +vim.keymap.set("n", "B", function() + require("dap").set_breakpoint() +end) +vim.keymap.set("n", "lp", function() + require("dap").set_breakpoint(nil, nil, vim.fn.input("Log point message: ")) +end) +vim.keymap.set("n", "dr", function() + require("dap").repl.open() +end) +vim.keymap.set("n", "dl", function() + require("dap").run_last() +end) +vim.keymap.set({ "n", "v" }, "dh", function() + require("dap.ui.widgets").hover() +end) +vim.keymap.set({ "n", "v" }, "dp", function() + require("dap.ui.widgets").preview() +end) +vim.keymap.set("n", "df", function() + local widgets = require("dap.ui.widgets") + widgets.centered_float(widgets.frames) +end) +vim.keymap.set("n", "ds", function() + local widgets = require("dap.ui.widgets") + widgets.centered_float(widgets.scopes) +end) diff --git a/.config/nvim/lua/LSP.lua b/.config/nvim/lua/LSP.lua index 6f75b17..9de7877 100644 --- a/.config/nvim/lua/LSP.lua +++ b/.config/nvim/lua/LSP.lua @@ -1,16 +1,28 @@ +local capabilities = require("cmp_nvim_lsp").default_capabilities() + + require("mason-lspconfig").setup({ ensure_installed = { "psalm", "terraformls", "lua_ls" }, automatic_installation = true, + capabilities = capabilities, }) require("lspconfig")["lua_ls"].setup({ on_attach = on_attach, flags = lsp_flags, + capabilities = capabilities, }) require("lspconfig")["psalm"].setup({ on_attach = on_attach, flags = lsp_flags, + capabilities = capabilities, }) require("lspconfig")["terraformls"].setup({ on_attach = on_attach, flags = lsp_flags, + capabilities = capabilities, +}) +require("lspconfig")["pyright"].setup({ + on_attach = on_attach, + flags = lsp_flags, + capabilities = capabilities, }) diff --git a/.config/nvim/lua/snippets.lua b/.config/nvim/lua/snippets.lua new file mode 100644 index 0000000..80309d7 --- /dev/null +++ b/.config/nvim/lua/snippets.lua @@ -0,0 +1 @@ +require("luasnip.loaders.from_vscode").lazy_load() diff --git a/.config/nvim/plugin/packer_compiled.lua b/.config/nvim/plugin/packer_compiled.lua index 72205ce..adc4d1f 100644 --- a/.config/nvim/plugin/packer_compiled.lua +++ b/.config/nvim/plugin/packer_compiled.lua @@ -79,26 +79,61 @@ _G.packer_plugins = { path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/Comment.nvim", url = "https://github.com/numToStr/Comment.nvim" }, - ["coq.artifacts"] = { + ["FixCursorHold.nvim"] = { loaded = true, - path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/coq.artifacts", - url = "https://github.com/ms-jpq/coq.artifacts" + path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/FixCursorHold.nvim", + url = "https://github.com/antoinemadec/FixCursorHold.nvim" }, - ["coq.thirdparty"] = { + LuaSnip = { loaded = true, - path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/coq.thirdparty", - url = "https://github.com/ms-jpq/coq.thirdparty" + path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/LuaSnip", + url = "https://github.com/L3MON4D3/LuaSnip" }, - coq_nvim = { + ["cmp-buffer"] = { loaded = true, - path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/coq_nvim", - url = "https://github.com/ms-jpq/coq_nvim" + path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/cmp-buffer", + url = "https://github.com/hrsh7th/cmp-buffer" + }, + ["cmp-cmdline"] = { + loaded = true, + path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/cmp-cmdline", + url = "https://github.com/hrsh7th/cmp-cmdline" + }, + ["cmp-git"] = { + loaded = true, + path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/cmp-git", + url = "https://github.com/petertriho/cmp-git" + }, + ["cmp-nvim-lsp"] = { + loaded = true, + path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", + url = "https://github.com/hrsh7th/cmp-nvim-lsp" + }, + ["cmp-path"] = { + loaded = true, + path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/cmp-path", + url = "https://github.com/hrsh7th/cmp-path" + }, + ["cmp-tmux"] = { + loaded = true, + path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/cmp-tmux", + url = "https://github.com/andersevenrud/cmp-tmux" + }, + cmp_luasnip = { + loaded = true, + path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/cmp_luasnip", + url = "https://github.com/saadparwaiz1/cmp_luasnip" }, ["formatter.nvim"] = { loaded = true, path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/formatter.nvim", url = "https://github.com/mhartington/formatter.nvim" }, + ["friendly-snippets"] = { + loaded = true, + path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/friendly-snippets", + url = "https://github.com/rafamadriz/friendly-snippets" + }, ["git-blame.nvim"] = { loaded = true, path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/git-blame.nvim", @@ -119,11 +154,31 @@ _G.packer_plugins = { path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/mason.nvim", url = "https://github.com/williamboman/mason.nvim" }, + ["neodev.nvim"] = { + loaded = true, + path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/neodev.nvim", + url = "https://github.com/folke/neodev.nvim" + }, neogit = { loaded = true, path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/neogit", url = "https://github.com/TimUntersberger/neogit" }, + neotest = { + loaded = true, + path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/neotest", + url = "https://github.com/nvim-neotest/neotest" + }, + ["neotest-phpunit"] = { + loaded = true, + path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/neotest-phpunit", + url = "https://github.com/olimorris/neotest-phpunit" + }, + ["nvim-cmp"] = { + loaded = true, + path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/nvim-cmp", + url = "https://github.com/hrsh7th/nvim-cmp" + }, ["nvim-dap"] = { loaded = true, path = "/home/alhassan/.local/share/nvim/site/pack/packer/start/nvim-dap", diff --git a/.config/zsh/.zsh_plugins.zsh b/.config/zsh/.zsh_plugins.zsh index c5497f2..d839a4a 100644 --- a/.config/zsh/.zsh_plugins.zsh +++ b/.config/zsh/.zsh_plugins.zsh @@ -1,7 +1,3 @@ -if ! (( $+functions[zsh-defer] )); then - fpath+=( /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-romkatv-SLASH-zsh-defer ) - source /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-romkatv-SLASH-zsh-defer/zsh-defer.plugin.zsh -fi fpath+=( /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-ohmyzsh-SLASH-ohmyzsh/plugins/git ) source /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-ohmyzsh-SLASH-ohmyzsh/plugins/git/git.plugin.zsh fpath+=( /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-ohmyzsh-SLASH-ohmyzsh/plugins/tmux ) @@ -38,6 +34,10 @@ fpath+=( /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLA source /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-autosuggestions/zsh-autosuggestions.plugin.zsh fpath+=( /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-completions ) source /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-completions/zsh-completions.plugin.zsh +if ! (( $+functions[zsh-defer] )); then + fpath+=( /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-romkatv-SLASH-zsh-defer ) + source /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-romkatv-SLASH-zsh-defer/zsh-defer.plugin.zsh +fi fpath+=( /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zdharma-continuum-SLASH-fast-syntax-highlighting ) zsh-defer source /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zdharma-continuum-SLASH-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh fpath+=( /home/alhassan/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zsh-users-SLASH-zsh-history-substring-search )