From e8653392c725e51ffbe6d2f17593e4b82b90f6c7 Mon Sep 17 00:00:00 2001 From: qugalet Date: Fri, 29 Nov 2024 20:35:44 +0200 Subject: [PATCH] sync --- after/ftplugin/gohtmltmpl.vim | 10 + after/ftplugin/markdown.lua | 5 + after/ftplugin/tex.lua | 1 + after/plugin/ftplugin/markdown.lua | 0 after/plugin/lsp.lua | 22 +- after/plugin/{lualine.lua => lualine.lua.bak} | 0 after/plugin/statusline.lua | 195 ++++++++++++++++++ after/plugin/treesitter.lua | 4 +- lazy-lock.json | 56 +++-- lua/qvim/plugins.lua | 56 ++++- lua/qvim/remap.lua | 3 - 11 files changed, 316 insertions(+), 36 deletions(-) create mode 100644 after/ftplugin/gohtmltmpl.vim create mode 100644 after/ftplugin/markdown.lua create mode 100644 after/ftplugin/tex.lua delete mode 100644 after/plugin/ftplugin/markdown.lua rename after/plugin/{lualine.lua => lualine.lua.bak} (100%) create mode 100644 after/plugin/statusline.lua diff --git a/after/ftplugin/gohtmltmpl.vim b/after/ftplugin/gohtmltmpl.vim new file mode 100644 index 0000000..5d92af1 --- /dev/null +++ b/after/ftplugin/gohtmltmpl.vim @@ -0,0 +1,10 @@ +function DetectGoHtmlTmpl() + if expand('%:e') == "html" && search("{{") != 0 + setfiletype gohtmltmpl + endif +endfunction + +augroup filetypedetect + " gohtmltmpl + au BufRead,BufNewFile *.html call DetectGoHtmlTmpl() +augroup END diff --git a/after/ftplugin/markdown.lua b/after/ftplugin/markdown.lua new file mode 100644 index 0000000..307dda7 --- /dev/null +++ b/after/ftplugin/markdown.lua @@ -0,0 +1,5 @@ +vim.keymap.set("n", "j", "gj") +vim.keymap.set("n", "k", "gk") + +vim.cmd([[set wrap]]) +vim.cmd([[set linebreak]]) diff --git a/after/ftplugin/tex.lua b/after/ftplugin/tex.lua new file mode 100644 index 0000000..97209fb --- /dev/null +++ b/after/ftplugin/tex.lua @@ -0,0 +1 @@ +vim.opt_local.textwidth = 80 diff --git a/after/plugin/ftplugin/markdown.lua b/after/plugin/ftplugin/markdown.lua deleted file mode 100644 index e69de29..0000000 diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua index b84943f..e70f1b3 100644 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -1,7 +1,8 @@ +require('java').setup() + local lsp_zero = require("lsp-zero") local lspconfig = require("lspconfig") - lsp_zero.on_attach(function(client, bufnr) -- see :help lsp-zero-keybindings -- to learn the available actions @@ -64,7 +65,7 @@ end) vim.filetype.add({ extension = { templ = "templ" } }) -lsp_zero.setup_servers({ "gopls", "lua_ls", "nil_ls", "pylsp", "clangd" }) +lsp_zero.setup_servers({ "gopls", "lua_ls", "nil_ls", "pylsp", "clangd", "jdtls" }) lspconfig.html.setup { cmd = { "vscode-html-language-server", "--stdio" }, @@ -136,6 +137,7 @@ lspconfig.lua_ls.setup({ -- }) local cmp = require("cmp") +local lspkind = require("lspkind") local cmp_action = require("lsp-zero").cmp_action() local cmp_select = { behavior = cmp.SelectBehavior.Select } @@ -166,9 +168,17 @@ cmp.setup({ end, }, sources = { - { name = 'path' }, - { name = 'nvim_lsp', keyword_length = 1 }, - { name = 'vim-dadbod-completion', keyword_length = 1 }, - { name = 'buffer', keyword_length = 3 }, + { name = "copilot", group_index = 2 }, + -- Other Sources + { name = "nvim_lsp", group_index = 2, keyword_length = 1 }, + { name = "path", group_index = 2 }, + { name = "luasnip", group_index = 2 }, + }, + formatting = { + format = lspkind.cmp_format({ + mode = "symbol", + max_width = 50, + symbol_map = { Copilot = "" } + }) } }) diff --git a/after/plugin/lualine.lua b/after/plugin/lualine.lua.bak similarity index 100% rename from after/plugin/lualine.lua rename to after/plugin/lualine.lua.bak diff --git a/after/plugin/statusline.lua b/after/plugin/statusline.lua new file mode 100644 index 0000000..2da99b7 --- /dev/null +++ b/after/plugin/statusline.lua @@ -0,0 +1,195 @@ +local modes = { + ["n"] = "NORMAL", + ["no"] = "NORMAL", + ["v"] = "VISUAL", + ["V"] = "VISUAL LINE", + [""] = "VISUAL BLOCK", + ["s"] = "SELECT", + ["S"] = "SELECT LINE", + [""] = "SELECT BLOCK", + ["i"] = "INSERT", + ["ic"] = "INSERT", + ["R"] = "REPLACE", + ["Rv"] = "VISUAL REPLACE", + ["c"] = "COMMAND", + ["cv"] = "VIM EX", + ["ce"] = "EX", + ["r"] = "PROMPT", + ["rm"] = "MOAR", + ["r?"] = "CONFIRM", + ["!"] = "SHELL", + ["t"] = "TERMINAL", +} + +local function mode() + local current_mode = vim.api.nvim_get_mode().mode + return string.format(" %s ", modes[current_mode]):upper() +end + +local hlgroups = { + Statusline = { bg = "#282828" }, + StatuslineAccent = { fg = "#282828", bg = "#ebdbb2" }, + StatuslineInsertAccent = { fg = "#ebdbb2", bg = "#83a598" }, + StatuslineVisualAccent = { fg = "#ebdbb2", bg = "#d65d0e" }, + StatuslineReplaceAccent = { fg = "#ebdbb2", bg = "#fb4934" }, + StatuslineCmdLineAccent = { fg = "#ebdbb2", bg = "#b8bb26" }, + StatusLineExtra = { fg = "#ebdbb2", bg = "#665c54" }, + StatusLineNC = { fg = "#ebdbb2", bg = "#282828" }, + LspDiagnosticsSignError = { fg = "#cc241d", bg = "#282828" }, + LspDiagnosticsSignWarning = { fg = "#d79921", bg = "#282828" }, + LspDiagnosticsSignHint = { fg = "#ebdbb2", bg = "#282828" }, + LspDiagnosticsSignInformation = { fg = "#ebdbb2", bg = "#282828" }, + GitSignsAdd = { fg = "#ebdbb2", bg = "#282828" }, + GitSignsChange = { fg = "#ebdbb2", bg = "#282828" }, + GitSignsDelete = { fg = "#ebdbb2", bg = "#282828" }, +} + +for hlgroup_name, hlgroup_attr in pairs(hlgroups) do + vim.api.nvim_set_hl(0, hlgroup_name, hlgroup_attr) +end + +local function update_mode_colors() + local current_mode = vim.api.nvim_get_mode().mode + local mode_color = "%#StatusLineAccent#" + if current_mode == "n" then + mode_color = "%#StatuslineAccent#" + elseif current_mode == "i" or current_mode == "ic" then + mode_color = "%#StatuslineInsertAccent#" + elseif current_mode == "v" or current_mode == "V" or current_mode == "" then + mode_color = "%#StatuslineVisualAccent#" + elseif current_mode == "R" then + mode_color = "%#StatuslineReplaceAccent#" + elseif current_mode == "c" then + mode_color = "%#StatuslineCmdLineAccent#" + elseif current_mode == "t" then + mode_color = "%#StatuslineTerminalAccent#" + end + return mode_color +end + +local function filepath() + local fpath = vim.fn.fnamemodify(vim.fn.expand "%", ":~:.:h") + if fpath == "" or fpath == "." then + return " " + end + + return string.format(" %%<%s/", fpath) +end + +local function filename() + local fname = vim.fn.expand "%:t" + if fname == "" then + return "" + end + return fname .. " " +end + +local function lsp() + local count = {} + local levels = { + errors = "Error", + warnings = "Warn", + info = "Info", + hints = "Hint", + } + + for k, level in pairs(levels) do + count[k] = vim.tbl_count(vim.diagnostic.get(0, { severity = level })) + end + + local errors = "" + local warnings = "" + local hints = "" + local info = "" + + if count["errors"] ~= 0 then + errors = " %#LspDiagnosticsSignError# " .. count["errors"] + end + if count["warnings"] ~= 0 then + warnings = " %#LspDiagnosticsSignWarning# " .. count["warnings"] + end + if count["hints"] ~= 0 then + hints = " %#LspDiagnosticsSignHint# " .. count["hints"] + end + if count["info"] ~= 0 then + info = " %#LspDiagnosticsSignInformation# " .. count["info"] + end + + return errors .. warnings .. hints .. info .. "%#Statusline#" +end + +local function filetype() + return string.format(" %s ", vim.bo.filetype):upper() +end + +local function lineinfo() + if vim.bo.filetype == "alpha" then + return "" + end + return " %P %l:%c " +end + +local vcs = function() + local git_info = vim.b.gitsigns_status_dict + if not git_info or git_info.head == "" then + return "" + end + local added = git_info.added and ("%#GitSignsAdd#+" .. git_info.added .. " ") or "" + local changed = git_info.changed and ("%#GitSignsChange#~" .. git_info.changed .. " ") or "" + local removed = git_info.removed and ("%#GitSignsDelete#-" .. git_info.removed .. " ") or "" + if git_info.added == 0 then + added = "" + end + if git_info.changed == 0 then + changed = "" + end + if git_info.removed == 0 then + removed = "" + end + return table.concat { + " ", + added, + changed, + removed, + " ", + "%#GitSignsAdd# ", + git_info.head, + " %#Statusline#", + } +end + +Statusline = {} + +Statusline.active = function() + return table.concat { + "%#Statusline#", + update_mode_colors(), + mode(), + "%#StatusLineNC# ", + filepath(), + filename(), + "%#StatusLineNC#", + lsp(), + vcs(), + "%=%#StatusLineExtra#", + filetype(), + lineinfo(), + } +end + +function Statusline.inactive() + return " %F" +end + +function Statusline.short() + return "%#StatusLineNC#  NvimTree" +end + +vim.api.nvim_exec([[ + augroup Statusline + au! + au WinEnter,BufEnter * setlocal statusline=%!v:lua.Statusline.active() + au WinLeave,BufLeave * setlocal statusline=%!v:lua.Statusline.inactive() + au WinEnter,BufEnter,FileType NvimTree setlocal statusline=%!v:lua.Statusline.short() + augroup END +]], false) diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua index 6bb41e5..fd6adf0 100644 --- a/after/plugin/treesitter.lua +++ b/after/plugin/treesitter.lua @@ -1,4 +1,4 @@ -require'nvim-treesitter.configs'.setup { +require 'nvim-treesitter.configs'.setup { -- A list of parser names, or "all" (the five listed parsers should always be installed) ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "python", "go" }, @@ -19,3 +19,5 @@ require'nvim-treesitter.configs'.setup { additional_vim_regex_highlighting = false, }, } + +vim.treesitter.language.register('markdown', 'vimwiki') diff --git a/lazy-lock.json b/lazy-lock.json index 8d48f63..a5aacb4 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,47 +1,59 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "LuaSnip": { "branch": "master", "commit": "e808bee352d1a6fcf902ca1a71cee76e60e24071" }, + "LuaSnip": { "branch": "master", "commit": "659c4479529a05cc9b05ef762639a09d366cc690" }, "auto-pairs": { "branch": "master", "commit": "39f06b873a8449af8ff6a3eee716d3da14d63a76" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, - "conform.nvim": { "branch": "master", "commit": "40d4e98fcc3e6f485f0e8924c63734bc7e305967" }, + "conform.nvim": { "branch": "master", "commit": "023f795dbcf32d4351b6a9ed2e613d471b5bb812" }, + "copilot-cmp": { "branch": "master", "commit": "b6e5286b3d74b04256d0a7e3bd2908eabec34b44" }, + "copilot.lua": { "branch": "master", "commit": "f8d8d872bb319f640d5177dad5fbf01f7a16d7d0" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "firenvim": { "branch": "master", "commit": "64f9389b88c8b0c7667d45c171a5f25c42d852fb" }, - "gitsigns.nvim": { "branch": "main", "commit": "863903631e676b33e8be2acb17512fdc1b80b4fb" }, - "go.nvim": { "branch": "master", "commit": "fb612d13c34d3d1d2caa4d5785733abe70dc22f0" }, + "gitsigns.nvim": { "branch": "main", "commit": "ac5aba6dce8c06ea22bea2c9016f51a2dbf90dc7" }, + "go.nvim": { "branch": "master", "commit": "6368756601a358b1491ac2ff10d0e2939a76df5e" }, "gruvbox.nvim": { "branch": "main", "commit": "49d9c0b150ba70efcd831ec7b3cb8ee740067045" }, - "guihua.lua": { "branch": "master", "commit": "225db770e36aae6a1e9e3a65578095c8eb4038d3" }, - "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, - "indent-blankline.nvim": { "branch": "master", "commit": "e7a4442e055ec953311e77791546238d1eaae507" }, + "guihua.lua": { "branch": "master", "commit": "d783191eaa75215beae0c80319fcce5e6b3beeda" }, + "harpoon": { "branch": "harpoon2", "commit": "a84ab829eaf3678b586609888ef52f7779102263" }, + "indent-blankline.nvim": { "branch": "master", "commit": "7871a88056f7144defca9c931e311a3134c5d509" }, "inlay-hints.nvim": { "branch": "master", "commit": "af84dee42cd118af6d592b06c1c0e45d6432a6c0" }, - "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, - "lsp-zero.nvim": { "branch": "v3.x", "commit": "56db3d5ce5476b183783160e6045f7337ba12b83" }, + "lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" }, + "lsp-zero.nvim": { "branch": "v3.x", "commit": "ab2a3413646fedd77aa0eab4214a6473e62f6a64" }, "lsp_signature.nvim": { "branch": "master", "commit": "fc38521ea4d9ec8dbd4c2819ba8126cea743943b" }, - "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" }, + "lspkind.nvim": { "branch": "master", "commit": "a700f1436d4a938b1a1a93c9962dc796afbaef4d" }, + "lua-async-await": { "branch": "main", "commit": "652d94df34e97abe2d4a689edbc4270e7ead1a98" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.nvim": { "branch": "main", "commit": "0a8a1072137d916406507c941698a4bfa9dbbe7a" }, + "mini.icons": { "branch": "main", "commit": "54686be7d58807906cb2c8c2216e0bf9c044f19a" }, + "mini.nvim": { "branch": "main", "commit": "7b4d5d48b6b5a75009d63f8f3e4ef4819b7e8139" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" }, - "neogit": { "branch": "master", "commit": "001f43f50d9589d837cec59004fd92486ab06870" }, + "neogit": { "branch": "master", "commit": "89d13fb9898619774d359a3900959181d60dd02f" }, "no-neck-pain.nvim": { "branch": "main", "commit": "c7efdbd0b739646c58d22fa44f6fffa2973f303e" }, "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, - "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, - "nvim-dap": { "branch": "master", "commit": "7ff6936010b7222fea2caea0f67ed77f1b7c60dd" }, - "nvim-dap-python": { "branch": "master", "commit": "03fe9592409236b9121c03b66a682dfca15a5cac" }, + "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, + "nvim-dap": { "branch": "master", "commit": "6bf4de67dbe90271608e1c81797e5edc79ec6335" }, + "nvim-dap-python": { "branch": "master", "commit": "3e3dd98d4d83715c9e0e429b4a5da7bd706e6ceb" }, "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, - "nvim-lspconfig": { "branch": "master", "commit": "b1de227da4ca6baf6ba865bec75917e4b4053844" }, + "nvim-java": { "branch": "main", "commit": "905013eb83c58bda992724b3ecbe20f60b58513f" }, + "nvim-java-core": { "branch": "main", "commit": "5b03dca22fee76524a89e1c2dc1d73a9f0b1a3bb" }, + "nvim-java-dap": { "branch": "main", "commit": "55f239532f7a3789d21ea68d1e795abc77484974" }, + "nvim-java-refactor": { "branch": "main", "commit": "ea1420fed5463c9cc976c2b4175f434b3646f0f7" }, + "nvim-java-test": { "branch": "main", "commit": "7f0f40e9c5b7eab5096d8bec6ac04251c6e81468" }, + "nvim-lspconfig": { "branch": "master", "commit": "d2d153a179ed59aa7134d7ebdf4d7dcb156efa22" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-notify": { "branch": "master", "commit": "fbef5d32be8466dd76544a257d3f3dce20082a07" }, - "nvim-treesitter": { "branch": "master", "commit": "5a2ff8b7ca5470b1011ed82ef3fdd53139ffc467" }, + "nvim-treesitter": { "branch": "master", "commit": "6389ceb1758b8f62a15194e3b790e33268304cb8" }, "nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" }, "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, + "oil.nvim": { "branch": "master", "commit": "21705a1debe6d85a53c138ab944484b685432b2b" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, - "telescope.nvim": { "branch": "master", "commit": "df534c3042572fb958586facd02841e10186707c" }, + "render-markdown.nvim": { "branch": "main", "commit": "634acd5da964c32f6947cd0c7802d7a116662665" }, + "spring-boot.nvim": { "branch": "main", "commit": "218c0c26c14d99feca778e4d13f5ec3e8b1b60f0" }, + "telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" }, "undotree": { "branch": "master", "commit": "78b5241191852ffa9bb5da5ff2ee033160798c3b" }, "vim-fugitive": { "branch": "master", "commit": "d4877e54cef67f5af4f950935b1ade19ed6b7370" }, - "vim-tmux-navigator": { "branch": "master", "commit": "a9b52e7d36114d40350099f254b5f299a35df978" }, - "vimtex": { "branch": "master", "commit": "ded1d899afa51f42b71bed607680e21338d18c74" }, + "vim-tmux-navigator": { "branch": "master", "commit": "424b5caa154bff34dc258ee53cec5a8e36cf7ea8" }, + "vimtex": { "branch": "master", "commit": "6ee92c7ed2cdc876f499bd5561a65d04dee10d1f" }, "vimwiki": { "branch": "dev", "commit": "72792615e739d0eb54a9c8f7e0a46a6e2407c9e8" }, - "which-key.nvim": { "branch": "main", "commit": "8badb359f7ab8711e2575ef75dfe6fbbd87e4821" }, + "which-key.nvim": { "branch": "main", "commit": "68e37e12913a66b60073906f5d3f14dee0de19f2" }, "window-picker": { "branch": "main", "commit": "41cfaa428577c53552200a404ae9b3a0b5719706" }, "xkbswitch.nvim": { "branch": "master", "commit": "1e14fe0ff9e11ff1671c9db30a8702d9d21f3816" } } diff --git a/lua/qvim/plugins.lua b/lua/qvim/plugins.lua index 8244c2b..4bd6773 100644 --- a/lua/qvim/plugins.lua +++ b/lua/qvim/plugins.lua @@ -71,10 +71,10 @@ return { config = true }, - { - "nvim-lualine/lualine.nvim", - dependencies = { "nvim-tree/nvim-web-devicons", lazy = true }, - }, + -- { + -- "nvim-lualine/lualine.nvim", + -- dependencies = { "nvim-tree/nvim-web-devicons", lazy = true }, + -- }, { "lukas-reineke/indent-blankline.nvim", @@ -131,6 +131,25 @@ return { }, }, + "onsails/lspkind.nvim", + + { + "zbirenbaum/copilot.lua", + cmd = "Copilot", + event = "InsertEnter", + config = { + suggestion = { enabled = false }, + panel = { enabled = false }, + } + }, + + { + "zbirenbaum/copilot-cmp", + config = function() + require("copilot_cmp").setup() + end, + }, + { "rcarriga/nvim-dap-ui", dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" } }, { "mfussenegger/nvim-dap-python", dependencies = { "mfussenegger/nvim-dap" } }, @@ -190,11 +209,26 @@ return { end }, + { + 'MeanderingProgrammer/render-markdown.nvim', + dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.nvim' }, -- if you use the mini.nvim suite + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons + ---@module 'render-markdown' + ---@type render.md.UserConfig + opts = { + filetypes = { 'markdown', 'vimwiki' }, + }, + }, + { 'glacambre/firenvim', build = ":call firenvim#install(0)" }, -- html "windwp/nvim-ts-autotag", + -- java + 'nvim-java/nvim-java', + { "lervag/vimtex", lazy = false, -- we don't want to lazy load VimTeX @@ -215,5 +249,19 @@ return { config = function() require("inlay-hints").setup() end + }, + + { + 'stevearc/oil.nvim', + ---@module 'oil' + ---@type oil.SetupOpts + opts = {}, + config = function() + require('oil').setup() + vim.keymap.set("n", "", "Oil", { desc = "Open parent directory" }) + end, + -- Optional dependencies + dependencies = { { "echasnovski/mini.icons", opts = {} } }, + -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if prefer nvim-web-devicons } } diff --git a/lua/qvim/remap.lua b/lua/qvim/remap.lua index 4193561..e07cd51 100644 --- a/lua/qvim/remap.lua +++ b/lua/qvim/remap.lua @@ -15,6 +15,3 @@ vim.keymap.set("x", "p", "\"_dP") vim.keymap.set("v", ">", ">gv") vim.keymap.set("v", "<", "