From 095c6182eb70245b57ed66f47960b7edb4eb419a Mon Sep 17 00:00:00 2001 From: Snoweuph Date: Sat, 24 Feb 2024 20:53:17 +0100 Subject: [PATCH] Setup --- .gitignore | 2 +- nvim/.luarc.json | 5 + nvim/init.lua | 1 + nvim/lua/core/init.lua | 2 + nvim/lua/core/packagemanager.lua | 15 +++ nvim/lua/plugins.lua | 1 + nvim/lua/plugins/code-autobrackets.lua | 6 + nvim/lua/plugins/code-highliting.lua | 13 ++ nvim/lua/plugins/code-lsp-extra.lua | 40 ++++++ nvim/lua/plugins/code-lsp.lua | 162 +++++++++++++++++++++++++ nvim/lua/plugins/code-snippets.lua | 71 +++++++++++ nvim/lua/plugins/dashboard.lua | 32 +++++ nvim/lua/plugins/debugging.lua | 29 +++++ nvim/lua/plugins/editor-bar.lua | 60 +++++++++ nvim/lua/plugins/file-tree.lua | 61 ++++++++++ nvim/lua/plugins/git.lua | 17 +++ nvim/lua/plugins/search.lua | 24 ++++ nvim/lua/plugins/theme.lua | 9 ++ nvim/lua/vim-config/editor.lua | 8 ++ nvim/lua/vim-config/init.lua | 2 + nvim/lua/vim-config/keymap.lua | 3 + 21 files changed, 562 insertions(+), 1 deletion(-) create mode 100644 nvim/.luarc.json create mode 100644 nvim/init.lua create mode 100644 nvim/lua/core/init.lua create mode 100644 nvim/lua/core/packagemanager.lua create mode 100644 nvim/lua/plugins.lua create mode 100644 nvim/lua/plugins/code-autobrackets.lua create mode 100644 nvim/lua/plugins/code-highliting.lua create mode 100644 nvim/lua/plugins/code-lsp-extra.lua create mode 100644 nvim/lua/plugins/code-lsp.lua create mode 100644 nvim/lua/plugins/code-snippets.lua create mode 100644 nvim/lua/plugins/dashboard.lua create mode 100644 nvim/lua/plugins/debugging.lua create mode 100644 nvim/lua/plugins/editor-bar.lua create mode 100644 nvim/lua/plugins/file-tree.lua create mode 100644 nvim/lua/plugins/git.lua create mode 100644 nvim/lua/plugins/search.lua create mode 100644 nvim/lua/plugins/theme.lua create mode 100644 nvim/lua/vim-config/editor.lua create mode 100644 nvim/lua/vim-config/init.lua create mode 100644 nvim/lua/vim-config/keymap.lua diff --git a/.gitignore b/.gitignore index cd423b9..1d1a808 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ !.gitignore # Include NVim -!nvim +!/nvim/**/* diff --git a/nvim/.luarc.json b/nvim/.luarc.json new file mode 100644 index 0000000..c7da2db --- /dev/null +++ b/nvim/.luarc.json @@ -0,0 +1,5 @@ +{ + "diagnostics.globals": [ + "vim" + ] +} diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..5700b24 --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1 @@ +require('core') diff --git a/nvim/lua/core/init.lua b/nvim/lua/core/init.lua new file mode 100644 index 0000000..8c76d3a --- /dev/null +++ b/nvim/lua/core/init.lua @@ -0,0 +1,2 @@ +require("vim-config") +require("core.packagemanager") diff --git a/nvim/lua/core/packagemanager.lua b/nvim/lua/core/packagemanager.lua new file mode 100644 index 0000000..240c263 --- /dev/null +++ b/nvim/lua/core/packagemanager.lua @@ -0,0 +1,15 @@ +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) + +local opts = {} +require("lazy").setup("plugins", opts) diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/nvim/lua/plugins.lua @@ -0,0 +1 @@ +return {} diff --git a/nvim/lua/plugins/code-autobrackets.lua b/nvim/lua/plugins/code-autobrackets.lua new file mode 100644 index 0000000..b4f8e9a --- /dev/null +++ b/nvim/lua/plugins/code-autobrackets.lua @@ -0,0 +1,6 @@ +return { + 'm4xshen/autoclose.nvim', + config = function () + require("autoclose").setup() + end +} diff --git a/nvim/lua/plugins/code-highliting.lua b/nvim/lua/plugins/code-highliting.lua new file mode 100644 index 0000000..f24305b --- /dev/null +++ b/nvim/lua/plugins/code-highliting.lua @@ -0,0 +1,13 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + -- Setup -- + local config = require("nvim-treesitter.configs") + config.setup({ + auto_install = true, + highlight = { enable = true }, + indent = { enable = true }, + }) + end +} diff --git a/nvim/lua/plugins/code-lsp-extra.lua b/nvim/lua/plugins/code-lsp-extra.lua new file mode 100644 index 0000000..f0bcc0d --- /dev/null +++ b/nvim/lua/plugins/code-lsp-extra.lua @@ -0,0 +1,40 @@ +return { + "nvimtools/none-ls.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + }, + config = function() + -- Setup -- + local null_ls = require("null-ls") + null_ls.setup({ + sources = { + -- Prettier -- + null_ls.builtins.formatting.prettier, + + -- Php -- + null_ls.builtins.diagnostics.phpstan, + null_ls.builtins.formatting.phpcsfixer.with({ + prefer_local = "vendor/bin/php-cs-fixer", + args = {"fix", "--allow-risky=yes", "$FILENAME"} + }), + + -- Twig -- + null_ls.builtins.diagnostics.twigcs, + + -- JavaScript & Typescript + null_ls.builtins.formatting.eslint_d, + + -- Lua -- + null_ls.builtins.formatting.stylua, + + -- Go -- + null_ls.builtins.formatting.gofumpt, + null_ls.builtins.code_actions.gomodifytags, + null_ls.builtins.code_actions.impl + }, + }) + + -- Keybinding -- + vim.keymap.set("n", "gf", vim.lsp.buf.format, {}) + end, +} diff --git a/nvim/lua/plugins/code-lsp.lua b/nvim/lua/plugins/code-lsp.lua new file mode 100644 index 0000000..8e8544f --- /dev/null +++ b/nvim/lua/plugins/code-lsp.lua @@ -0,0 +1,162 @@ +return { + { + "williamboman/mason.nvim", + lazy = false, + config = function() + require("mason").setup() + end, + }, + { + "williamboman/mason-lspconfig.nvim", + lazy = false, + opts = { + auto_install = true, + }, + config = function() + require("mason-lspconfig").setup({ + ensure_installed = { + "lua_ls", + "bashls", + "dotls", + "jsonls", + "sqlls", + "lemminx", + "yamlls", + "marksman", + "html", + "emmet_ls", + "cssls", + "tailwindcss", + "tsserver", + "stimulus_ls", + "svelte", + "volar", + "eslint", + "phpactor", + "gopls", + "rust_analyzer", + "jdtls", + "kotlin_language_server", + "pylsp" + } + }) + end + }, + { + "neovim/nvim-lspconfig", + lazy = false, + config = function() + -- Setup -- + local capabilities = require('cmp_nvim_lsp').default_capabilities() + local lspconfig = require("lspconfig") + + -- Lua support -- + lspconfig.lua_ls.setup({ + capabilities = capabilities + }) + + -- Bash support -- + lspconfig.bashls.setup({ + capabilities = capabilities + }) + -- Dotenv support -- + lspconfig.dotls.setup({ + capabilities = capabilities + }) + + -- JSON support -- + lspconfig.jsonls.setup({ + capabilities = capabilities + }) + -- SQL support -- + lspconfig.sqlls.setup({ + capabilities = capabilities + }) + -- XML support -- + lspconfig.lemminx.setup({ + capabilities = capabilities + }) + -- YAML support -- + lspconfig.yamlls.setup({ + capabilities = capabilities + }) + + -- Markdown support -- + lspconfig.marksman.setup({ + capabilities = capabilities + }) + + -- HTML support -- + lspconfig.html.setup({ + capabilities = capabilities + }) + -- Emmet support -- + lspconfig.emmet_ls.setup({ + capabilities = capabilities + }) + -- PHP support -- + lspconfig.phpactor.setup({ + capabilities = capabilities + }) + -- CSS & SCSS support --$response + lspconfig.cssls.setup({ + capabilities = capabilities + }) + -- Tailwind support -- + lspconfig.tailwindcss.setup({ + capabilities = capabilities + }) + -- JavaScript & TypeScript support -- + lspconfig.tsserver.setup({ + capabilities = capabilities + }) + -- Stimulus support -- + lspconfig.stimulus_ls.setup({ + capabilities = capabilities + }) + -- Svelte support -- + lspconfig.svelte.setup({ + capabilities = capabilities + }) + -- Vue support -- + lspconfig.volar.setup({ + capabilities = capabilities + }) + + -- Go support -- + lspconfig.gopls.setup({ + capabilities = capabilities + }) + + -- Rust support -- + lspconfig.rust_analyzer.setup({ + capabilities = capabilities + }) + + -- Java support -- + lspconfig.jdtls.setup({ + capabilities = capabilities + }) + -- Kotlin support -- + lspconfig.kotlin_language_server.setup({ + capabilities = capabilities + }) + + -- Python support -- + lspconfig.pylsp.setup({ + capabilities = capabilities + }) + + -- Eslint support -- + lspconfig.eslint.setup({ + capabilities = capabilities + }) + + -- Keybinding -- + vim.keymap.set("n", "K", vim.lsp.buf.hover, {}) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, {}) + vim.keymap.set("n", "gr", vim.lsp.buf.references, {}) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, {}) + end + } +} diff --git a/nvim/lua/plugins/code-snippets.lua b/nvim/lua/plugins/code-snippets.lua new file mode 100644 index 0000000..2e09e9b --- /dev/null +++ b/nvim/lua/plugins/code-snippets.lua @@ -0,0 +1,71 @@ +return { + { + "L3MON4D3/LuaSnip", + version = "2.*", + dependencies = { + "rafamadriz/friendly-snippets", + "mireq/luasnip-snippets", + }, + build = "make install_jsregexp", + config = function() + -- Setup -- + require("luasnip.loaders.from_vscode").lazy_load() + require("luasnip.loaders.from_snipmate").lazy_load() + + require("luasnip_snippets.common.snip_utils").setup() + end, + }, + { + "hrsh7th/nvim-cmp", + dependencies = { + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-nvim-lsp", + }, + config = function() + -- Setup -- + local cmp = require("cmp") + local luasnip = require("luasnip") + luasnip.setup({ + load_ft_func = require("luasnip_snippets.common.snip_utils").load_ft_func, + ft_func = require("luasnip_snippets.common.snip_utils").ft_func, + enable_autosnippets = true, + }) + -- Keybinding -- + vim.keymap.set({ "i", "s" }, "", function() + if luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + vim.api.nvim_input("") + end + end, { silent = true }) + vim.keymap.set({ "i", "s" }, "", function() + luasnip.jump(-1) + end, { silent = true }) + -- Setup -- + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + -- Keybinding -- + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + }, { { name = "buffer" } }), + }) + end, + }, +} diff --git a/nvim/lua/plugins/dashboard.lua b/nvim/lua/plugins/dashboard.lua new file mode 100644 index 0000000..06e9234 --- /dev/null +++ b/nvim/lua/plugins/dashboard.lua @@ -0,0 +1,32 @@ +return { + "goolord/alpha-nvim", + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + config = function() + -- Setup -- + local alpha = require("alpha") + local dashboard = require("alpha.themes.startify") + + -- Header -- + dashboard.section.header.val = { + [[ ]], + [[ ]], + [[ ]], + [[ ]], + [[  ]], + [[ ████ ██████ █████ ██ ]], + [[ ███████████ █████  ]], + [[ █████████ ███████████████████ ███ ███████████ ]], + [[ █████████ ███ █████████████ █████ ██████████████ ]], + [[ █████████ ██████████ █████████ █████ █████ ████ █████ ]], + [[ ███████████ ███ ███ █████████ █████ █████ ████ █████ ]], + [[ ██████ █████████████████████ ████ █████ █████ ████ ██████ ]], + [[ ]], + [[ ]], + [[ ]], + } + + alpha.setup(dashboard.opts) + end, +} diff --git a/nvim/lua/plugins/debugging.lua b/nvim/lua/plugins/debugging.lua new file mode 100644 index 0000000..e01c7d7 --- /dev/null +++ b/nvim/lua/plugins/debugging.lua @@ -0,0 +1,29 @@ +return { + "mfussenegger/nvim-dap", + dependencies = { + "rcarriga/nvim-dap-ui", + }, + config = function() + -- Setup -- + local dap = require("dap") + local dapui = require("dapui").setup() + dap.listeners.before.attach.dapui_config = function() + dapui.open() + end + dap.listeners.before.launch.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 + + -- Keybinding -- + vim.keymap.set("n", "dt", ":DapToggleBreakpoint") + vim.keymap.set("n", "dc", ":DapContinue") + vim.keymap.set("n", "dx", ":DapTerminate") + vim.keymap.set("n", "do", ":DapStepOver") + end, +} diff --git a/nvim/lua/plugins/editor-bar.lua b/nvim/lua/plugins/editor-bar.lua new file mode 100644 index 0000000..399fa10 --- /dev/null +++ b/nvim/lua/plugins/editor-bar.lua @@ -0,0 +1,60 @@ +return { + { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + -- Setup -- + require("lualine").setup({ + options = { + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = { + "neo-tree", + "fugitive", + "help", + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch", "diff", "diagnostics" }, + lualine_x = { "location" }, + lualine_y = { "encoding" }, + lualine_z = { "filetype" }, + }, + inactive_sections = { + lualine_a = { "mode" }, + lualine_b = { "branch", "diff", "diagnostics" }, + lualine_x = { "location" }, + lualine_y = { "encoding" }, + lualine_z = { "filetype" }, + }, + tabline = {}, + winbar = { + lualine_a = { "filename" }, + }, + inactive_winbar = { + lualine_a = { "filename" }, + }, + extensions = {}, + }) + end, + }, + { + "romgrk/barbar.nvim", + dependencies = { + "lewis6991/gitsigns.nvim", + "nvim-tree/nvim-web-devicons", + }, + config = function() + require("barbar").setup() + end, + }, +} diff --git a/nvim/lua/plugins/file-tree.lua b/nvim/lua/plugins/file-tree.lua new file mode 100644 index 0000000..9718069 --- /dev/null +++ b/nvim/lua/plugins/file-tree.lua @@ -0,0 +1,61 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + config = function() + -- Setup -- + require("neo-tree").setup({ + close_if_last_window = false, + enable_git_status = true, + enable_diagnostics = true, + name = { + trailing_slash = false, + use_git_status_colors = true, + highlight = "NeoTreeFileName", + }, + git_status = { + symbols = { + -- Git Change type Icon -- + added = "✚", + modified = "", + deleted = "✖", + renamed = "󰁕", + -- Git Status type Icon -- + untracked = "", + ignored = "", + unstaged = "󰄱", + staged = "", + conflict = "", + } + }, + symlink_target = { + enabled = false, + }, + filesystem = { + hijack_netrw_behavior = "open_default" + } + }) + + -- Dignostic Icons -- + vim.fn.sign_define("DiagnosticSignError", { + text = " ", texthl = "DiagnosticSignError" + }) + vim.fn.sign_define("DiagnosticSignWarn", { + text = " ", texthl = "DiagnosticSignWarn" + }) + vim.fn.sign_define("DiagnosticSignInfo", { + text = " ", texthl = "DiagnosticSignInfo" + }) + vim.fn.sign_define("DiagnosticSignHint", { + text = "󰌵", texthl = "DiagnosticSignHint" + }) + + -- Keybinding -- + vim.keymap.set("n", "", ":Neotree filesystem reveal left", {}) + vim.keymap.set("n", "bf", ":Neotree buffers reveal float", {}) + end, +} diff --git a/nvim/lua/plugins/git.lua b/nvim/lua/plugins/git.lua new file mode 100644 index 0000000..1516e51 --- /dev/null +++ b/nvim/lua/plugins/git.lua @@ -0,0 +1,17 @@ +return { + { + "tpope/vim-fugitive", + }, + { + "lewis6991/gitsigns.nvim", + config = function() + -- Setup -- + require("gitsigns").setup() + + -- Keybinding -- + vim.keymap.set("n", "gh", ":Gitsigns preview_hunk_inline", {}) + vim.keymap.set("n", "gb", ":Gitsigns toggle_current_line_blame", {}) + vim.keymap.set("n", "go", ":Git ", {}) + end, + }, +} diff --git a/nvim/lua/plugins/search.lua b/nvim/lua/plugins/search.lua new file mode 100644 index 0000000..2440a59 --- /dev/null +++ b/nvim/lua/plugins/search.lua @@ -0,0 +1,24 @@ +return { + "nvim-telescope/telescope.nvim", + tag = "0.1.5", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope-ui-select.nvim" + }, + config = function() + -- Setup -- + require("telescope").setup({ + extensions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown({}), + }, + }, + }) + require("telescope").load_extension("ui-select") + + -- Keybinding -- + local builtin = require("telescope.builtin") + vim.keymap.set("n", "", builtin.find_files, {}) + vim.keymap.set("n", "fg", builtin.live_grep, {}) + end +} diff --git a/nvim/lua/plugins/theme.lua b/nvim/lua/plugins/theme.lua new file mode 100644 index 0000000..6e00f05 --- /dev/null +++ b/nvim/lua/plugins/theme.lua @@ -0,0 +1,9 @@ +return { + "catppuccin/nvim", + name = "catppuccin", + priority = 1000, + config = function() + -- Set Theme -- + vim.cmd("colorscheme catppuccin") + end +} diff --git a/nvim/lua/vim-config/editor.lua b/nvim/lua/vim-config/editor.lua new file mode 100644 index 0000000..869206d --- /dev/null +++ b/nvim/lua/vim-config/editor.lua @@ -0,0 +1,8 @@ +-- Use 2 Spaces Instead of Tabs -- +vim.cmd("set expandtab") +vim.cmd("set tabstop=1") +vim.cmd("set softtabstop=2") +vim.cmd("set shiftwidth=2") + +-- Enable Line Number -- +vim.cmd("set number") diff --git a/nvim/lua/vim-config/init.lua b/nvim/lua/vim-config/init.lua new file mode 100644 index 0000000..7602657 --- /dev/null +++ b/nvim/lua/vim-config/init.lua @@ -0,0 +1,2 @@ +require("vim-config.editor") +require("vim-config.keymap") diff --git a/nvim/lua/vim-config/keymap.lua b/nvim/lua/vim-config/keymap.lua new file mode 100644 index 0000000..4ba8861 --- /dev/null +++ b/nvim/lua/vim-config/keymap.lua @@ -0,0 +1,3 @@ +vim.g.mapleader = " " +vim.keymap.set("n", "", ">>") +vim.keymap.set("n", "", "<<")