From ac3b5408fc65a9feb2a2c012e33f28114fb8bf4b Mon Sep 17 00:00:00 2001 From: Johannes Merz Date: Fri, 22 Mar 2024 15:06:26 +0100 Subject: [PATCH] small changes; added plantuml --- nvim/.config/nvim/lazy-lock.json | 5 + nvim/.config/nvim/lua/joe/core/options.lua | 7 +- nvim/.config/nvim/lua/joe/lazy.lua | 30 ++-- nvim/.config/nvim/lua/joe/plugins/init.lua | 2 +- .../nvim/lua/joe/plugins/lsp/lspconfig.lua | 161 ++++++++++++++++++ .../.config/nvim/lua/joe/plugins/plantuml.lua | 15 ++ 6 files changed, 205 insertions(+), 15 deletions(-) create mode 100644 nvim/.config/nvim/lua/joe/plugins/lsp/lspconfig.lua create mode 100644 nvim/.config/nvim/lua/joe/plugins/plantuml.lua diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 7396c44..1f007fa 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -4,6 +4,7 @@ "alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" }, "bufferline.nvim": { "branch": "main", "commit": "64e2c5def50dfd6b6f14d96a45fa3d815a4a1eef" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "conform.nvim": { "branch": "master", "commit": "bf109f061fc3cd75394b7823923187ae045cbf22" }, @@ -17,6 +18,8 @@ "nvim-autopairs": { "branch": "master", "commit": "dbfc1c34bed415906395db8303c71039b3a3ffb4" }, "nvim-cmp": { "branch": "main", "commit": "630cdf7d547c4461ef6d7362c3794a08abfad4fb" }, "nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" }, + "nvim-lsp-file-operations": { "branch": "master", "commit": "223aca86b737dc66e9c51ebcda8788a8d9cc6cf2" }, + "nvim-lspconfig": { "branch": "master", "commit": "24662f92c18edd397ef12d635b11dbdedef2d094" }, "nvim-surround": { "branch": "main", "commit": "d47001f8ddf9646c24f16d2732d4d0255acd2121" }, "nvim-tree.lua": { "branch": "master", "commit": "f7c09bd72e50e1795bd3afb9e2a2b157b4bfb3c3" }, "nvim-treesitter": { "branch": "master", "commit": "6e7b41106e9b15a5b47d149378d53482c9d9c7a3" }, @@ -24,8 +27,10 @@ "nvim-ts-autotag": { "branch": "main", "commit": "531f48334c422222aebc888fd36e7d109cb354cd" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "7ab799a9792f7cf3883cf28c6a00ad431f3d382a" }, "nvim-web-devicons": { "branch": "master", "commit": "cb0c967c9723a76ccb1be0cc3a9a10e577d2f6ec" }, + "plantuml.nvim": { "branch": "master", "commit": "d7acbf9899945cc8fad2f068127c3a9f3b51db22" }, "plenary.nvim": { "branch": "master", "commit": "f7adfc4b3f4f91aab6caebf42b3682945fbc35be" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, "telescope.nvim": { "branch": "0.1.x", "commit": "6312868392331c9c0f22725041f1ec2bef57c751" }, + "vim-polyglot": { "branch": "master", "commit": "bc8a81d3592dab86334f27d1d43c080ebf680d42" }, "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } } \ No newline at end of file diff --git a/nvim/.config/nvim/lua/joe/core/options.lua b/nvim/.config/nvim/lua/joe/core/options.lua index ddd0a54..98f96e1 100644 --- a/nvim/.config/nvim/lua/joe/core/options.lua +++ b/nvim/.config/nvim/lua/joe/core/options.lua @@ -1,8 +1,9 @@ local opt = vim.opt -- for conciseness -- line numbers -opt.relativenumber = true -- show relative line numbers -opt.number = true -- shows absolute line number on cursor line (when relative number is on) +-- opt.relativenumber = true -- show relative line numbers +-- opt.number = true -- shows absolute line number on cursor line (when relative number is on) +opt.number = true -- tabs & indentation opt.tabstop = 2 -- 2 spaces for tabs (prettier default) @@ -42,4 +43,4 @@ opt.splitbelow = true -- split horizontal window to the bottom opt.swapfile = false -- turn of mouse -opt.mouse="" +opt.mouse = "" diff --git a/nvim/.config/nvim/lua/joe/lazy.lua b/nvim/.config/nvim/lua/joe/lazy.lua index 16f1dd0..a30974c 100644 --- a/nvim/.config/nvim/lua/joe/lazy.lua +++ b/nvim/.config/nvim/lua/joe/lazy.lua @@ -1,16 +1,24 @@ 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, - }) + 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) -require("lazy").setup('joe.plugins') - - +require("lazy").setup({ + { import = "joe.plugins" }, + { import = "joe.plugins.lsp" }, + checker = { + enabled = true, + -- notify = false, + }, + change_detection = { + -- notify = false + }, +}) diff --git a/nvim/.config/nvim/lua/joe/plugins/init.lua b/nvim/.config/nvim/lua/joe/plugins/init.lua index 5c8e41c..a81bdef 100644 --- a/nvim/.config/nvim/lua/joe/plugins/init.lua +++ b/nvim/.config/nvim/lua/joe/plugins/init.lua @@ -1,4 +1,4 @@ -- addons without configuration return { - + "sheerun/vim-polyglot", } diff --git a/nvim/.config/nvim/lua/joe/plugins/lsp/lspconfig.lua b/nvim/.config/nvim/lua/joe/plugins/lsp/lspconfig.lua new file mode 100644 index 0000000..269867f --- /dev/null +++ b/nvim/.config/nvim/lua/joe/plugins/lsp/lspconfig.lua @@ -0,0 +1,161 @@ +return { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "hrsh7th/cmp-nvim-lsp", + { "antosha417/nvim-lsp-file-operations", config = true }, + }, + config = function() + -- import lspconfig plugin + local lspconfig = require("lspconfig") + + -- import cmp-nvim-lsp plugin + local cmp_nvim_lsp = require("cmp_nvim_lsp") + + local keymap = vim.keymap -- for conciseness + + local opts = { noremap = true, silent = true } + local on_attach = function(client, bufnr) + opts.busfer = bufnr + + -- set keybinds + opts.desc = "Show LSP references" + keymap.set("n", "gR", "Telescope lsp_references", opts) -- show definition, references + + opts.desc = "Go to declaration" + keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration + + opts.desk = "Show LSP definitions" + keymap.set("n", "gd", "Telescope lsp_definitions", opts) -- show lsp definitions + + opts.desc = "Show LSP implementations" + keymap.set("n", "gi", "Telescope lsp_implementations", opts) -- show lsp implementations + + opts.desc = "Show LSP type definitions" + keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) -- show lsp type definitions + + opts.desc = "See available code actions" + keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection + + opts.desc = "Smart rename" + keymap.set("n", "rn", vim.lsp.buf.rename, opts) -- smart rename + + opts.desc = "Show buffer diagnostics" + keymap.set("n", "D", "Telescope diagnostics bufnr=0", opts) -- show diagnostics for file + + opts.desc = "Show line diagnostics" + keymap.set("n", "d", vim.diagnostic.open_float, opts) -- show diagnostics for line + + opts.desc = "Go to previous diagnostic" + keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer + + opts.desc = "Go to next diagnostic" + keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer + + opts.desc = "Show documentation for what is under cursor" + keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor + + opts.desc = "Restart LSP" + keymap.set("n", "rs", ":LspRestart", opts) -- mapping to restart lsp if necessary + end + + -- used to enable autocompletion (assign to every lsp server config) + local capabilities = cmp_nvim_lsp.default_capabilities() + + -- Change the Diagnostic symbols in the sign column (gutter) + -- (not in youtube nvim video) + local signs = { Error = " ", Warn = " ", Hint = "󰠠 ", Info = " " } + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) + end + + -- configure html server + lspconfig["html"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure typescript server with plugin + lspconfig["tsserver"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure css server + lspconfig["cssls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure tailwindcss server + lspconfig["tailwindcss"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure svelte server + lspconfig["svelte"].setup({ + capabilities = capabilities, + on_attach = function(client, bufnr) + on_attach(client, bufnr) + + vim.api.nvim_create_autocmd("BufWritePost", { + pattern = { "*.js", "*.ts" }, + callback = function(ctx) + if client.name == "svelte" then + client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.file }) + end + end, + }) + end, + }) + + -- configure prisma orm server + lspconfig["prismals"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure graphql language server + lspconfig["graphql"].setup({ + capabilities = capabilities, + on_attach = on_attach, + filetypes = { "graphql", "gql", "svelte", "typescriptreact", "javascriptreact" }, + }) + + -- configure emmet language server + lspconfig["emmet_ls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" }, + }) + + -- configure python server + lspconfig["pyright"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure lua server (with special settings) + lspconfig["lua_ls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + settings = { -- custom settings for lua + Lua = { + -- make the language server recognize "vim" global + diagnostics = { + globals = { "vim" }, + }, + workspace = { + -- make language server aware of runtime files + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + }, + }, + }) + end, +} diff --git a/nvim/.config/nvim/lua/joe/plugins/plantuml.lua b/nvim/.config/nvim/lua/joe/plugins/plantuml.lua new file mode 100644 index 0000000..050b0af --- /dev/null +++ b/nvim/.config/nvim/lua/joe/plugins/plantuml.lua @@ -0,0 +1,15 @@ +return { + "https://gitlab.com/itaranto/plantuml.nvim", + config = function() + local puml = require("plantuml") + puml.setup({ + renderer = { + type = "text", + options = { + split_cmd = "vsplit", -- Allowed values: `split`, `vsplit`. + }, + }, + render_on_write = true, -- Set to false to disable auto-rendering. + }) + end, +}