From 50c4761b4bcbbddf22956e85d1d2b81071530a9c Mon Sep 17 00:00:00 2001 From: ALittlePatate Date: Fri, 3 Nov 2023 11:24:41 +0100 Subject: [PATCH] nvim config stolen from @Lukacms --- .emacs | 1 + MANIFEST.linux | 1 + nvim/.luarc.json | 10 + nvim/ftplugin/markdown.vim | 1 + nvim/init.lua | 20 ++ nvim/lazy-lock.json | 49 +++ nvim/lua/highlights.lua | 29 ++ nvim/lua/lsp/asm.lua | 10 + nvim/lua/lsp/clangd.lua | 12 + nvim/lua/lsp/csharp-ls.lua | 7 + nvim/lua/lsp/elsint.lua | 46 +++ nvim/lua/lsp/hls.lua | 19 ++ nvim/lua/lsp/init.lua | 110 +++++++ nvim/lua/lsp/jsonls.lua | 16 + nvim/lua/lsp/null-ls.lua | 37 +++ nvim/lua/lsp/rust-analyzer.lua | 27 ++ nvim/lua/lsp/sumneko_lua.lua | 32 ++ nvim/lua/lsp/texlab.lua | 28 ++ nvim/lua/lsp/tsserver.lua | 18 ++ nvim/lua/lsp/utils.lua | 24 ++ nvim/lua/mappings.lua | 36 +++ nvim/lua/options.lua | 58 ++++ nvim/lua/plugins/coding.lua | 202 +++++++++++++ nvim/lua/plugins/colorscheme.lua | 45 +++ nvim/lua/plugins/documentation.lua | 9 + nvim/lua/plugins/editor.lua | 284 ++++++++++++++++++ nvim/lua/plugins/init.lua | 1 + nvim/lua/plugins/misc.lua | 35 +++ nvim/lua/plugins/treesitter.lua | 64 ++++ nvim/lua/plugins/ui.lua | 84 ++++++ nvim/lua/settings.lua | 17 ++ nvim/lua/utils.lua | 85 ++++++ nvim/scripts/get_vimspector_conf.sh | 9 + .../vimspector/conf/c/.vimspector.json | 21 ++ nvim/snippets/c.json | 96 ++++++ nvim/snippets/cmake.json | 12 + nvim/snippets/cpp.json | 147 +++++++++ nvim/snippets/haskell.json | 16 + nvim/snippets/make.json | 45 +++ nvim/snippets/neo-tree.json | 1 + nvim/snippets/python.json | 37 +++ nvim/snippets/rust.json | 8 + 42 files changed, 1809 insertions(+) create mode 100644 nvim/.luarc.json create mode 100644 nvim/ftplugin/markdown.vim create mode 100644 nvim/init.lua create mode 100644 nvim/lazy-lock.json create mode 100644 nvim/lua/highlights.lua create mode 100644 nvim/lua/lsp/asm.lua create mode 100644 nvim/lua/lsp/clangd.lua create mode 100644 nvim/lua/lsp/csharp-ls.lua create mode 100644 nvim/lua/lsp/elsint.lua create mode 100644 nvim/lua/lsp/hls.lua create mode 100644 nvim/lua/lsp/init.lua create mode 100644 nvim/lua/lsp/jsonls.lua create mode 100644 nvim/lua/lsp/null-ls.lua create mode 100644 nvim/lua/lsp/rust-analyzer.lua create mode 100644 nvim/lua/lsp/sumneko_lua.lua create mode 100644 nvim/lua/lsp/texlab.lua create mode 100644 nvim/lua/lsp/tsserver.lua create mode 100644 nvim/lua/lsp/utils.lua create mode 100644 nvim/lua/mappings.lua create mode 100644 nvim/lua/options.lua create mode 100644 nvim/lua/plugins/coding.lua create mode 100644 nvim/lua/plugins/colorscheme.lua create mode 100644 nvim/lua/plugins/documentation.lua create mode 100644 nvim/lua/plugins/editor.lua create mode 100644 nvim/lua/plugins/init.lua create mode 100644 nvim/lua/plugins/misc.lua create mode 100644 nvim/lua/plugins/treesitter.lua create mode 100644 nvim/lua/plugins/ui.lua create mode 100644 nvim/lua/settings.lua create mode 100644 nvim/lua/utils.lua create mode 100644 nvim/scripts/get_vimspector_conf.sh create mode 100644 nvim/scripts/vimspector/conf/c/.vimspector.json create mode 100644 nvim/snippets/c.json create mode 100644 nvim/snippets/cmake.json create mode 100644 nvim/snippets/cpp.json create mode 100644 nvim/snippets/haskell.json create mode 100644 nvim/snippets/make.json create mode 100644 nvim/snippets/neo-tree.json create mode 100644 nvim/snippets/python.json create mode 100644 nvim/snippets/rust.json diff --git a/.emacs b/.emacs index fbf7a41..0cd1731 100755 --- a/.emacs +++ b/.emacs @@ -23,6 +23,7 @@ (show-paren-mode 1) (electric-pair-mode 1) (global-display-line-numbers-mode 1) +(global-font-lock-mode 0) (setq display-line-numbers-type 'relative) (set-face-attribute 'default nil :height 200) (global-set-key (kbd "") 'keyboard-escape-quit) diff --git a/MANIFEST.linux b/MANIFEST.linux index 399b887..cc8b1b7 100755 --- a/MANIFEST.linux +++ b/MANIFEST.linux @@ -1,6 +1,7 @@ .Xresources|symlink| .tmux.conf|symlink| .vimrc|symlink| +nvim|symlink|.config dunstrc|symlink|.config/dunst kitty.conf|symlink|.config/kitty neofetch/config.conf|symlink|.config diff --git a/nvim/.luarc.json b/nvim/.luarc.json new file mode 100644 index 0000000..3f28253 --- /dev/null +++ b/nvim/.luarc.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", + "Lua.workspace.checkThirdParty": false, + "diagnostics.disable": [ + "unused-local" + ], + "diagnostics.globals": [ + "vim" + ] +} \ No newline at end of file diff --git a/nvim/ftplugin/markdown.vim b/nvim/ftplugin/markdown.vim new file mode 100644 index 0000000..8c537e1 --- /dev/null +++ b/nvim/ftplugin/markdown.vim @@ -0,0 +1 @@ +vmap :EasyAlign* diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..eee01a3 --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,20 @@ +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) + +require("options") +require("mappings") +require("settings") +require("lazy").setup("plugins") +require("lsp") +require("highlights") diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json new file mode 100644 index 0000000..136b38a --- /dev/null +++ b/nvim/lazy-lock.json @@ -0,0 +1,49 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" }, + "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, + "gitsigns.nvim": { "branch": "main", "commit": "5a9a6ac29a7805c4783cda21b80a1e361964b3f2" }, + "glow.nvim": { "branch": "main", "commit": "5b38fb7b6e806cac62707a4aba8c10c5f14d5bb5" }, + "lazy.nvim": { "branch": "main", "commit": "4c75c8eeb957a99aa44ce8e526c04340ab358c5e" }, + "lspkind-nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, + "lualine.nvim": { "branch": "master", "commit": "7533b0ead663d80452210c0c089e5105089697e5" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "neo-tree.nvim": { "branch": "v2.x", "commit": "80dc74d081823649809f78370fa5b204aa9a853a" }, + "neogen": { "branch": "main", "commit": "70127baaff25611deaf1a29d801fc054ad9d2dc1" }, + "nui.nvim": { "branch": "main", "commit": "c0c8e347ceac53030f5c1ece1c5a5b6a17a25b32" }, + "null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, + "nvim-autopairs": { "branch": "master", "commit": "f6c71641f6f183427a651c0ce4ba3fb89404fa9e" }, + "nvim-cmp": { "branch": "main", "commit": "d3a3056204e1a9dbb7c7fe36c114dc43b681768c" }, + "nvim-code-action-menu": { "branch": "main", "commit": "e4399dbaf6eabff998d3d5f1cbcd8d9933710027" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" }, + "nvim-lspconfig": { "branch": "master", "commit": "e49b1e90c1781ce372013de3fa93a91ea29fc34a" }, + "nvim-treesitter": { "branch": "master", "commit": "afa103385a2b5ef060596ed822ef63276ae88016" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "92e688f013c69f90c9bbd596019ec10235bc51de" }, + "nvim-ufo": { "branch": "main", "commit": "ebbab711d909d5f675e38ad489765bd22bd2c6b3" }, + "nvim-web-devicons": { "branch": "master", "commit": "3af745113ea537f58c4b1573b64a429fefad9e07" }, + "nvim-window-picker": { "branch": "main", "commit": "5902827d0e338890a22849e2f18dc80d1cc1a8db" }, + "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, + "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, + "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, + "prettier.nvim": { "branch": "main", "commit": "d98e732cb73690b07c00c839c924be1d1d9ac5c2" }, + "promise-async": { "branch": "main", "commit": "e94f35161b8c5d4a4ca3b6ff93dd073eb9214c0e" }, + "rust-tools.nvim": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" }, + "schemastore.nvim": { "branch": "main", "commit": "a8fa6a36f09f00d32577fae0b3cee2f25ffc5c74" }, + "stabilize.nvim": { "branch": "master", "commit": "eeb1873daffaba67246188a5668b366e45ed1de1" }, + "symbols-outline.nvim": { "branch": "master", "commit": "512791925d57a61c545bc303356e8a8f7869763c" }, + "tabline.nvim": { "branch": "main", "commit": "2eb56826bf7b85b9090aff73a696e0e803bf89ae" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, + "telescope.nvim": { "branch": "master", "commit": "74ce793a60759e3db0d265174f137fb627430355" }, + "todo-comments.nvim": { "branch": "main", "commit": "3094ead8edfa9040de2421deddec55d3762f64d1" }, + "trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" }, + "typescript.nvim": { "branch": "main", "commit": "4de85ef699d7e6010528dcfbddc2ed4c2c421467" }, + "vim-better-whitespace": { "branch": "master", "commit": "1b22dc57a2751c7afbc6025a7da39b7c22db635d" }, + "vim-easy-align": { "branch": "master", "commit": "12dd6316974f71ce333e360c0260b4e1f81169c3" }, + "vim-fugitive": { "branch": "master", "commit": "cbe9dfa162c178946afa689dd3f42d4ea8bf89c1" }, + "vim-vsnip": { "branch": "master", "commit": "be277461265f1e5c7db470aa479f30956597ea9e" }, + "vim-windowswap": { "branch": "master", "commit": "15db3f697aa1fa696d99fcdc920c90cd2cec855e" }, + "vscode.nvim": { "branch": "main", "commit": "563e3f671543ba14f23ccb57020a428add640d02" } +} \ No newline at end of file diff --git a/nvim/lua/highlights.lua b/nvim/lua/highlights.lua new file mode 100644 index 0000000..168c34e --- /dev/null +++ b/nvim/lua/highlights.lua @@ -0,0 +1,29 @@ +local highlight = require("utils").highlight + +vim.o.termguicolors = true + +highlight("VertSplit", { bg = "None" }) + +return { + colors = { + columbia_blue = "#9CDCFE", + eclipse = "#3C3C3C", + glabe_green = "#608B4E", + grey = "#808080", + light_grey = "#D4D4D4", + lilac = "#C586C0", + nero = "#262626", + picton_blue = "#569CD6", + straw = "#D7BA7D", + + -- Diagnostics + equator = "#E0AF68", + mountain_meadow = "#10B981", + sunset_orange = "#F44747", + + -- GitSigns + bordeaux = "#4b1818", + clover = "#4b5632", + raw_umber = "#6F490B", + }, +} diff --git a/nvim/lua/lsp/asm.lua b/nvim/lua/lsp/asm.lua new file mode 100644 index 0000000..9db0d03 --- /dev/null +++ b/nvim/lua/lsp/asm.lua @@ -0,0 +1,10 @@ +local M = {} + +M.setup = function(on_attach, capabilities) + require("lspconfig").asm.setup({ + capabilities = capabilities, + cmd = { "asm-lsp" }, + on_attach = on_attach, + }) +end +return M diff --git a/nvim/lua/lsp/clangd.lua b/nvim/lua/lsp/clangd.lua new file mode 100644 index 0000000..3ac5e04 --- /dev/null +++ b/nvim/lua/lsp/clangd.lua @@ -0,0 +1,12 @@ +local M = {} + +M.setup = function(on_attach, capabilities) + require("lspconfig").clangd.setup({ + capabilities = capabilities, + cmd = { "clangd", "--background-index", "-clang-tidy" }, + on_attach = on_attach, + filetype = { "c", "cpp", "objc", "objcpp" }, + }) +end + +return M diff --git a/nvim/lua/lsp/csharp-ls.lua b/nvim/lua/lsp/csharp-ls.lua new file mode 100644 index 0000000..cadd6af --- /dev/null +++ b/nvim/lua/lsp/csharp-ls.lua @@ -0,0 +1,7 @@ +local M = {} + +M.setup = function(on_attach, capabilities) + require 'lspconfig'.csharp_ls.setup {} +end + +return M diff --git a/nvim/lua/lsp/elsint.lua b/nvim/lua/lsp/elsint.lua new file mode 100644 index 0000000..0796bdc --- /dev/null +++ b/nvim/lua/lsp/elsint.lua @@ -0,0 +1,46 @@ +local M = {} + +M.setup = function(on_attach, capabilities) + require("lspconfig").eslint.setup({ + capabilities = capabilities, + filetypes = { + "javascript", + "javascriptreact", + "javascript.jsx", + "typescript", + "typescriptreact", + "typescript.tsx", + "vue", + }, + on_attach = on_attach, + settings = { + codeAction = { + disableRuleComment = { + enable = true, + location = "separateLine", + }, + showDocumentation = { + enable = true, + }, + }, + codeActionOnSave = { + enable = false, + mode = "all", + }, + format = false, + nodePath = "", + onIgnoredFiles = "off", + packageManager = "yarn", + quiet = false, + rulesCustomizations = {}, + run = "onType", + useESLintClass = false, + validate = "on", + workingDirectory = { + mode = "location", + }, + }, + }) +end + +return M diff --git a/nvim/lua/lsp/hls.lua b/nvim/lua/lsp/hls.lua new file mode 100644 index 0000000..a18265a --- /dev/null +++ b/nvim/lua/lsp/hls.lua @@ -0,0 +1,19 @@ +local M = {} + +M.setup = function(on_attach, capabilities) + require("lspconfig").hls.setup({ + capabilities = capabilities, + cmd = { "haskell-language-server-wrapper", "--lsp" }, + on_attach = on_attach, + filetypes = { "haskell", "lhaskell" }, + settings = { + haskell = { + -- formattingProvider = "stylish-haskell", + --[[ formattingProvider = "", + cabalFormattingProvider = "cabalfmt", ]] + }, + }, + }) +end + +return M diff --git a/nvim/lua/lsp/init.lua b/nvim/lua/lsp/init.lua new file mode 100644 index 0000000..f9e4d73 --- /dev/null +++ b/nvim/lua/lsp/init.lua @@ -0,0 +1,110 @@ +local lsp_utils = require("lsp.utils") +local u = require("utils") + +vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + underline = true, + update_in_insert = false, + virtual_text = { + prefix = "", + }, +}) + +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" }) + +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + +local lsp_formatting = function(bufnr, async, range) + vim.lsp.buf.format({ + async = async, + bufnr = bufnr, + filter = function(client) + local excluded_clients = { "html", "tsserver" } + + for _, excluded_client in ipairs(excluded_clients) do + if excluded_client == client.name then + return false + end + end + return true + end, + range = range, + }) +end + +local on_attach = function(client, bufnr) + u.buf_map(bufnr, "n", "gd", vim.lsp.buf.definition) + u.buf_map(bufnr, "n", "gi", vim.lsp.buf.implementation) + u.buf_map(bufnr, "n", "K", vim.lsp.buf.hover) + u.buf_map(bufnr, "n", "", vim.lsp.buf.signature_help) + u.buf_map(bufnr, "n", "gt", vim.lsp.buf.type_definition) + u.buf_map(bufnr, "n", "gr", vim.lsp.buf.references) + u.buf_map(bufnr, "n", "", ":CodeActionMenu") + u.buf_map(bufnr, "n", "d", vim.diagnostic.open_float) + u.buf_map(bufnr, "n", "r", vim.lsp.buf.rename) + u.buf_map(bufnr, "n", "", ":Trouble document_diagnostics") + + if client.supports_method("textDocument/formatting") then + u.buf_command(bufnr, "LspFormatting", function() + lsp_formatting(bufnr, false) + end) + u.buf_map(bufnr, "n", "f", function() + lsp_formatting(bufnr, true) + end) + if lsp_utils.is_path_excluded(bufnr, client) == false then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + command = "LspFormatting", + }) + end + end + + if client.supports_method("textDocument/rangeFormatting") then + u.buf_map(bufnr, "v", "f", function() + local start = vim.api.nvim_buf_get_mark(0, "<") + local _end = vim.api.nvim_buf_get_mark(0, ">") + local range = { start = start, ["end"] = _end } + + lsp_formatting(bufnr, true, range) + end) + end +end + +local capabilities = require("cmp_nvim_lsp").default_capabilities() + +local servers_names = { + "bashls", + "clangd", + "cmake", + "csharp_ls", + "cssmodules_ls", + "dockerls", + "elixirls", + "html", + "hls", + "java_language_server", + "jsonls", + "lua_ls", + "null-ls", + "pyright", + "rust-analyzer", + -- "sumneko_lua", + "texlab", + "tsserver", + "yamlls", +} + +for _, server_name in ipairs(servers_names) do + local success, server = pcall(require, "lsp." .. server_name) + + if success then + server.setup(on_attach, capabilities) + else + -- Load default lsp config + require("lspconfig")[server_name].setup({ on_attach, capabilities }) + end +end diff --git a/nvim/lua/lsp/jsonls.lua b/nvim/lua/lsp/jsonls.lua new file mode 100644 index 0000000..8db6569 --- /dev/null +++ b/nvim/lua/lsp/jsonls.lua @@ -0,0 +1,16 @@ +local M = {} + +M.setup = function(on_attach, capabilities) + require("lspconfig").jsonls.setup({ + capabilities = capabilities, + on_attach = on_attach, + settings = { + json = { + validate = { enable = true }, + schemas = require("schemastore").json.schemas(), + }, + }, + }) +end + +return M diff --git a/nvim/lua/lsp/null-ls.lua b/nvim/lua/lsp/null-ls.lua new file mode 100644 index 0000000..c8ff644 --- /dev/null +++ b/nvim/lua/lsp/null-ls.lua @@ -0,0 +1,37 @@ +local null_ls = require("null-ls") +local b = null_ls.builtins + +-- https://github.com/jose-elias-alvarez/null-ls.nvim/pull/804 +local buf_path_in_workflow_folder = function() + local api = vim.api + local path = api.nvim_buf_get_name(api.nvim_get_current_buf()) + return path:match("github/workflows/") ~= nil +end + +local sources = { + b.diagnostics.actionlint.with({ + runtime_condition = buf_path_in_workflow_folder, + }), + + function() + local nl_utils = require("null-ls.utils").make_conditional_utils() + return nl_utils.root_has_file({ ".prettierrc.json", ".prettierrc" }) + and b.formatting.prettierd.with({ filetypes = { "html", "javascript", "typescript", "svelte" } }) + or b.formatting.eslint_d + end, + + b.formatting.black, + b.formatting.stylua, +} + +local M = {} + +M.setup = function(on_attach) + null_ls.setup({ + debug = false, + sources = sources, + on_attach = on_attach, + }) +end + +return M diff --git a/nvim/lua/lsp/rust-analyzer.lua b/nvim/lua/lsp/rust-analyzer.lua new file mode 100644 index 0000000..58db1ef --- /dev/null +++ b/nvim/lua/lsp/rust-analyzer.lua @@ -0,0 +1,27 @@ +local M = {} + +M.setup = function(on_attach, capabilities) + require("rust-tools").setup({ + server = { + capabilities = capabilities, + on_attach = on_attach, + settings = { + ["rust-analyzer"] = { + checkOnSave = { + command = "clippy", + }, + cargo = { + autoreload = true, + }, + diagnostics = { + enable = true, + disabled = { "unresolved-proc-macro" }, + enableExperimental = true, + }, + }, + }, + }, + }) +end + +return M diff --git a/nvim/lua/lsp/sumneko_lua.lua b/nvim/lua/lsp/sumneko_lua.lua new file mode 100644 index 0000000..7545044 --- /dev/null +++ b/nvim/lua/lsp/sumneko_lua.lua @@ -0,0 +1,32 @@ +local runtime_path = vim.split(package.path, ";") +table.insert(runtime_path, "lua/?.lua") +table.insert(runtime_path, "lua/?/init.lua") + +local M = {} + +M.setup = function(on_attach, capabilities) + require("lspconfig").sumneko_lua.setup({ + capabilities = capabilities, + disable_formatting = true, + on_attach = on_attach, + settings = { + Lua = { + runtime = { + version = "LuaJIT", + path = runtime_path, + }, + diagnostics = { + globals = { "vim", "use" }, + }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + }, + telemetry = { + enable = false, + }, + }, + }, + }) +end + +return M diff --git a/nvim/lua/lsp/texlab.lua b/nvim/lua/lsp/texlab.lua new file mode 100644 index 0000000..8137f87 --- /dev/null +++ b/nvim/lua/lsp/texlab.lua @@ -0,0 +1,28 @@ +local M = {} + +M.setup = function(on_attach, capabilities) + require("lspconfig").texlab.setup({ + capabilities = capabilities, + on_attach = on_attach, + settings = { + texlab = { + build = { + executable = "tectonic", + args = { + "%f", + "--synctex", + "--keep-logs", + "--keep-intermediates", + }, + }, + formatterLineLength = 80, + latexFormatter = "latexindent", + latexindent = { + modifyLineBreaks = true, + }, + }, + }, + }) +end + +return M diff --git a/nvim/lua/lsp/tsserver.lua b/nvim/lua/lsp/tsserver.lua new file mode 100644 index 0000000..8a21c46 --- /dev/null +++ b/nvim/lua/lsp/tsserver.lua @@ -0,0 +1,18 @@ +local u = require("utils") + +local M = {} + +M.setup = function(on_attach, capabilities) + require("typescript").setup({ + server = { + capabilities = capabilities, + on_attach = function(client, bufnr) + on_attach(client, bufnr) + + u.buf_map(bufnr, "n", "h", ":TypescriptOrganizeImports") + end, + }, + }) +end + +return M diff --git a/nvim/lua/lsp/utils.lua b/nvim/lua/lsp/utils.lua new file mode 100644 index 0000000..a9be8d0 --- /dev/null +++ b/nvim/lua/lsp/utils.lua @@ -0,0 +1,24 @@ +local M = {} + +M.is_path_excluded = function(bufnr, client) + local buf_path = vim.api.nvim_buf_get_name(bufnr) + local excluded_paths = {} + local success, custom = pcall(require, "custom") + if success then + excluded_paths = custom.excluded_paths[client.name] + end + local is_excluded = false + + if excluded_paths ~= nil then + for i = 1, #excluded_paths do + if buf_path:find("^" .. excluded_paths[i]) ~= nil then + is_excluded = true + break + end + end + end + + return is_excluded +end + +return M diff --git a/nvim/lua/mappings.lua b/nvim/lua/mappings.lua new file mode 100644 index 0000000..90b056c --- /dev/null +++ b/nvim/lua/mappings.lua @@ -0,0 +1,36 @@ +-- {{@@ header() @@}} + +local map = require("utils").map + +-- set leader key +vim.g.mapleader = "," + +-- Remap ; to : +map("n", ";", ":") + +-- jk to return to normal mode +map({ "i", "v" }, "jk", "") + +-- tab navigation +map("n", "H", ":tabprevious") +map("n", "L", ":tabnext") +map("n", "T", ":tabnew") +map("n", "C", ":tabclose") + +-- Map Alt+Arrows to move lines +map("n", "", ":m-2 ==") +map("n", "", ":m+ ==") +map("v", "", ":m '<-2gv=gv") +map("v", "", ":m '>+1gv=gv") + +-- Resize buffer size +map("n", "", "2-") +map("n", "", "2+") +map("n", "", "2<") +map("n", "", "2>") + +-- Fold +map("n", "", "za") + +--[[ map('n', 'n', ':cnext') +map('n', 'N', ':cprev') ]] diff --git a/nvim/lua/options.lua b/nvim/lua/options.lua new file mode 100644 index 0000000..14bde8a --- /dev/null +++ b/nvim/lua/options.lua @@ -0,0 +1,58 @@ +-- {{@@ header() @@}} + +local opt = vim.opt + +vim.o.autochdir = false + +opt.wildignorecase = true -- Make filenames autocompletion case-insensitive + +opt.ignorecase = true -- Make search case insensitive if all lowercase +opt.smartcase = true -- No ignore case when pattern has uppercase + +opt.syntax = "enable" -- Enables syntax highlighing +opt.wrap = false -- Display long lines as just one line + +opt.foldlevel = 99 +opt.foldlevelstart = 99 -- Minimum number of screen line below and above the cursor +opt.foldenable = true +opt.colorcolumn = "79" + +opt.termguicolors = true -- Set colorscheme + +opt.scrolloff = 99 -- Minimum number of line above and below the cursor line +opt.timeoutlen = 200 -- Shorten key sequence timeout + +opt.clipboard = "unnamedplus" -- Copy paste between vim and everything else + +-- Splits +opt.splitbelow = true +opt.splitright = true + +opt.tabstop = 2 -- Number of spaces that in files uses +opt.shiftwidth = 2 -- Number of spaces to use fir (auto)indent step +opt.expandtab = true -- Use spaces when is inserted +opt.autoindent = true -- Take indent for new line from previous line + +opt.wrap = true + +opt.fixeol = false + +opt.number = true -- Print the line number in front of each line +opt.cursorline = true -- Highligh the screen line of the cursor + +opt.signcolumn = "yes" -- Always display signcolumn + +opt.wildignore = opt.wildignore + "*.o,*.gcno,*.gcda" -- Files matching these patterns are not completed + +-- set relative number +opt.relativenumber = true + +vim.o.shell = "/usr/bin/env bash" + +vim.o.cmdheight = 1 +vim.o.laststatus = 0 + +-- vim.o.mouse = vim.o.mouse .. "a" +vim.o.mouse = "" + +-- vim.o.equalalways = false -- splitted windows are not always the same size diff --git a/nvim/lua/plugins/coding.lua b/nvim/lua/plugins/coding.lua new file mode 100644 index 0000000..b721d7d --- /dev/null +++ b/nvim/lua/plugins/coding.lua @@ -0,0 +1,202 @@ +return { + -- {%@@ if profile != "lukac" @@%} + + { "b0o/schemastore.nvim" }, + + { + "neovim/nvim-lspconfig", + event = "BufReadPre", + dependencies = { + { "weilbith/nvim-code-action-menu", cmd = "CodeActionMenu" }, + "jose-elias-alvarez/null-ls.nvim", + "jose-elias-alvarez/typescript.nvim", + "simrat39/rust-tools.nvim", + "hrsh7th/cmp-nvim-lsp", + }, + }, + + { + "j-hui/fidget.nvim", + tag = "legacy", + event = "BufReadPre", + opts = {} + }, + + --[[ { + "L3MON4D3/LuaSnip", + version = ".*", + config = function() + require("luasnip.loaders.from_vscode").lazy_load({ paths = { "~/.config/nvim/snippets/" } }) + end, + keys = { + { + "", + function() + require("luasnip").jump(1) + end, + mode = "i", + }, + { + "", + function() + require("luasnip").jump(-1) + end, + mode = "i", + }, + }, + }, ]] + + { + "hrsh7th/vim-vsnip", + config = function() + vim.g.vsnip_snippet_dir = "~/.config/nvim/snippets" + + local map = require("utils").map + local options = { expr = true, noremap = true } + + map("i", "", 'vsnip#jumpable(1) ? "(vsnip-jump-next)" : ""', options) + map("s", "", 'vsnip#jumpable(1) ? "(vsnip-jump-next)" : ""', options) + map("s", "", 'vsnip#jumpable(-1) ? "(vsnip-jump-prev)" : ""', options) + map("i", "", 'vsnip#jumpable(-1) ? "(vsnip-jump-prev)" : ""', options) + end, + }, + + -- Autocompletion + { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-path", + "hrsh7th/cmp-vsnip", + -- "L3MON4D3/LuaSnip", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-nvim-lsp", + "onsails/lspkind-nvim", + }, + init = function(_) + local highlight = require("utils").highlight + local colors = require("highlights").colors + local cmp = require("cmp") + local lspkind = require("lspkind") + + highlight("CmpItemAbbrDeprecated", { style = "strikethrough", fg = colors.grey }) + + highlight("CmpItemAbbrMatch", { bg = "NONE", fg = colors.picton_blue }) + highlight("CmpItemAbbrMatchFuzzy", { bg = "NONE", fg = colors.picton_blue }) + + highlight("CmpItemKindVariable", { bg = "NONE", fg = colors.columbia_blue }) + highlight("CmpItemKindInterface", { bg = "NONE", fg = colors.columbia_blue }) + highlight("CmpItemKindText", { bg = "NONE", fg = colors.columbia_blue }) + + highlight("CmpItemKindFunction", { bg = "NONE", fg = colors.lilac }) + highlight("CmpItemKindMethod", { bg = "NONE", fg = colors.lilac }) + + highlight("CmpItemKindKeyword", { bg = "NONE", fg = colors.light_grey }) + highlight("CmpItemKindProperty", { bg = "NONE", fg = colors.light_grey }) + highlight("CmpItemKindUnit", { bg = "NONE", fg = colors.light_grey }) + + vim.opt.completeopt = { "menuone", "noselect" } + -- Remove cmp status display + vim.opt.shortmess:append("c") + end, + opts = function() + local cmp = require("cmp") + local lspkind = require("lspkind") + -- local luasnip = require("luasnip") + + return { + snippet = { + expand = function(args) + -- luasnip.lsp_expand(args.body) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + + mapping = { + [""] = cmp.mapping.complete({ + config = { + sources = { + { name = "nvim_lsp" }, + -- { name = "LuaSnip" }, + { name = "vsnip" }, + { name = "path" }, + { name = "buffer" }, + }, + }, + }), + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.select_prev_item(), + }, + + sources = { + { name = "nvim_lsp" }, + -- { name = "LuaSnip" }, + { name = "vsnip" }, + { name = "path" }, + { name = "buffer" }, + }, + + formatting = { + format = lspkind.cmp_format({ + mode = "symbol", + maxwidth = "50", + + symbol_map = { + Text = "", + Method = "", + Function = "", + Constructor = "", + Field = "ﴲ", + Variable = "[]", + Class = "", + Interface = "ﰮ", + Module = "", + Property = "襁", + Unit = "", + Value = "", + Enum = "練", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "ﲀ", + Struct = "ﳤ", + Event = "", + Operator = "", + TypeParameter = "", + }, + }), + }, + } + end, + }, + + -- Symbol tree + { "simrat39/symbols-outline.nvim", keys = { { "s", "SymbolsOutlineOpen" } }, opts = {} }, + { "JoosepAlviste/nvim-ts-context-commentstring", lazy = true }, + + { + "numToStr/Comment.nvim", + opts = { + ignore = "^$", + toggler = { + line = "/", + }, + }, + }, + + { + "MunifTanjim/prettier.nvim", + opts = { + single_quote = true, + print_width = 100, + jsx_single_quote = true, + bracket_same_line = true, + } + } +} diff --git a/nvim/lua/plugins/colorscheme.lua b/nvim/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..584a6cd --- /dev/null +++ b/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,45 @@ +return { + { + "Mofiqul/vscode.nvim", + priority = 1000, + opts = { + transparent = true, + italic_comments = true, + color_overrides = { + vscLineNumber = "#D7BA7D", + vscFoldBackground = "#202d39", + -- Syntax colors + vscGray = "#808080", + vscViolet = "#646695", + vscBlue = "#569CD6", + vscAccentBlue = "#4FC1FE", + vscDarkBlue = "#223E55", + vscMediumBlue = "#18a2fe", + vscLightBlue = "#9CDCFE", + vscGreen = "#808080", + vscBlueGreen = "#4EC9B0", + vscLightGreen = "#B5CEA8", + vscRed = "#F44747", + vscOrange = "#CE9178", + vscLightRed = "#D16969", + vscYellowOrange = "#D7BA7D", + vscYellow = "#DCDCAA", + vscDarkYellow = "#FFA602", + vscPink = "#C586C0", + }, + group_overrides = { + -- this supports the same val table as vim.api.nvim_set_hl + -- use colors from this colorscheme by requiring vscode.colors! + Cursor = { + fg = "#646695", + bg = "#B5CEA8", + bold = false, + }, + }, + }, + config = function(plugin, opts) + require("vscode").setup(opts) + require("vscode").load() + end, + }, +} diff --git a/nvim/lua/plugins/documentation.lua b/nvim/lua/plugins/documentation.lua new file mode 100644 index 0000000..764b72d --- /dev/null +++ b/nvim/lua/plugins/documentation.lua @@ -0,0 +1,9 @@ +return { + { + "danymat/neogen", + dependencies = "nvim-treesitter/nvim-treesitter", + config = true, + -- Uncomment next line if you want to follow only stable versions + -- version = "*" + } +} diff --git a/nvim/lua/plugins/editor.lua b/nvim/lua/plugins/editor.lua new file mode 100644 index 0000000..cffa20c --- /dev/null +++ b/nvim/lua/plugins/editor.lua @@ -0,0 +1,284 @@ +local utils = require("utils") + +return { + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v2.x", + cmd = "Neotree", + dependencies = { + { "nvim-lua/plenary.nvim" }, + { "nvim-tree/nvim-web-devicons" }, + { "MunifTanjim/nui.nvim" }, + { + "s1n7ax/nvim-window-picker", + tag = "v1.5", + opts = function() + local colors = require("highlights").colors + + return { + autoselect_one = true, + include_current = true, + filter_rules = { + bo = { + filetype = { "neo-tree", "neo-tree-popup", "notify", "Trouble" }, + buftype = { "terminal", "quickfix" }, + }, + }, + fg_color = colors.picton_blue, + other_win_hl_color = colors.bordeaux, + } + end, + }, + }, + keys = { + { "", "Neotree toggle" }, + }, + opts = { + close_if_last_window = false, + popup_border_style = "rounded", + enable_git_status = true, + enable_diagnostics = true, + window = { + mappings = { + ["o"] = "open_with_window_picker", + }, + }, + + default_component_configs = { + indent = { + with_markers = false, + }, + name = { + use_git_status_colors = false, + }, + git_status = { + symbols = { + deleted = "", + + untracked = "*", + }, + }, + }, + + filesystem = { + hide_gitignored = true, + follow_current_file = true, + use_libuv_file_watcher = true, + always_show = { + ".clang_format", + ".clang-tidy", + }, + }, + }, + }, + + -- {%@@ if profile != "lukac" @@%} + + { + "nvim-telescope/telescope.nvim", + dependencies = { + { "nvim-lua/popup.nvim" }, + { "nvim-lua/plenary.nvim" }, + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + }, + keys = { + { "", "Telescope find_files" }, + { "§", "Telescope live_grep" }, + { "", "Telescope lsp_document_symbols" }, + { "", "Telescope current_buffer_fuzzy_find" }, + }, + init = function() + local telescope = require("telescope") + + telescope.load_extension("fzf") + end, + opts = function() + local actions = require("telescope.actions") + + return { + defaults = { + prompt_prefix = "  ", + selection_caret = " ", + entry_prefix = " ", + sorting_strategy = "ascending", + layout_strategy = "horizontal", + layout_config = { + horizontal = { + prompt_position = "top", + preview_width = 0.55, + results_width = 0.8, + }, + vertical = { + mirror = false, + }, + width = 0.80, + height = 0.85, + preview_cutoff = 120, + }, + mappings = { + i = { + [""] = actions.move_selection_previous, + [""] = actions.move_selection_next, + [""] = actions.close, + }, + }, + }, + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + }, + }, + file_ignore_patterns = { + "nodes_modules/.*", + ".git/.*", + "target/.*", + ".yarn", + }, + } + end, + }, + + { "tpope/vim-fugitive" }, + { + "lewis6991/gitsigns.nvim", + event = "BufReadPre", + dependencies = { + "nvim-lua/plenary.nvim", + }, + config = function(_, opts) + local highlight = require("utils").highlight + local colors = require("highlights").colors + + highlight("GitSignsAddNr", { bg = colors.clover, fg = "NONE" }) + highlight("GitSignsChangeNr", { bg = colors.raw_umber, fg = "NONE" }) + highlight("GitSignsDeleteNr", { bg = colors.bordeaux, fg = "NONE" }) + + require("gitsigns").setup(opts) + end, + + opts = { + signs = { + add = { numhl = "GitSignsAddNr" }, + change = { numhl = "GitSignsChangeNr" }, + delete = { numhl = "GitSignsDeleteNr" }, + topdelete = { numhl = "GitSignsDeleteNr" }, + changedelete = { numhl = "GitSignsChangeNr" }, + }, + signcolumn = false, + numhl = true, + linehl = false, + word_diff = false, + watch_gitdir = { + interval = 1000, + follow_files = true, + }, + attach_to_untracked = true, + current_line_blame = true, + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + local buf_map = require("utils").buf_map + + buf_map(bufnr, "n", "g", function() + gs.blame_line({ full = true }) + end) + end, + }, + }, + + { + "iamcco/markdown-preview.nvim", + config = function() + vim.fn["mkdp#util#install"]() + end, + }, + -- { "iamcco/markdown-preview.nvim" }, + { "ellisonleao/glow.nvim", config = true, cmd = "Glow" }, + + { + "folke/todo-comments.nvim", + dependencies = "nvim-lua/plenary.nvim", + opts = { + signs = true, + sign_priority = 8, + keywords = { + FIX = { + icon = " ", + color = "error", + alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, + }, + TODO = { icon = " ", color = "info" }, + HACK = { icon = " ", color = "warning" }, + WARN = { icon = " ", color = "warning", alt = { "WARNING", "XXX" } }, + PERF = { icon = " ", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } }, + NOTE = { icon = " ", color = "hint", alt = { "INFO" } }, + }, + merge_keywords = true, + highlight = { + before = "", + keyword = "wide", + after = "fg", + pattern = [[.*<(KEYWORDS)\s*]], + comments_only = true, + max_line_len = 400, + }, + colors = { + error = { "LspDiagnosticsDefaultError", "ErrorMsg", "#DC2626" }, + warning = { "LspDiagnosticsDefaultWarning", "WarningMsg", "#FBBF24" }, + info = { "LspDiagnosticsDefaultInformation", "#2563EB" }, + hint = { "LspDiagnosticsDefaultHint", "#10B981" }, + default = { "Identifier", "#7C3AED" }, + }, + search = { + command = "rg", + args = { + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + }, + pattern = [[\b(KEYWORDS)]], -- ripgrep regex + }, + }, + }, + + { + "folke/trouble.nvim", + dependencies = "nvim-tree/nvim-web-devicons", + opts = { + + use_diagnostic_signs = true, + }, + }, + + { + "kevinhwang91/nvim-ufo", + dependencies = { "kevinhwang91/promise-async" }, + init = function() + local bufnr = vim.api.nvim_get_current_buf() + require("ufo").setFoldVirtTextHandler(bufnr, utils.fold_handler) + end, + opts = { + open_fold_hl_timeout = 100, + provider_selector = function(bufnr, filetype, buftype) + return { "treesitter", "indent" } + end, + fold_virt_text_handler = utils.fold_handler, + }, + }, + + { "junegunn/vim-easy-align" }, + { "wesQ3/vim-windowswap" }, + + -- {%@@ endif @@%} + + { + "ntpeters/vim-better-whitespace", + event = "BufReadPre", + keys = { + { "", "StripWhitespace" }, + }, + }, +} diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/nvim/lua/plugins/init.lua @@ -0,0 +1 @@ +return {} diff --git a/nvim/lua/plugins/misc.lua b/nvim/lua/plugins/misc.lua new file mode 100644 index 0000000..46eb96d --- /dev/null +++ b/nvim/lua/plugins/misc.lua @@ -0,0 +1,35 @@ +--[[ local utils = require("utils") + +return { + { + "andweeb/presence.nvim", + config = function(plugin, opts) + -- The setup config table shows all available config options with their default values: + require("presence").setup({ + -- General options + auto_update = true, -- Update activity based on autocmd events (if `false`, map or manually execute `:lua package.loaded.presence:update()`) + neovim_image_text = "The One True Text Editor", -- Text displayed when hovered over the Neovim image + main_image = "neovim", -- Main image display (either "neovim" or "file") + client_id = "793271441293967371", -- Use your own Discord application client id (not recommended) + log_level = nil, -- Log messages at or above this level (one of the following: "debug", "info", "warn", "error") + debounce_timeout = 10, -- Number of seconds to debounce events (or calls to `:lua package.loaded.presence:update(, true)`) + enable_line_number = false, -- Displays the current line number instead of the current project + blacklist = {}, -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches + buttons = true, -- Configure Rich Presence button(s), either a boolean to enable/disable, a static table (`{{ label = "