From 798b56bc4ff82638d425657d247c11656fb5c430 Mon Sep 17 00:00:00 2001 From: Max Richter Date: Sat, 14 Jan 2023 03:02:20 +0100 Subject: [PATCH] feat: update config --- configs/.zshrc | 3 +- configs/nvim/.luarc.json | 4 + configs/nvim/init.lua | 1 + configs/nvim/lazy-lock.json | 59 +-- configs/nvim/lua/max/configs/autocomplete.lua | 168 ++++---- configs/nvim/lua/max/configs/lsp.lua | 406 ++++++++---------- configs/nvim/lua/max/configs/treesitter.lua | 3 + configs/nvim/lua/max/core/autocommands.lua | 18 +- configs/nvim/lua/max/core/keymappings.lua | 12 +- configs/nvim/lua/max/core/options.lua | 4 +- configs/nvim/lua/max/core/plugins.lua | 101 ++--- configs/nvim/lua/max/theme/icons.lua | 59 +++ 12 files changed, 452 insertions(+), 386 deletions(-) create mode 100644 configs/nvim/lua/max/theme/icons.lua diff --git a/configs/.zshrc b/configs/.zshrc index 5a173d8..083f750 100644 --- a/configs/.zshrc +++ b/configs/.zshrc @@ -1,5 +1,5 @@ # Update Repo -source $HOME/.dotfiles/configs/zsh/update-repo.zsh +# source $HOME/.dotfiles/configs/zsh/update-repo.zsh # p10k if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then @@ -37,6 +37,7 @@ plugins=( asdf tmux nx-completion + you-should-use sudo zsh-autosuggestions ) diff --git a/configs/nvim/.luarc.json b/configs/nvim/.luarc.json index e1b9d70..a5e7370 100644 --- a/configs/nvim/.luarc.json +++ b/configs/nvim/.luarc.json @@ -1,4 +1,8 @@ { "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", + "Lua.diagnostics.globals": [ + "vim", + "require" + ], "Lua.workspace.checkThirdParty": false } \ No newline at end of file diff --git a/configs/nvim/init.lua b/configs/nvim/init.lua index 3200980..5cdb2c9 100644 --- a/configs/nvim/init.lua +++ b/configs/nvim/init.lua @@ -4,6 +4,7 @@ require("max.core.bootstrap") require("max.core.plugins") + require("max.core.autocommands") require("max.core.keymappings") diff --git a/configs/nvim/lazy-lock.json b/configs/nvim/lazy-lock.json index eee8e21..e4d70f5 100644 --- a/configs/nvim/lazy-lock.json +++ b/configs/nvim/lazy-lock.json @@ -4,65 +4,68 @@ "FixCursorHold.nvim": { "branch": "master", "commit": "70a9516a64668cbfe59f31b66d0a21678c5e9b12" }, "LuaSnip": { "branch": "master", "commit": "5d57303efde86fcb0959c52b1a6d40f923940f34" }, "alpha-nvim": { "branch": "main", "commit": "21a0f2520ad3a7c32c0822f943368dc063a569fb" }, - "autolist.nvim": { "branch": "main", "commit": "71b89ac9f7dd9739f4b477f59301d807d5f3a347" }, + "autolist.nvim": { "branch": "main", "commit": "f8b4c11b79b0fef77a64b03810839a1abbbc67d5" }, "boole.nvim": { "branch": "main", "commit": "23a799a60a0f56640a24d9fc20cf35ed958549ee" }, - "catppuccin": { "branch": "main", "commit": "3020af75aae098a77737d91ee37c7147c8450d99" }, + "bufferline.nvim": { "branch": "main", "commit": "c7492a76ce8218e3335f027af44930576b561013" }, + "catppuccin": { "branch": "main", "commit": "ecfa842c38b937596c81fa8df2123de69b980081" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-emoji": { "branch": "main", "commit": "19075c36d5820253d32e2478b6aaf3734aeaafa0" }, "cmp-nvim-lsp": { "branch": "main", "commit": "59224771f91b86d1de12570b4070fe4ad7cd1eeb" }, "cmp-nvim-lua": { "branch": "main", "commit": "f3491638d123cfd2c8048aefaf66d246ff250ca6" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "copilot-cmp": { "branch": "master", "commit": "b732a58ac8b7287b981cd9f0d9c0f61e5e9d5760" }, + "copilot.lua": { "branch": "master", "commit": "5b911f2d8ecccc684c13fdb8af4145cca19dc3cf" }, "dressing.nvim": { "branch": "master", "commit": "4436d6f41e2f6b8ada57588acd1a9f8b3d21453c" }, "editorconfig-vim": { "branch": "master", "commit": "30ddc057f71287c3ac2beca876e7ae6d5abe26a0" }, - "friendly-snippets": { "branch": "main", "commit": "484fb38b8f493ceeebf4e6fc499ebe41e10aae25" }, + "flit.nvim": { "branch": "main", "commit": "be110f9814a45788d10537fd59b3c76d956bb7ad" }, + "friendly-snippets": { "branch": "main", "commit": "45698b3d193fff404c3c9c30d25dc138a729d64b" }, "fwatch.nvim": { "branch": "main", "commit": "a691f7349dc66285cd75a1a698dd28bca45f2bf8" }, - "fzf": { "branch": "master", "commit": "e0f0984da7ecb0132a1744220d1d96c32583c0b8" }, + "fzf": { "branch": "master", "commit": "1c83b3969185393f0427463a39ef1523c273c16c" }, "git-conflict.nvim": { "branch": "main", "commit": "cbefa7075b67903ca27f6eefdc9c1bf0c4881017" }, - "gitsigns.nvim": { "branch": "main", "commit": "114362a85e51918ab2965181ffa31932c181f32f" }, - "lazy.nvim": { "branch": "main", "commit": "e6ee0fa6103e9514e85a96fc16902ad7f777b53f" }, + "gitsigns.nvim": { "branch": "main", "commit": "addd6e174a85fc1c4007ab0b65d77e6555b417bf" }, + "lazy.nvim": { "branch": "main", "commit": "666ed7bf73eb5895253c1155bd29270b066cbdac" }, "leap.nvim": { "branch": "main", "commit": "a968ab4250840dc879e805f918b4f3b892310a12" }, - "litee-calltree.nvim": { "branch": "main", "commit": "e2dffec35740032258fee3a3c7f30123226f2271" }, - "litee-symboltree.nvim": { "branch": "main", "commit": "488a660afcfd54644e6b755256907d3c7d8cf8d0" }, - "litee.nvim": { "branch": "main", "commit": "bf366a1414fd0f9401631ac8884f2f9fa4bf18d2" }, "lsp-format.nvim": { "branch": "master", "commit": "ca0df5c8544e51517209ea7b86ecc522c98d4f0a" }, - "lsp-zero.nvim": { "branch": "main", "commit": "b3d60f170a23ba52cfd56fd6f8ce70a38e853330" }, - "lsp_lines.nvim": { "branch": "main", "commit": "ec98b45c8280e5ef8c84028d4f38aa447276c002" }, "lspkind.nvim": { "branch": "master", "commit": "c68b3a003483cf382428a43035079f78474cd11e" }, - "lspsaga.nvim": { "branch": "main", "commit": "b7b4777369b441341b2dcd45c738ea4167c11c9e" }, + "lspsaga.nvim": { "branch": "main", "commit": "0817d11977a686d47a105c2634c05bc9a1f0537a" }, "lualine-lsp-progress": { "branch": "master", "commit": "56842d097245a08d77912edf5f2a69ba29f275d7" }, - "lualine.nvim": { "branch": "master", "commit": "d8c392dd75778d6258da4e7c55522e94ac389732" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "3751eb5c56c67b51e68a1f4a0da28ae74ab771c1" }, - "mason.nvim": { "branch": "main", "commit": "a4ebe1f14ba31242cd09f9e0709d5b1f9d2bcecb" }, + "lualine.nvim": { "branch": "master", "commit": "0050b308552e45f7128f399886c86afefc3eb988" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "43c7f402cb9822b61b5dc05bf0b385928df256a6" }, + "mason.nvim": { "branch": "main", "commit": "5ab101aa11849c2424d5b87726105daae8cb49e8" }, "neotest": { "branch": "master", "commit": "fee5ce9bdc3dff4706a29b012e75025ab376becb" }, "neotest-jest": { "branch": "main", "commit": "8b8926480865e56053681d0c56e3be0a3b5e716c" }, "neotest-vitest": { "branch": "main", "commit": "d6577b191e16c174bffbec1eadfcd65c22fdcc0d" }, - "no-neck-pain.nvim": { "branch": "main", "commit": "6df43aec515aa68d266172934f849d01a2a4b8fd" }, + "no-neck-pain.nvim": { "branch": "main", "commit": "6e7e2ec15b67ae61e93cc7c8e1cafbec7596cb0f" }, "nui.nvim": { "branch": "main", "commit": "257da38029d3859ed111804f9d4e95b0fa993a31" }, + "null-ls.nvim": { "branch": "main", "commit": "915558963709ea17c5aa246ca1c9786bfee6ddb4" }, + "nvim-autopairs": { "branch": "master", "commit": "f00eb3b766c370cb34fdabc29c760338ba9e4c6c" }, "nvim-cmp": { "branch": "main", "commit": "11a95792a5be0f5a40bab5fc5b670e5b1399a939" }, - "nvim-dap": { "branch": "master", "commit": "700a3c7d6fbe5b07bee74e9952b456120d355c47" }, - "nvim-dap-ui": { "branch": "master", "commit": "f2206de65ea39093e3f13992507fc985c17aa763" }, + "nvim-dap": { "branch": "master", "commit": "b8201fd104287e9c24f898f1f7f5202896eea203" }, + "nvim-dap-ui": { "branch": "master", "commit": "b80227ea56a48177786904f6322abc8b2dc0bc36" }, "nvim-dap-vscode-js": { "branch": "main", "commit": "e7c05495934a658c8aa10afd995dacd796f76091" }, - "nvim-lastplace": { "branch": "main", "commit": "ecced899435c6bcdd81becb5efc6d5751d0dc4c8" }, - "nvim-lspconfig": { "branch": "master", "commit": "7b98aadc6e85db4fc3af6c1ec22c4774d965506e" }, + "nvim-lspconfig": { "branch": "master", "commit": "ed88435764d8b00442e66d39ec3d9c360e560783" }, "nvim-notify": { "branch": "master", "commit": "b005821516f1f37801a73067afd1cef2dbc4dfe8" }, - "nvim-scrollbar": { "branch": "main", "commit": "6e704cdeb7114385b4b19f9dc4b8f0c442019edc" }, - "nvim-toggleterm.lua": { "branch": "main", "commit": "b02a1674bd0010d7982b056fd3df4f717ff8a57a" }, - "nvim-tree.lua": { "branch": "master", "commit": "677d54afee1dfa7a30eb9e16ab7d9d1affc6484b" }, - "nvim-treesitter": { "branch": "master", "commit": "5fb315df12a3091f241b0326aed0ec70381adbd8" }, + "nvim-scrollbar": { "branch": "main", "commit": "6a2065fbcd032075a06d2ab54508b69842bc4496" }, + "nvim-toggleterm.lua": { "branch": "main", "commit": "a54e6c471ce1cd8ef8357e34598a28a955297131" }, + "nvim-tree.lua": { "branch": "master", "commit": "3ce0a8e770f70a135ef969e0a640bd8d05baf42c" }, + "nvim-treesitter": { "branch": "master", "commit": "51d220e0bd8922caabcb3e5de936fc599a1bd210" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "a8c86f48c1030acee22b9e071e3c531de77bf253" }, - "nvim-ufo": { "branch": "main", "commit": "71a1bb367f3e6df402546a69ca4e64b567901c73" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "4a42b30376c1bd625ab5016c2079631d531d797a" }, + "nvim-ufo": { "branch": "main", "commit": "e3528c9b7ca20e9e0d69d588037f484257f0d652" }, "nvim-web-devicons": { "branch": "master", "commit": "6c38926351372ea87034dec26182b62c835ff3bc" }, "persisted.nvim": { "branch": "main", "commit": "558fc4b9f48e16008782240521cb72455d93b835" }, - "plenary.nvim": { "branch": "master", "commit": "9d81624fbcedd3dd43b38d7e13a1e7b3f873d8cd" }, + "plenary.nvim": { "branch": "master", "commit": "1c7e3e6b0f4dd5a174fcea9fda8a4d7de593b826" }, "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, "promise-async": { "branch": "main", "commit": "842dca33e6b1af7bedcefc72cffbc807d54dbfca" }, "sniprun": { "branch": "master", "commit": "79806dad094770a1563ac0227c9692f7592df744" }, - "telescope.nvim": { "branch": "master", "commit": "04af51dbfb17c2afa0b8d82b0e842e0638201ca9" }, + "symbols-outline.nvim": { "branch": "master", "commit": "6a3ed24c5631da7a5d418bced57c16b32af7747c" }, + "telescope.nvim": { "branch": "master", "commit": "1ba7278cf08da8048e7f589ef6b65a39fd3e4dbf" }, "translate.nvim": { "branch": "main", "commit": "7b2fd50c21ecfe536d572d62dcd3fa83acad3743" }, "trouble.nvim": { "branch": "main", "commit": "83ec606e7065adf134d17f4af6bae510e3c491c1" }, "undotree": { "branch": "master", "commit": "1a23ea84bd02c34f50d8e10a8b4bfc89597ffe4e" }, "vim-dadbod": { "branch": "master", "commit": "a09e40664e9cd30cd2b3f8866b796598302070f6" }, "vim-dadbod-ui": { "branch": "master", "commit": "f4ead480930a37dd2b0cf917a8c387ed36c2d86a" }, "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, - "which-key.nvim": { "branch": "main", "commit": "85f69b07afce4ea77c58ae9a3aeb4e6c918b4d34" } + "which-key.nvim": { "branch": "main", "commit": "e4fa445065a2bb0bbc3cca85346b67817f28e83e" } } \ No newline at end of file diff --git a/configs/nvim/lua/max/configs/autocomplete.lua b/configs/nvim/lua/max/configs/autocomplete.lua index 20a5ca4..5e190a6 100644 --- a/configs/nvim/lua/max/configs/autocomplete.lua +++ b/configs/nvim/lua/max/configs/autocomplete.lua @@ -1,4 +1,3 @@ --- luasnip setup local luasnip = require("luasnip") require("luasnip/loaders/from_vscode").lazy_load() @@ -9,106 +8,109 @@ local cmp_autopairs = require("nvim-autopairs.completion.cmp") local capabilities = require("cmp_nvim_lsp").default_capabilities() require("lspconfig").html.setup({ - capabilities = capabilities, + capabilities = capabilities, }) require("nvim-autopairs").setup() -require("copilot").setup() -require("copilot_cmp").setup({ - clear_after_cursor = true, +require("copilot").setup({ + suggestion = { enabled = false }, + panel = { enabled = false }, }) +require("copilot_cmp").setup { + method = "getCompletionsCycling", +} local check_backspace = function() - local col = vim.fn.col(".") - 1 - return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") + local col = vim.fn.col(".") - 1 + return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") end cmp.setup({ - window = { - documentation = cmp.config.window.bordered(), - }, - experimental = { - ghost_text = true, - }, - completion = { - completeopt = "menuone,noselect", - }, - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = { - [""] = cmp.mapping.complete({}), - [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expandable() then - luasnip.expand() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif check_backspace() then - fallback() - else - fallback() - end - end, { - "i", - "s", - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { - "i", - "s", - }), - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), - }, - formatting = { - format = lspkind.cmp_format({ - mode = "symbol_text", - max_width = 50, - symbol_map = { Copilot = "" }, - }), - }, - sources = { - { name = "copilot" }, - { name = "vim-dadbod-completion", filetype = "sql" }, - { name = "nvim_lua" }, - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "emoji" }, - { name = "path" }, - { name = "buffer" }, - { name = "calc" }, - }, + window = { + documentation = cmp.config.window.bordered(), + }, + experimental = { + ghost_text = true, + }, + completion = { + completeopt = "menuone,noselect", + }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = { + [""] = cmp.mapping.complete({}), + [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expandable() then + luasnip.expand() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif check_backspace() then + fallback() + else + fallback() + end + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { + "i", + "s", + }), + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), + }, + formatting = { + format = lspkind.cmp_format({ + mode = "symbol_text", + max_width = 50, + symbol_map = { Copilot = "" }, + }), + }, + sources = { + { name = "copilot" }, + { name = "vim-dadbod-completion", filetype = "sql" }, + { name = "nvim_lua" }, + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "emoji" }, + { name = "path" }, + { name = "buffer" }, + { name = "calc" }, + }, }) -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). cmp.setup.cmdline("/", { - sources = { - { name = "buffer" }, - }, + sources = { + { name = "buffer" }, + }, }) -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). cmp.setup.cmdline(":", { - sources = cmp.config.sources({ - { name = "path" }, - }, { - { name = "cmdline" }, - }), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), }) cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } })) diff --git a/configs/nvim/lua/max/configs/lsp.lua b/configs/nvim/lua/max/configs/lsp.lua index 725901b..6c053ba 100644 --- a/configs/nvim/lua/max/configs/lsp.lua +++ b/configs/nvim/lua/max/configs/lsp.lua @@ -2,19 +2,20 @@ local mason = require("mason") local mason_lsp = require("mason-lspconfig") local lsp = require("lspconfig") + require("null-ls").setup({ - sources = { - require("null-ls").builtins.formatting.stylua, - require("null-ls").builtins.diagnostics.eslint, - require("null-ls").builtins.code_actions.eslint_d, - -- require("null-ls").builtins.completion.spell, - }, + sources = { + require("null-ls").builtins.formatting.stylua, + require("null-ls").builtins.diagnostics.eslint, + -- require("null-ls").builtins.code_actions.eslint_d, + -- require("null-ls").builtins.completion.spell, + }, }) mason.setup() mason_lsp.setup({ - ensure_installed = { "sumneko_lua", "jsonls", "tsserver", "svelte", "cssls" }, + ensure_installed = { "sumneko_lua", "jsonls", "tsserver", "svelte", "cssls" }, }) local runtime_path = vim.split(package.path, ";") @@ -22,230 +23,201 @@ table.insert(runtime_path, "lua/?.lua") table.insert(runtime_path, "lua/?/init.lua") local function on_attach(client, bufnr) - if client.supports_method("textDocument/formatting") then - vim.api.nvim_create_autocmd("BufWritePre", { - buffer = bufnr, - callback = function() - vim.lsp.buf.format() + if client.supports_method("textDocument/formatting") then + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = bufnr, + callback = function() + vim.lsp.buf.format() - if client.name == "tsserver" or client.name == "svelte" then - -- params for the request - local params = { - command = "_typescript.organizeImports", - arguments = { vim.api.nvim_buf_get_name(bufnr) }, - title = "", - } + if client.name == "tsserver" or client.name == "svelte" then + -- params for the request + local params = { + command = "_typescript.organizeImports", + arguments = { vim.api.nvim_buf_get_name(bufnr) }, + title = "", + } - -- perform a syncronous request - -- 500ms timeout depending on the size of file a bigger timeout may be needed - vim.lsp.buf_request_sync(bufnr, "workspace/executeCommand", params, 500) - end - end, - }) - else - -- vim.notify("Lsp (" .. client.name .. ") doesnt support format") - end + -- perform a syncronous request + -- 500ms timeout depending on the size of file a bigger timeout may be needed + vim.lsp.buf_request_sync(bufnr, "workspace/executeCommand", params, 500) + end + end, + }) + else + -- vim.notify("Lsp (" .. client.name .. ") doesnt support format") + end end -lsp.sumneko_lua.setup({ - on_attach = on_attach, - settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = "LuaJIT", - -- Setup your lua path - path = runtime_path, - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { "vim" }, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file("", true), - }, - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = { - enable = false, - }, - }, - }, -}) - local capabilities = require("cmp_nvim_lsp").default_capabilities() - +capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true +} capabilities.textDocument.completion.completionItem.snippetSupport = true -lsp.prismals.setup({ - capabilities = capabilities, - on_attach = on_attach, -}) +local custom_lsp = {}; -lsp.emmet_ls.setup({ - capabilities = capabilities, - on_attach = on_attach, -}) +custom_lsp.tsserver = { + on_attach = on_attach, + capabilities = capabilities, + root_dir = lsp.util.root_pattern("tsconfig.json", "package.json", "jsconfig.json", ".git"), +} -lsp.solargraph.setup({ - filetypes = { "ruby" }, - on_attach = on_attach, -}) - -lsp.elixirls.setup({ - on_attach = on_attach, -}) - -lsp.jsonls.setup({ - capabilities = capabilities, - on_attach = on_attach, - settings = { - provideFormatter = false, - json = { - schemas = { - { - description = "TypeScript compiler configuration file", - fileMatch = { "tsconfig.json", "tsconfig.*.json" }, - url = "http://json.schemastore.org/tsconfig", - }, - { - description = "ESLint config", - fileMatch = { ".eslintrc.json", ".eslintrc" }, - url = "http://json.schemastore.org/eslintrc", - }, - { - description = "Prettier config", - fileMatch = { ".prettierrc", ".prettierrc.json", "prettier.config.json" }, - url = "http://json.schemastore.org/prettierrc", - }, - { - description = "JSON schema for Import Maps files", - fileMatch = { "importmap.json", "import_map.json", "import-map.json" }, - name = "importmap.json", - url = "https://json.schemastore.org/importmap.json", - }, - { - description = "NPM configuration file", - fileMatch = { "package.json" }, - name = "package.json", - url = "https://json.schemastore.org/package.json", - }, - }, - }, +custom_lsp.sumneko_lua = { + on_attach = on_attach, + capabilities = capabilities, + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = "LuaJIT", + -- Setup your lua path + path = runtime_path, + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { "vim" }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { + enable = false, + }, }, -}) + }, +} -lsp.svelte.setup({ - capabilities = capabilities, - on_attach = on_attach, -}) -lsp.tsserver.setup({ - capabilities = capabilities, - on_attach = on_attach, -}) -lsp.html.setup({ - capabilities = capabilities, - on_attach = on_attach, -}) -lsp.phpactor.setup({ - capabilities = capabilities, - on_attach = on_attach, -}) -lsp.intelephense.setup({ - capabilities = capabilities, - on_attach = on_attach, - settings = { - intelephense = { - stubs = { - "wordpress", - "woocommerce", - "wordpress-globals", - "wp-cli", - }, - environment = { - includePaths = "/home/max/.composer/vendor/php-stubs/", -- this line forces the composer path for the stubs in case inteliphense don't find it... - }, - files = { - maxSize = 5000000, - }, + +custom_lsp.jsonls = { + capabilities = capabilities, + on_attach = on_attach, + settings = { + provideFormatter = false, + json = { + schemas = { + { + description = "TypeScript compiler configuration file", + fileMatch = { "tsconfig.json", "tsconfig.*.json" }, + url = "http://json.schemastore.org/tsconfig", }, - }, -}) -lsp.cssls.setup({ - capabilities = capabilities, - on_attach = on_attach, -}) - -lsp.zls.setup({ - capabilities = capabilities, - on_attach = on_attach, -}) - -lsp.bashls.setup({ - capabilities = capabilities, - filetypes = { "sh", "bash" }, - on_attach = on_attach, -}) - -lsp.rust_analyzer.setup({ - on_attach = on_attach, - settings = { - ["rust-analyzer"] = { - imports = { - granularity = { - group = "module", - }, - prefix = "self", - }, - cargo = { - buildScripts = { - enable = true, - }, - }, - procMacro = { - enable = true, - }, + { + description = "ESLint config", + fileMatch = { ".eslintrc.json", ".eslintrc" }, + url = "http://json.schemastore.org/eslintrc", }, - }, -}) - -lsp.gopls.setup({ - capabilities = capabilities, - on_attach = on_attach, -}) - -lsp.yamlls.setup({ - capabilities = capabilities, - on_attach = on_attach, - settings = { - yaml = { - schemas = { - ["https://raw.githubusercontent.com/quantumblacklabs/kedro/develop/static/jsonschema/kedro-catalog-0.17.json"] = "conf/**/*catalog*", - ["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*", - ["https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/traefik-v2-file-provider.json"] = "rules.yml", - ["https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/traefik-v2.json"] = "traefik.yml", - }, + { + description = "Prettier config", + fileMatch = { ".prettierrc", ".prettierrc.json", "prettier.config.json" }, + url = "http://json.schemastore.org/prettierrc", }, - }, -}) - -lsp.glslls.setup(require("max.configs.lsp-glsl")) - -lsp.ltex.setup({ - capabilities = capabilities, - on_attach = on_attach, - settings = { - ltex = { - language = "de", - disabledRules = { ["en-US"] = { "PROFANITY" } }, - dictionary = { - ["en-US"] = { "perf", "ci", "neovim" }, - }, - hiddenFalsePositives = { - "neovim", - "Neovim", - "waybar", - }, + { + description = "JSON schema for Import Maps files", + fileMatch = { "importmap.json", "import_map.json", "import-map.json" }, + name = "importmap.json", + url = "https://json.schemastore.org/importmap.json", }, + { + description = "NPM configuration file", + fileMatch = { "package.json" }, + name = "package.json", + url = "https://json.schemastore.org/package.json", + }, + }, }, + }, +} + +custom_lsp.intelephense = { + capabilities = capabilities, + on_attach = on_attach, + settings = { + intelephense = { + stubs = { + "wordpress", + "woocommerce", + "wordpress-globals", + "wp-cli", + }, + environment = { + includePaths = "/home/max/.composer/vendor/php-stubs/", -- this line forces the composer path for the stubs in case inteliphense don't find it... + }, + files = { + maxSize = 5000000, + }, + }, + }, +} + +custom_lsp.rust_analyzer = { + on_attach = on_attach, + settings = { + ["rust-analyzer"] = { + imports = { + granularity = { + group = "module", + }, + prefix = "self", + }, + cargo = { + buildScripts = { + enable = true, + }, + }, + procMacro = { + enable = true, + }, + }, + }, +} + +custom_lsp.yamlls = { + capabilities = capabilities, + on_attach = on_attach, + settings = { + yaml = { + schemas = { + ["https://raw.githubusercontent.com/quantumblacklabs/kedro/develop/static/jsonschema/kedro-catalog-0.17.json"] = "conf/**/*catalog*", + ["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*", + ["https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/traefik-v2-file-provider.json"] = "rules.yml", + ["https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/traefik-v2.json"] = "traefik.yml", + }, + }, + }, +} + +custom_lsp.glslls = require("max.configs.lsp-glsl") + +custom_lsp.ltex = { + capabilities = capabilities, + on_attach = on_attach, + settings = { + ltex = { + language = "de", + disabledRules = { ["en-US"] = { "PROFANITY" } }, + dictionary = { + ["en-US"] = { "perf", "ci", "neovim" }, + }, + hiddenFalsePositives = { + "neovim", + "Neovim", + "waybar", + }, + }, + }, +} + +require('mason-lspconfig').setup_handlers({ + function(server_name) + if custom_lsp[server_name] ~= nil then + lsp[server_name].setup(custom_lsp[server_name]) + else + lsp[server_name].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + end + end, }) diff --git a/configs/nvim/lua/max/configs/treesitter.lua b/configs/nvim/lua/max/configs/treesitter.lua index 3c599c1..bc532ea 100644 --- a/configs/nvim/lua/max/configs/treesitter.lua +++ b/configs/nvim/lua/max/configs/treesitter.lua @@ -1,4 +1,7 @@ require("nvim-treesitter.configs").setup({ + context_commentstring = { + enable = true + }, indent = { enable = true, }, diff --git a/configs/nvim/lua/max/core/autocommands.lua b/configs/nvim/lua/max/core/autocommands.lua index 7be5a00..64b00b2 100644 --- a/configs/nvim/lua/max/core/autocommands.lua +++ b/configs/nvim/lua/max/core/autocommands.lua @@ -41,8 +41,18 @@ augroup filetypedetect augroup END ]]) -autocmd({ "BufReadPost" }, { - pattern = "*", - group = config_group, - command = "filetype detect", +-- autocmd({ "BufReadPost" }, { +-- pattern = "*", +-- group = config_group, +-- command = "filetype detect", +-- }) + +autocmd("BufReadPost", { + callback = function() + local mark = vim.api.nvim_buf_get_mark(0, '"') + local lcount = vim.api.nvim_buf_line_count(0) + if mark[1] > 0 and mark[1] <= lcount then + pcall(vim.api.nvim_win_set_cursor, 0, mark) + end + end, }) diff --git a/configs/nvim/lua/max/core/keymappings.lua b/configs/nvim/lua/max/core/keymappings.lua index ccc61f5..6ff1b64 100644 --- a/configs/nvim/lua/max/core/keymappings.lua +++ b/configs/nvim/lua/max/core/keymappings.lua @@ -27,6 +27,7 @@ map("n", "a", ":Alpha", opts); -- LSP Functionality map("n", "n", ":lua vim.diagnostic.goto_next()", opts) map("n", "p", ":lua vim.diagnostic.goto_prev()", opts) +map("n", "e", ":lua vim.diagnostic.open_float()", opts) map("n", "gD", "lua vim.lsp.buf.declaration()", opts) map("n", "gd", "lua vim.lsp.buf.definition()", opts) map("n", "gi", "lua vim.lsp.buf.implementation()", opts) @@ -39,7 +40,7 @@ map({ "n", "v" }, "gr", "Lspsaga lsp_finder", opts) map("n", "u", ":UndotreeToggle", opts) -- This is my [i]nspect section, [i]nspect [s]ymbols -map("n", "is", "lua require('litee.lib.lsp.wrappers').buf_document_symbol()", opts) +map("n", "is", "SymbolsOutline", opts) map("n", "io", "Lspsaga outline", opts) map("n", "ip", ":TroubleToggle", opts) map({ "n", "v" }, "t", require("max.configs.translate"), opts) @@ -88,13 +89,20 @@ map("n", "", "yyp", opts) -- If i paste with p, the replaced content doesnt replace my clipboard map("v", "p", '"_dP', opts) +-- clear highlights after search +map("n", "cl", ":noh", opts); +map("n", "m", ":Mason", opts); +map("n", "l", ":Lazy", opts); +map("n", "so", ":so %", opts); + + -- Faster git merge map("n", "gd", ":Gvdiffsplit!", opts) map("n", "gdl", ":diffget //3", opts) map("n", "gdh", ":diffget //2", opts) -- Find file in NvimTree -map("n", "e", ":NvimTreeToggle", opts) +map("n", "j", ":NvimTreeToggle", opts) map("n", "f", ":NvimTreeFindFile", opts) -- I aint no weak boy diff --git a/configs/nvim/lua/max/core/options.lua b/configs/nvim/lua/max/core/options.lua index 20f1cf0..9aeffa3 100644 --- a/configs/nvim/lua/max/core/options.lua +++ b/configs/nvim/lua/max/core/options.lua @@ -25,6 +25,8 @@ vim.cmd([[set complete+=kspell]]) -- auto complete with spellcheck vim.cmd([[set completeopt=menuone,noselect]]) -- auto complete menu (It's pretty great) vim.cmd([[set nocompatible]]) -- Disable compatibility to old-time vi set.mouse = "a" -- Enable mouse support +set.signcolumn = "yes" +set.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" } -- Configure Folds vim.cmd([[set wildmode=list:longest,full]]) -- Command-line completion mode @@ -50,7 +52,7 @@ set.termguicolors = true -- set term gui colors (most terminals support this) set.laststatus = 3 -- Always display the status line set.title = true -- Show current txt that you editing set.relativenumber = true -- Vim’s absolute, relative and hybrid line numbers -set.cursorline = false -- Enable highlighting of the current line +set.cursorline = true -- Enable highlighting of the current line set.synmaxcol = 128 vim.cmd("syntax sync minlines=256") set.mousescroll = "ver:1,hor:1" diff --git a/configs/nvim/lua/max/core/plugins.lua b/configs/nvim/lua/max/core/plugins.lua index 8beb163..8780040 100644 --- a/configs/nvim/lua/max/core/plugins.lua +++ b/configs/nvim/lua/max/core/plugins.lua @@ -13,6 +13,7 @@ local plugins = { { "nvim-lualine/lualine.nvim", + lazy = false, config = function() require("max.configs.lualine") end, @@ -21,9 +22,11 @@ local plugins = { -------------------- -- Layout Plugins -- -------------------- + { 'akinsho/bufferline.nvim', lazy = false, config = true }, { "shortcuts/no-neck-pain.nvim", cmd = "NoNeckPain", config = true }, { "stevearc/dressing.nvim", + lazy = false, config = true }, { @@ -34,17 +37,10 @@ local plugins = { end, }, { - "ldelossa/litee.nvim", - cmd = "InsertEnter", - dependencies = { - "ldelossa/litee-symboltree.nvim", - "ldelossa/litee-calltree.nvim", - }, - config = function() - require("max.configs.litee") - end, + "simrat39/symbols-outline.nvim", + cmd = "SymbolsOutline", + config = true, }, - { "ethanholz/nvim-lastplace", event = "BufReadPre", config = true }, { "mbbill/undotree", lazy = false }, { "petertriho/nvim-scrollbar", @@ -78,16 +74,15 @@ local plugins = { event = "BufReadPost", dependencies = 'kevinhwang91/promise-async', config = function() - require('ufo').setup({ - provider_selector = function() - return { 'treesitter', 'indent' } - end - }) + require("ufo").setup() + vim.o.foldcolumn = '1' vim.o.foldlevel = 99 vim.o.foldlevelstart = 99 vim.o.foldenable = true - vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] + -- vim.o.statuscolumn = "%=%l%s%C" + vim.o.statuscolumn = '%=%l%s%{foldlevel(v:lnum) > foldlevel(v:lnum - 1) ? (foldclosed(v:lnum) == -1 ? "" : "") : " " }' + -- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] end, }, { @@ -109,7 +104,7 @@ local plugins = { }, -- startup screen { "numToStr/Comment.nvim", - event = "BufReadPre", + event = "InsertEnter", config = function() require("Comment").setup() end, @@ -119,13 +114,12 @@ local plugins = { --------------------- "junegunn/fzf", { - "ggandor/leap.nvim", - - config = function() - local leap = require("leap") - leap.add_default_mappings() - leap.setup({}) - end, + "ggandor/flit.nvim", + dependencies = { + "ggandor/leap.nvim", + }, + event = "VimEnter", + config = true, }, { "nvim-telescope/telescope.nvim", @@ -133,42 +127,28 @@ local plugins = { require("max.configs.telescope") end, }, - --------------- -- Lsp Setup -- --------------- - - { "glepnir/lspsaga.nvim", - cmd = "Lspsaga" - }, -- better windows for lsp replace, goto definition etc... - { "VonHeikemen/lsp-zero.nvim", + { + "glepnir/lspsaga.nvim", + event = 'BufRead', + config = function() + require('lspsaga').setup({}) + end + }, + { "neovim/nvim-lspconfig", dependencies = { - "neovim/nvim-lspconfig", "arkav/lualine-lsp-progress", "williamboman/mason.nvim", + "jose-elias-alvarez/null-ls.nvim", "williamboman/mason-lspconfig.nvim", - "hrsh7th/nvim-cmp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "saadparwaiz1/cmp_luasnip", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-nvim-lua", - "L3MON4D3/LuaSnip", "onsails/lspkind.nvim", - "rafamadriz/friendly-snippets", { "lukas-reineke/lsp-format.nvim", config = true }, }, event = "InsertEnter", config = function() - local lsp = require("lsp-zero") - lsp.preset("recommended") - lsp.on_attach(function(client, bufnr) - require("lsp-format").on_attach(client, bufnr) - end) - lsp.nvim_workspace() - lsp.setup() - vim.diagnostic.config { virtual_text = true } - + require("max.configs.lsp") end }, { "folke/trouble.nvim", @@ -182,16 +162,36 @@ local plugins = { -- Autocomplete -- ------------------- { "tpope/vim-surround", lazy = false }, + { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-buffer", + "windwp/nvim-autopairs", + "hrsh7th/cmp-path", + "hrsh7th/cmp-emoji", + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-nvim-lua", + "zbirenbaum/copilot.lua", + "zbirenbaum/copilot-cmp", + "L3MON4D3/LuaSnip", + "rafamadriz/friendly-snippets", + }, + config = function() + require("max.configs.autocomplete") + end + }, { "nat-418/boole.nvim", - event = "BufReadPre", + event = "InsertEnter", config = function() require("boole").setup() end, }, { "gaoDean/autolist.nvim", - event = "BufReadPre", + event = "InsertEnter", config = function() require("autolist").setup({}) end, @@ -204,6 +204,7 @@ local plugins = { event = "BufReadPost", dependencies = { "nvim-treesitter/nvim-treesitter-textobjects", + "JoosepAlviste/nvim-ts-context-commentstring" }, config = function() require("max.configs.treesitter") diff --git a/configs/nvim/lua/max/theme/icons.lua b/configs/nvim/lua/max/theme/icons.lua new file mode 100644 index 0000000..4e21f2b --- /dev/null +++ b/configs/nvim/lua/max/theme/icons.lua @@ -0,0 +1,59 @@ +local defaults = { + -- colorscheme can be a string like `catppuccin` or a function that will load the colorscheme + ---@type string|fun() + colorscheme = function() + require("tokyonight").load() + end, + -- icons used by other plugins + icons = { + diagnostics = { + Error = " ", + Warn = " ", + Hint = " ", + Info = " ", + }, + git = { + added = " ", + modified = " ", + removed = " ", + }, + kinds = { + Array = " ", + Boolean = " ", + Class = " ", + Color = " ", + Constant = " ", + Constructor = " ", + Enum = " ", + EnumMember = " ", + Event = " ", + Field = " ", + File = " ", + Folder = " ", + Function = " ", + Interface = " ", + Key = " ", + Keyword = " ", + Method = " ", + Module = " ", + Namespace = " ", + Null = "ﳠ ", + Number = " ", + Object = " ", + Operator = " ", + Package = " ", + Property = " ", + Reference = " ", + Snippet = " ", + String = " ", + Struct = " ", + Text = " ", + TypeParameter = " ", + Unit = " ", + Value = " ", + Variable = " ", + }, + }, +} + +return defaults