From ee00d818be98a0d36204080b28ba72ffef65e78b Mon Sep 17 00:00:00 2001 From: Nicolai VdS Date: Mon, 25 Nov 2024 15:27:51 +0100 Subject: [PATCH] added lsp, formatter debugger etc --- .config/nvim/.luarc.json | 5 +++ .config/nvim/init.lua | 19 +++++----- .config/nvim/lazy-lock.json | 15 ++++++++ .config/nvim/lua/plugins/alpha.lua | 31 +++++++++++++++++ .config/nvim/lua/plugins/catpuccin.lua | 10 +++--- .config/nvim/lua/plugins/completions.lua | 44 ++++++++++++++++++++++++ .config/nvim/lua/plugins/debugging.lua | 26 ++++++++++++++ .config/nvim/lua/plugins/lsp-config.lua | 39 +++++++++++++++++++++ .config/nvim/lua/plugins/lualine.lua | 15 ++++---- .config/nvim/lua/plugins/neo-tree.lua | 15 ++++---- .config/nvim/lua/plugins/none-ls.lua | 19 ++++++++++ .config/nvim/lua/plugins/telescope.lua | 33 +++++++++++++----- .config/nvim/lua/plugins/treesitter.lua | 14 ++++---- .config/nvim/lua/vim-options.lua | 13 ++++--- 14 files changed, 246 insertions(+), 52 deletions(-) create mode 100644 .config/nvim/.luarc.json create mode 100644 .config/nvim/lua/plugins/alpha.lua create mode 100644 .config/nvim/lua/plugins/completions.lua create mode 100644 .config/nvim/lua/plugins/debugging.lua create mode 100644 .config/nvim/lua/plugins/lsp-config.lua create mode 100644 .config/nvim/lua/plugins/none-ls.lua diff --git a/.config/nvim/.luarc.json b/.config/nvim/.luarc.json new file mode 100644 index 0000000..1e1765c --- /dev/null +++ b/.config/nvim/.luarc.json @@ -0,0 +1,5 @@ +{ + "diagnostics.globals": [ + "vim" + ] +} \ No newline at end of file diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 38bb513..f52ebf2 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,18 +1,15 @@ -local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then vim.fn.system({ - 'git', - 'clone', - '--filter=blob:none', - 'https://github.com/folke/lazy.nvim.git', - '--branch=stable', + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", lazypath, }) end vim.opt.rtp:prepend(lazypath) -require('vim-options') -require('lazy').setup('plugins') - - - +require("vim-options") +require("lazy").setup("plugins") diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index dbe7471..b116a1c 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,11 +1,26 @@ { + "LuaSnip": { "branch": "master", "commit": "0f7bbce41ea152a94d12aea286f2ce98e63c0f58" }, + "alpha-nvim": { "branch": "main", "commit": "de72250e054e5e691b9736ee30db72c65d560771" }, "catppuccin": { "branch": "main", "commit": "faf15ab0201b564b6368ffa47b56feefc92ce3f4" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, "lazy.nvim": { "branch": "main", "commit": "56ead98e05bb37a4ec28930a54d836d033cf00f2" }, "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "43894adcf10bb1190c2184bd7c1750e8ea2b3dce" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" }, + "none-ls-extras.nvim": { "branch": "main", "commit": "f50d4dece9f91813f049f8100d188933f7d654d9" }, + "none-ls.nvim": { "branch": "main", "commit": "1f2bf17eddfdd45aed254b6922c6c68b933dba9e" }, "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, + "nvim-cmp": { "branch": "main", "commit": "ed31156aa2cc14e3bc066c59357cc91536a2bc01" }, + "nvim-dap": { "branch": "master", "commit": "cc92b054720a96170eca6bd9bdedd43d2b0a7a8a" }, + "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, + "nvim-lspconfig": { "branch": "master", "commit": "dafd61d6533bd90ecf6e2a3a972298fdddc74d82" }, + "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-treesitter": { "branch": "master", "commit": "d14bc4bd15a7b9b5a9e7977c6a28f2cab6c4ad4a" }, "nvim-web-devicons": { "branch": "master", "commit": "edbe0a65cfacbbfff6a4a1e98ddd60c28c560509" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" } } diff --git a/.config/nvim/lua/plugins/alpha.lua b/.config/nvim/lua/plugins/alpha.lua new file mode 100644 index 0000000..2c85231 --- /dev/null +++ b/.config/nvim/lua/plugins/alpha.lua @@ -0,0 +1,31 @@ +return { + "goolord/alpha-nvim", + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + + config = function() + local alpha = require("alpha") + local dashboard = require("alpha.themes.startify") + + dashboard.section.header.val = { + [[ ]], + [[ ]], + [[ ]], + [[ ]], + [[  ]], + [[ ████ ██████ █████ ██ ]], + [[ ███████████ █████  ]], + [[ █████████ ███████████████████ ███ ███████████ ]], + [[ █████████ ███ █████████████ █████ ██████████████ ]], + [[ █████████ ██████████ █████████ █████ █████ ████ █████ ]], + [[ ███████████ ███ ███ █████████ █████ █████ ████ █████ ]], + [[ ██████ █████████████████████ ████ █████ █████ ████ ██████ ]], + [[ ]], + [[ ]], + [[ ]], + } + + alpha.setup(dashboard.opts) + end, +} diff --git a/.config/nvim/lua/plugins/catpuccin.lua b/.config/nvim/lua/plugins/catpuccin.lua index 9a41f32..249efad 100644 --- a/.config/nvim/lua/plugins/catpuccin.lua +++ b/.config/nvim/lua/plugins/catpuccin.lua @@ -1,9 +1,9 @@ -return { - 'catppuccin/nvim', +return { + "catppuccin/nvim", lazy = false, - name = 'catppuccin', + name = "catppuccin", priority = 1000, config = function() - vim.cmd.colorscheme 'catppuccin' - end + vim.cmd.colorscheme("catppuccin") + end, } diff --git a/.config/nvim/lua/plugins/completions.lua b/.config/nvim/lua/plugins/completions.lua new file mode 100644 index 0000000..d429fb5 --- /dev/null +++ b/.config/nvim/lua/plugins/completions.lua @@ -0,0 +1,44 @@ +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({ + [""] = 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/.config/nvim/lua/plugins/debugging.lua b/.config/nvim/lua/plugins/debugging.lua new file mode 100644 index 0000000..8b73ea0 --- /dev/null +++ b/.config/nvim/lua/plugins/debugging.lua @@ -0,0 +1,26 @@ +return { + "mfussenegger/nvim-dap", + dependencies = { + "rcarriga/nvim-dap-ui", + "nvim-neotest/nvim-nio", + }, + config = function() + local dap, dapui = require("dap"), require("dapui") + + 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 + + vim.keymap.set("n", "dt", dap.toggle_breakpoint, {}) + vim.keymap.set("n", "dc", dap.continue, {}) + end, +} diff --git a/.config/nvim/lua/plugins/lsp-config.lua b/.config/nvim/lua/plugins/lsp-config.lua new file mode 100644 index 0000000..a05421d --- /dev/null +++ b/.config/nvim/lua/plugins/lsp-config.lua @@ -0,0 +1,39 @@ +return { + { + "williamboman/mason.nvim", + lazy = false, + config = function() + require("mason").setup() + end, + }, + { + "williamboman/mason-lspconfig.nvim", + lazy = false, + opts = { + auto_install = true, + }, + }, + { + "neovim/nvim-lspconfig", + lazy = false, + config = function() + local capabilities = require("cmp_nvim_lsp").default_capabilities() + + local lspconfig = require("lspconfig") + lspconfig.lua_ls.setup({ + capabilities = capabilities, + }) + lspconfig.ts_ls.setup({ + capabilities = capabilities + }) + lspconfig.rust_analyzer.setup({ + capabilities = capabilities + }) + + 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/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua index ff1ed55..456311b 100644 --- a/.config/nvim/lua/plugins/lualine.lua +++ b/.config/nvim/lua/plugins/lualine.lua @@ -1,14 +1,13 @@ return { - 'nvim-lualine/lualine.nvim', - dependencies = { 'nvim-tree/nvim-web-devicons' }, + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, event = "VeryLazy", opts = { options = { icons_enabled = true, - theme = 'auto', - component_seperator = '|', - section_separators = { left = '', right = '' }, - } - } + theme = "auto", + component_seperator = "|", + section_separators = { left = "", right = "" }, + }, + }, } - diff --git a/.config/nvim/lua/plugins/neo-tree.lua b/.config/nvim/lua/plugins/neo-tree.lua index efdbfde..06b6545 100644 --- a/.config/nvim/lua/plugins/neo-tree.lua +++ b/.config/nvim/lua/plugins/neo-tree.lua @@ -1,13 +1,12 @@ return { - 'nvim-neo-tree/neo-tree.nvim', - branch = 'v3.x', + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-tree/nvim-web-devicons', - 'MunifTanjim/nui.nvim', + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", }, config = function() - vim.keymap.set('n', '', ':Neotree filesystem reveal left', {}) - end + vim.keymap.set("n", "", ":Neotree filesystem reveal left", {}) + end, } - diff --git a/.config/nvim/lua/plugins/none-ls.lua b/.config/nvim/lua/plugins/none-ls.lua new file mode 100644 index 0000000..f88fc61 --- /dev/null +++ b/.config/nvim/lua/plugins/none-ls.lua @@ -0,0 +1,19 @@ +return { + "nvimtools/none-ls.nvim", + dependencies = { + "nvimtools/none-ls-extras.nvim" + }, + config = function() + local null_ls = require("null-ls") + + null_ls.setup({ + sources = { + null_ls.builtins.formatting.stylua, + null_ls.builtins.formatting.prettier, + require("none-ls.diagnostics.eslint"), + }, + }) + + vim.keymap.set("n", "gf", vim.lsp.buf.format, {}) + end, +} diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index f868dd2..abe434d 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -1,9 +1,26 @@ -b { - 'nvim-telescope/telescope.nvim', tag = '0.1.5', - dependencies = { 'nvim-lua/plenary.nvim' }, - config = function() - local builtin = require('telescope.builtin') - vim.keymap.set('n', '', builtin.find_files, {}) - vim.keymap.set('n', 'fg', builtin.live_grep, {}) -- ripgrep is needed for this to work - end +return { + { + "nvim-telescope/telescope.nvim", + tag = "0.1.5", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local builtin = require("telescope.builtin") + vim.keymap.set("n", "", builtin.find_files, {}) + vim.keymap.set("n", "fg", builtin.live_grep, {}) -- ripgrep is needed for this to work + end, + }, + { + "nvim-telescope/telescope-ui-select.nvim", + config = function() + require("telescope").setup({ + extentsions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown({}), + }, + }, + }) + + require("telescope").load_extension("ui-select") + end, + }, } diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index b065fe6..ad374de 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -1,12 +1,12 @@ -return { - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", config = function() - local config = require('nvim-treesitter.configs') + local config = require("nvim-treesitter.configs") config.setup({ - ensure_installed = { 'lua', 'javascript', 'typescript', 'rust' }, + auto_install = true, highlight = { enable = true }, - indent = { enable = true } + indent = { enable = true }, }) - end + end, } diff --git a/.config/nvim/lua/vim-options.lua b/.config/nvim/lua/vim-options.lua index 47d4058..5280020 100644 --- a/.config/nvim/lua/vim-options.lua +++ b/.config/nvim/lua/vim-options.lua @@ -1,7 +1,10 @@ -vim.cmd('set expandtab') -vim.cmd('set tabstop=2') -vim.cmd('set softtabstop=2') -vim.cmd('set shiftwidth=2') -vim.g.mapleader = ' ' +vim.cmd("set expandtab") +vim.cmd("set tabstop=2") +vim.cmd("set softtabstop=2") +vim.cmd("set shiftwidth=2") +vim.g.mapleader = " " +vim.g.backgrounf = "light" +vim.opt.swapfile = false +vim.wo.number = true