From 222b98d70bce5e1e3cc7ffbe38a20a03ebe8089a Mon Sep 17 00:00:00 2001 From: tiyn Date: Tue, 8 Aug 2023 06:10:22 +0200 Subject: [PATCH] nvim: plugins and dependencies restructured --- .config/nvim/lua/loadplugins.lua | 451 ++++++++++++------------------- .config/nvim/lua/style.lua | 41 +++ 2 files changed, 219 insertions(+), 273 deletions(-) diff --git a/.config/nvim/lua/loadplugins.lua b/.config/nvim/lua/loadplugins.lua index 9818742..3cb1d52 100644 --- a/.config/nvim/lua/loadplugins.lua +++ b/.config/nvim/lua/loadplugins.lua @@ -6,100 +6,74 @@ if not vim.loop.fs_stat(lazypath) then "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release + "--branch=stable", lazypath, }) end vim.opt.rtp:prepend(lazypath) return require("lazy").setup({ - -- indicate git diff status of line + + -- display git status per line { 'lewis6991/gitsigns.nvim', config = function() require('gitsigns').setup() - end, + end }, - -- show indentation lines (in empty lines too) + -- show indentation lines { 'lukas-reineke/indent-blankline.nvim', config = function() require("indent_blankline").setup({ show_current_context = true, - show_current_context_start = true, + show_current_context_start = true }) end, }, - -- improved java syntax highlighting - { - 'uiiaoo/java-syntax.vim', - ft = { 'java' }, - }, - - -- custom statusline + -- statusline { 'nvim-lualine/lualine.nvim', dependencies = { 'nvim-tree/nvim-web-devicons', }, config = function() require('lualine').setup({ options = { - icons_enabled = true, symbols = { error = Error_sign, warn = Warn_sign, hint = Hint_sign, - info = Info_sign, + info = Info_sign }, theme = 'tccs', component_separators = { left = '', right = '' }, - section_separators = { left = '', right = '' }, - disabled_filetypes = { - statusline = {}, - winbar = {}, - }, - ignore_focus = {}, - always_divide_middle = true, - globalstatus = false, - refresh = { - statusline = 1000, - tabline = 1000, - winbar = 1000, - } - }, - sections = { - lualine_a = { 'mode' }, - lualine_b = { 'branch', 'diff', 'diagnostics' }, - lualine_c = { 'filename' }, - lualine_x = { 'encoding', 'fileformat', 'filetype' }, - lualine_y = { 'progress' }, - lualine_z = { 'location' } + section_separators = { left = '', right = '' } }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { 'filename' }, - lualine_x = { 'location' }, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - winbar = {}, - inactive_winbar = {}, - extensions = {} }) - end, + end }, - -- show signature while typing - 'ray-x/lsp_signature.nvim', + -- show function signature while typing + { + 'ray-x/lsp_signature.nvim', + config = function() + require "lsp_signature".setup({ + bind = true, + handler_opts = { + border = "none" + }, + hint_prefix = Hint_sign, + hint_scheme = "DiagnosticSignHint" + }) + end + }, -- preview for markdown filetypes { "iamcco/markdown-preview.nvim", ft = { 'markdown' }, - build = "cd app && yarn install", + build = "cd app && yarn install" }, -- latex asynchronous pdf rendering @@ -108,13 +82,13 @@ return require("lazy").setup({ ft = { 'tex' }, config = function() vim.g.neotex_enabled = 2 - end, + end }, -- nim language support { 'zah/nim.vim', - ft = { 'nim' }, + ft = { 'nim' } }, -- automatic closing of brackets @@ -125,126 +99,134 @@ return require("lazy").setup({ end }, - -- language server protocol + -- lang server installations { - 'neovim/nvim-lspconfig', + 'williamboman/mason.nvim', dependencies = { - 'SmiteshP/nvim-navbuddy', - 'hrsh7th/cmp-nvim-lsp', - 'onsails/lspkind-nvim', - 'SmiteshP/nvim-navic', - 'MunifTanjim/nui.nvim', + { + 'jose-elias-alvarez/null-ls.nvim', + config = function() + require("null-ls").setup({ + sources = { + require("null-ls-embedded").nls_source.with({ + filetypes = { "markdown" } + }), + require("null-ls").builtins.formatting.black, + require("null-ls").builtins.formatting.mdformat + } + }) + end + }, + { + 'jay-babu/mason-null-ls.nvim', + config = function() + -- jay-babu/mason-null-ls.nvim + require("mason-null-ls").setup({ + automatic_installation = true, + ensure_installed = { "black", "mdformat" } + }) + end + }, + 'LostNeophyte/null-ls-embedded' }, config = function() - -- hrsh7th/cmp-nvim-lsp - local cmp_nvim_lsp = require("cmp_nvim_lsp") - - -- neovim/nvim-lspconfig - local nvim_lsp = require('lspconfig') - - local servers = { "pyright", "bashls", "texlab", "nimls", "marksman" } - - -- smiteshp/nvim-navbuddy - local navbuddy = require("nvim-navbuddy") - - local attach_func = function(client, bufnr) - navbuddy.attach(client, bufnr) - end - - local capabilities = cmp_nvim_lsp.default_capabilities() - capabilities.textDocument.foldingRange = { - dynamicRegistration = false, - lineFoldingOnly = true - } - - for _, lsp in ipairs(servers) do - nvim_lsp[lsp].setup { - on_attach = attach_func, - capabilities = capabilities, - flags = { - debounce_text_changes = 150 - } + require("mason").setup({ + ui = { + icons = Install_icons } - end - require 'lspconfig'.jdtls.setup { - on_attach = attach_func, - capabilities = capabilities, - flags = { - debounce_text_changes = 150 - }, - cmd = { 'jdtls' } - } - require 'lspconfig'.lua_ls.setup { - on_attach = attach_func, - capabilities = capabilities, - settings = { - Lua = { - diagnostics = { globals = { 'vim' } }, - telemetry = { enable = false }, - }, - }, - } - end, + }) + end }, -- lang server management { - 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', dependencies = { - 'williamboman/mason-lspconfig.nvim', - 'jose-elias-alvarez/null-ls.nvim', - 'LostNeophyte/null-ls-embedded', - 'jay-babu/mason-null-ls.nvim', + 'neovim/nvim-lspconfig', + { + 'hrsh7th/cmp-nvim-lsp', + config = function() + Capabilities = require("cmp_nvim_lsp").default_capabilities() + Capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true + } + end + }, + -- navigation menu + { + 'SmiteshP/nvim-navbuddy', + config = function() + local navbuddy = require("nvim-navbuddy") + Attach_func = function(client, bufnr) + navbuddy.attach(client, bufnr) + end + end, + dependencies = { + 'SmiteshP/nvim-navic', + 'MunifTanjim/nui.nvim' + } + }, }, config = function() - -- jose-elias-alvarez/null-ls.nvim - require("null-ls").setup({ - sources = { - require("null-ls-embedded").nls_source.with({ - filetypes = { "markdown" }, - }), - require("null-ls").builtins.formatting.black, - require("null-ls").builtins.formatting.mdformat, - }, - }) - - -- williamboman/mason.nvim - require("mason").setup() - - -- williamboman/mason-lspconfig.nvim require("mason-lspconfig").setup({ automatic_setup = true, - ensure_installed = { "pyright", "bashls", "texlab", "nimls", "marksman", "jdtls", "lua_ls" } + ensure_installed = { + "bashls", + "jdtls", + "lua_ls", + "marksman", + "nimls", + "pyright", + "texlab" + } }) - - -- jay-babu/mason-null-ls.nvim - require("mason-null-ls").setup({ - automatic_installation = true, - ensure_installed = {} + require("mason-lspconfig").setup_handlers({ + function(server_name) + require('lspconfig')[server_name].setup({ + on_attach = Attach_func, + capabilities = Capabilities, + flags = { + debounce_text_changes = 150 + } + }) + end, + ["lua_ls"] = function() + require 'lspconfig'.lua_ls.setup({ + settings = { + Lua = { + diagnostics = { + globals = { 'vim' } + } + } + } + }) + end }) - end, + end }, - -- autocompletion and its sources + -- autocompletion and its sources and snippets { 'hrsh7th/nvim-cmp', dependencies = { - -- standalone cmp sources + 'nvim-lua/plenary.nvim', + 'onsails/lspkind-nvim', + -- cmp sources 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-path', 'lukas-reineke/cmp-under-comparator', - -- luasnip and cmp source - 'l3mon4d3/luasnip', - 'saadparwaiz1/cmp_luasnip', - -- dependencies - 'nvim-lua/plenary.nvim', + -- luasnip + { + 'l3mon4d3/luasnip', + config = function() + require("luasnip.loaders.from_snipmate").lazy_load() + end, + dependencies = { 'saadparwaiz1/cmp_luasnip' } + }, }, config = function() - -- hrsh7th/nvim-cmp local cmp = require("cmp") - local luasnip = require("luasnip") - require("luasnip.loaders.from_snipmate").lazy_load() - cmp.setup { sorting = { comparators = { @@ -255,20 +237,20 @@ return require("lazy").setup({ cmp.config.compare.kind, cmp.config.compare.sort_text, cmp.config.compare.length, - cmp.config.compare.order, + cmp.config.compare.order }, }, snippet = { expand = function(args) - luasnip.lsp_expand(args.body) - end, + require("luasnip").lsp_expand(args.body) + end }, mapping = { [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) + elseif require("luasnip").jumpable(-1) then + require("luasnip").jump(-1) else fallback() end @@ -276,8 +258,8 @@ return require("lazy").setup({ [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() + elseif require("luasnip").expand_or_jumpable() then + require("luasnip").expand_or_jump() else fallback() end @@ -285,66 +267,26 @@ return require("lazy").setup({ [''] = cmp.mapping.close(), [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, - select = true, + select = true } }, sources = { { name = 'nvim_lsp' }, { name = 'path' }, { name = 'buffer' }, - { name = 'luasnip' }, + { name = 'luasnip' } }, formatting = { format = require("lspkind").cmp_format({ mode = "symbol_text", preset = "codicons", maxwidth = 50, - menu = { - nvim_lsp = "[LSP]", - path = "[PATH]", - buffer = "[BUF]", - luasnip = "[SNIP]", - }, - 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 = "" - }, - }), - }, + menu = Menu_signs, + symbol_map = Symbol_map + }) + } } - -- ray-x/lsp_signature.nvim - require "lsp_signature".setup({ - bind = true, - handler_opts = { - border = "none" - }, - hint_prefix = Hint_sign, - hint_scheme = "DiagnosticSignHint", - }) - end, + end }, -- fix for cursorhold function @@ -356,9 +298,9 @@ return require("lazy").setup({ config = function() require('colorizer').setup({ '*', - '!markdown', + '!markdown' }) - end, + end }, -- fileexplorer on the side @@ -378,14 +320,18 @@ return require("lazy").setup({ }, filters = { dotfiles = true, - }, + } }) - end, + end }, -- better language highlighting by improved parsing { 'nvim-treesitter/nvim-treesitter', + dependencies = { + -- automatically close html-tags + 'windwp/nvim-ts-autotag', + }, config = function() require("nvim-treesitter.configs").setup({ ensure_installed = { @@ -399,15 +345,9 @@ return require("lazy").setup({ "latex", "python", }, - autotag = { enable = true }, + autotag = { enable = true } }) - end, - }, - - -- automatically close html-tags - { - 'windwp/nvim-ts-autotag', - dependencies = { 'nvim-treesitter/nvim-treesitter' }, + end }, -- folding improvements @@ -426,7 +366,7 @@ return require("lazy").setup({ pattern = { '*' }, command = 'lua require("ufo").openAllFolds()' }) - end, + end }, -- fuzzy finder @@ -436,15 +376,16 @@ return require("lazy").setup({ dependencies = { 'nvim-lua/plenary.nvim' }, config = function() require("telescope").setup() - end, + end }, -- clean up white spaces and empty lines before writing { "mcauley-penney/tidy.nvim", + event = "VeryLazy", config = function() require("tidy").setup({ - filetype_exclude = {}, + filetype_exclude = {} }) end }, @@ -455,93 +396,57 @@ return require("lazy").setup({ dependencies = { 'nvim-lua/plenary.nvim' }, config = function() require 'todo-comments'.setup { - signs = true, - sign_priority = 8, keywords = { ERRO = { icon = Error_sign, color = "error" }, WARN = { icon = Warn_sign, color = "warning" }, HACK = { icon = Hack_sign, color = "warning" }, HINT = { icon = Hint_sign, color = "hint" }, - TODO = { icon = Todo_sign, color = "hint" }, - INFO = { icon = Info_sign, color = "info", alt = { "NOTE" } }, - PERF = { icon = Perfect_sign, color = "perfect" }, - TEST = { icon = Test_sign, color = "test" }, - }, - gui_style = { - fg = "NONE", - bg = "BOLD", - }, - merge_keywords = true, - highlight = { - multiline = true, - multiline_pattern = "^.", - multiline_context = 10, - before = "", - keyword = "wide", - after = "fg", - pattern = [[.*<(KEYWORDS)\s*:]], - comments_only = true, - max_line_len = 400, - exclude = {}, - }, - colors = { - error = "DiagnosticSignError", - warning = "DiagnosticSignWarn", - hint = "DiagnosticSignHint", - info = "DiagnosticSignInfo", - perfect = "Special", - test = "Identifier", - }, - search = { - command = "rg", - args = { - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - }, - pattern = [[\b(KEYWORDS):]], - }, + TODO = { icon = Todo_sign, color = "info" }, + INFO = { icon = Info_sign, color = "hint", alt = { "NOTE" } }, + PERF = { icon = Perfect_sign, color = "default" }, + TEST = { icon = Test_sign, color = "test" } + } } - end, + end }, -- git wrapper - 'tpope/vim-fugitive', - - -- golang language support { - 'fatih/vim-go', - ft = { 'go' }, - config = function() - vim.g.go_def_mapping_enabled = 0 - end, + 'tpope/vim-fugitive', + event = "VeryLazy" }, -- markdown language support { 'preservim/vim-markdown', ft = { 'markdown' }, - dependencies = { 'godlygeek/tabular' }, config = function() vim.g.vim_markdown_folding_style_pythonic = 1 vim.g.vim_markdown_folding_disabled = 0 vim.g.vim_markdown_conceal = 2 - end, + end }, -- bulk renamer - 'qpkorr/vim-renamer', + { + 'qpkorr/vim-renamer', + event = "VeryLazy" + }, -- additional quote/parantheses funtions - 'tpope/vim-surround', + { + "kylechui/nvim-surround", + event = "VeryLazy", + config = function() + require("nvim-surround").setup() + end + }, -- colorscheme { 'tiyn/vim-tccs', config = function() vim.cmd('colorscheme tccs') - end, - }, + end + } }) diff --git a/.config/nvim/lua/style.lua b/.config/nvim/lua/style.lua index 601e305..1670a33 100644 --- a/.config/nvim/lua/style.lua +++ b/.config/nvim/lua/style.lua @@ -8,6 +8,47 @@ Todo_sign = " " Perfect_sign = " " Test_sign = " " +Menu_signs = { + nvim_lsp = "", + path = "", + buffer = "", + luasnip = "", +} + +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 = "" +} + +Install_icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" +} + vim.fn.sign_define( "DiagnosticSignError", { texthl = "DiagnosticSignError", text = Error_sign, numhl = "DiagnosticSignError" }