From 650c5829720d28e419c2c640a28dc6d047bd1f62 Mon Sep 17 00:00:00 2001 From: fiplox Date: Sat, 15 Apr 2023 15:47:38 +0200 Subject: [PATCH] feat!: minor rework Moved all plugins that I don't change often/ever to plugins/init.lua. Removed mason-lspconfig, not useful in my case. --- init.lua | 6 +- lua/config/mappings.lua | 14 +- lua/config/utils.lua | 282 ++++++++++++++ lua/plugins/Comment.lua | 65 ---- lua/plugins/autopairs.lua | 28 -- lua/plugins/buffer_manager.lua | 28 -- lua/plugins/cmp.lua | 276 +++++++------ lua/plugins/colorizer.lua | 24 -- lua/plugins/feline.lua | 315 +++------------ lua/plugins/init.lua | 473 +++++++++++++++++++++-- lua/plugins/lsp/init.lua | 177 ++++----- lua/plugins/lsp/settings/sumneko_lua.lua | 21 - lua/plugins/mason.lua | 44 --- lua/plugins/neogit.lua | 94 ----- lua/plugins/null-ls.lua | 113 +++--- lua/plugins/oil.lua | 79 ---- lua/plugins/theme.lua | 5 - lua/plugins/toggleterm.lua | 48 --- lua/plugins/tresitter.lua | 47 --- lua/plugins/trouble.lua | 61 --- 20 files changed, 1034 insertions(+), 1166 deletions(-) create mode 100644 lua/config/utils.lua delete mode 100644 lua/plugins/Comment.lua delete mode 100644 lua/plugins/autopairs.lua delete mode 100644 lua/plugins/buffer_manager.lua delete mode 100644 lua/plugins/colorizer.lua delete mode 100644 lua/plugins/lsp/settings/sumneko_lua.lua delete mode 100644 lua/plugins/mason.lua delete mode 100644 lua/plugins/neogit.lua delete mode 100644 lua/plugins/oil.lua delete mode 100644 lua/plugins/theme.lua delete mode 100644 lua/plugins/toggleterm.lua delete mode 100644 lua/plugins/tresitter.lua delete mode 100644 lua/plugins/trouble.lua diff --git a/init.lua b/init.lua index 6cb263f..5a2b8b6 100644 --- a/init.lua +++ b/init.lua @@ -16,12 +16,12 @@ vim.opt.runtimepath:prepend(lazypath) vim.api.nvim_create_autocmd('User', { pattern = 'LazyVimStarted', callback = function() + require 'feline' require 'config.mappings' require 'config.autocmd' - vim.cmd 'colorscheme neogruber' - require 'nvim-treesitter' - require 'feline' require 'noice' + require 'nvim-treesitter' + vim.cmd 'colorscheme neogruber' end, }) diff --git a/lua/config/mappings.lua b/lua/config/mappings.lua index a8f1860..2044d4c 100644 --- a/lua/config/mappings.lua +++ b/lua/config/mappings.lua @@ -96,19 +96,7 @@ function UnMapDHM() vim.api.nvim_del_keymap('n', 'N') end -if os.getenv 'SSH_TTY' then - MapDHM() -else - local handle = io.popen 'lsusb | grep -c Sofle' - if handle == nil then - return - end - local automap = handle:read '*n' - handle:close() - if automap == 1 then - MapDHM() - end -end +MapDHM() local wk = require 'which-key' diff --git a/lua/config/utils.lua b/lua/config/utils.lua new file mode 100644 index 0000000..d4416c8 --- /dev/null +++ b/lua/config/utils.lua @@ -0,0 +1,282 @@ +local M = {} +M.kind_icons = { + 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 = '', +} + +M.has_words_before = function() + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil +end + +M.feline_theme = { + fg = '#c9d1d9', + bg = '#1f2428', + green = '#66cc66', + yellow = '#d5992a', + purple = '#c678dd', + orange = '#b17135', + peanut = '#f6d5a4', + red = '#e06c75', + aqua = '#61afef', + bg2 = '#24293a', + dark_red = '#f75f5f', +} + +M.feline_vi_mode_colors = { + NORMAL = 'green', + OP = 'green', + INSERT = 'yellow', + VISUAL = 'purple', + LINES = 'orange', + BLOCK = 'dark_red', + REPLACE = 'red', + COMMAND = 'aqua', +} + +M.feline_c = { + vim_mode = { + provider = { + name = 'vi_mode', + opts = { + show_mode_name = true, + -- padding = "center", -- Uncomment for extra padding. + }, + }, + hl = function() + return { + fg = require('feline.providers.vi_mode').get_mode_color(), + bg = 'bg2', + style = 'bold', + name = 'NeovimModeHLColor', + } + end, + left_sep = 'block', + right_sep = 'block', + }, + gitBranch = { + provider = 'git_branch', + hl = { + fg = 'peanut', + bg = 'bg2', + style = 'bold', + }, + left_sep = 'block', + right_sep = 'block', + }, + gitDiffAdded = { + provider = 'git_diff_added', + hl = { + fg = 'green', + bg = 'bg2', + }, + left_sep = 'block', + right_sep = 'block', + }, + gitDiffRemoved = { + provider = 'git_diff_removed', + hl = { + fg = 'red', + bg = 'bg2', + }, + left_sep = 'block', + right_sep = 'block', + }, + gitDiffChanged = { + provider = 'git_diff_changed', + hl = { + fg = 'fg', + bg = 'bg2', + }, + left_sep = 'block', + right_sep = 'right_filled', + }, + separator = { + provider = '', + }, + file_info = { + provider = { + name = 'file_info', + opts = { + colored_icon = false, + type = 'relative-short', + }, + }, + hl = { + style = 'bold', + }, + left_sep = ' ', + right_sep = ' ', + }, + diagnostic_errors = { + provider = 'diagnostic_errors', + hl = { + fg = 'red', + }, + }, + diagnostic_warnings = { + provider = 'diagnostic_warnings', + hl = { + fg = 'yellow', + }, + }, + diagnostic_hints = { + provider = 'diagnostic_hints', + hl = { + fg = 'aqua', + }, + }, + diagnostic_info = { + provider = 'diagnostic_info', + }, + lsp_client_names = { + provider = 'lsp_client_names', + hl = { + fg = 'purple', + bg = 'bg2', + style = 'bold', + }, + left_sep = 'left_filled', + right_sep = 'right_filled', + }, + file_type = { + provider = { + name = 'file_type', + opts = { + -- filetype_icon = true, + colored_icon = false, + case = 'titlecase', + }, + }, + hl = { + fg = 'red', + bg = 'bg2', + style = 'bold', + }, + left_sep = 'left_filled', + right_sep = 'block', + }, + file_encoding = { + provider = 'file_encoding', + hl = { + fg = 'orange', + bg = 'bg2', + -- style = 'italic', + }, + left_sep = 'block', + right_sep = 'block', + }, + position = { + provider = 'position', + hl = { + fg = 'green', + bg = 'bg2', + style = 'bold', + }, + left_sep = 'block', + right_sep = 'block', + }, + line_percentage = { + provider = 'line_percentage', + hl = { + fg = 'aqua', + bg = 'bg2', + style = 'bold', + }, + left_sep = 'block', + right_sep = 'block', + }, + scroll_bar = { + provider = 'scroll_bar', + hl = { + fg = 'yellow', + style = 'bold', + }, + }, + search_count = { + provider = 'search_count', + hl = { + style = 'bold', + bg = 'bg2', + }, + left_sep = 'block', + right_sep = 'block', + }, + macro = { + provider = 'macro', + hl = { + style = 'bold', + bg = 'bg2', + }, + left_sep = 'block', + right_sep = 'block', + }, +} + +function M.on_attach(client, bufnr) + local has_formatter = #require("null-ls.sources").get_available(ft, "NULL_LS_FORMATTING") > 0 + --[[ vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') ]] + if client.name == 'jdt.ls' then + client.server_capabilities.documentFormattingProvider = false + vim.lsp.codelens.refresh() + if JAVA_DAP_ACTIVE then + require('jdtls').setup_dap { hotcodereplace = 'auto' } + require('jdtls.dap').setup_dap_main_class_configs() + end + end + local ft = vim.api.nvim_buf_get_option(bufnr, 'filetype') + + local enable = false + if has_formatter then + enable = client.name == 'null-ls' + else + enable = not (client.name == 'null-ls') + end + + -- util.info(client.name .. " " .. (enable and "yes" or "no"), "format") + client.server_capabilities.documentFormattingProvider = enable + client.server_capabilities.semanticTokensProvider = false +end + +M.lsp_config = { + virtual_text = { + prefix = '●', + }, + signs = false, + underline = true, + update_in_insert = true, + severity_sort = false, + float = { + focusable = false, + -- style = 'minimal', + border = 'rounded', + source = 'always', + header = '', + prefix = '', + }, +} + +return M diff --git a/lua/plugins/Comment.lua b/lua/plugins/Comment.lua deleted file mode 100644 index 0fc505e..0000000 --- a/lua/plugins/Comment.lua +++ /dev/null @@ -1,65 +0,0 @@ -local M = { - 'numToStr/Comment.nvim', - -- event = 'VeryLazy', - keys = { 'gcc', { 'gc', mode = 'v' }, {'gb', mode = 'v'} }, -} - -function M.config() - local comment = require 'Comment' - - comment.setup { - -- -LHS of operator-pending mappings in NORMAL and VISUAL mode - opleader = { - ---Line-comment keymap - line = 'gc', - ---Block-comment keymap - block = 'gb', - }, - ---LHS of extra mappings - extra = { - ---Add comment on the line above - above = 'gcO', - ---Add comment on the line below - below = 'gco', - ---Add comment at the end of line - eol = 'gca', - }, - ---Enable keybindings - ---NOTE: If given `false` then the plugin won't create any mappings - mappings = { - ---Operator-pending mapping; `gcc` `gbc` `gc[count]{motion}` `gb[count]{motion}` - basic = true, - ---Extra mapping; `gco`, `gcO`, `gcA` - extra = true, - ---Extended mapping; `g>` `g<` `g>[count]{motion}` `g<[count]{motion}` - extended = false, - }, - pre_hook = function(ctx) - -- Only calculate commentstring for tsx filetypes - if vim.bo.filetype == 'typescriptreact' then - local U = require 'Comment.utils' - - -- Determine whether to use linewise or blockwise commentstring - local type = ctx.ctype == U.ctype.linewise and '__default' or '__multiline' - - -- Determine the location where to calculate commentstring from - local location = nil - if ctx.ctype == U.ctype.blockwise then - location = require('ts_context_commentstring.utils').get_cursor_location() - elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then - location = require('ts_context_commentstring.utils').get_visual_start_location() - end - - return require('ts_context_commentstring.internal').calculate_commentstring { - key = type, - location = location, - } - end - end, - } - - local ft = require 'Comment.ft' - ft({ 's', 'asm' }, '# %s') -end - -return M diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua deleted file mode 100644 index 823be36..0000000 --- a/lua/plugins/autopairs.lua +++ /dev/null @@ -1,28 +0,0 @@ -local M = { - 'windwp/nvim-autopairs', - event = 'InsertEnter' -} - -function M.config() - local npairs = require 'nvim-autopairs' - - npairs.setup { - check_ts = true, -- treesitter integration - fast_wrap = { - map = '', - highlight = 'Search', - highlight_grey = 'Comment', - }, - map_c_w = true, - -- disable_filetype = { "TelescopePrompt" }, - } - - local cmp_autopairs = require 'nvim-autopairs.completion.cmp' - local cmp_status_ok, cmp = pcall(require, 'cmp') - if not cmp_status_ok then - return - end - cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done {}) -end - -return M diff --git a/lua/plugins/buffer_manager.lua b/lua/plugins/buffer_manager.lua deleted file mode 100644 index 198a26f..0000000 --- a/lua/plugins/buffer_manager.lua +++ /dev/null @@ -1,28 +0,0 @@ -local M = { - 'j-morano/buffer_manager.nvim', -} - -function M.config() - require('buffer_manager').setup { - -- line_keys = '', -- deactivate line keybindings - short_file_names = true, - short_term_names = false, - select_menu_item_commands = { - edit = { - key = '', - command = 'edit', - }, - v = { - key = '', - command = 'vsplit', - }, - h = { - key = '', - command = 'split', - }, - }, - width = 0.8, - } -end - -return M diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 995083a..06a4be2 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -1,4 +1,4 @@ -local M = { +return { 'hrsh7th/nvim-cmp', -- lazy = false, dependencies = { @@ -9,153 +9,135 @@ local M = { 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-path', + 'windwp/nvim-autopairs', }, event = { 'InsertEnter', 'CmdlineEnter' }, version = false, + config = function() + local cmp = require 'cmp' + local utils = require 'config.utils' + + cmp.setup { + -- enabled = function() + -- return vim.api.nvim_buf_get_option(0, 'buftype') ~= 'prompt' or require('cmp_dap').is_dap_buffer() + -- end, + view = { + entries = { + name = 'custom', -- can be "custom", "wildmenu" or "native" + -- separator = ' | ', + }, + }, + completion = { + autocomplete = { 'TextChanged', 'CmdlineChanged', 'TextChangedP' }, + -- autocomplete = false, + }, + snippet = { + expand = function(args) + require('snippy').expand_snippet(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + experimental = { + ghost_text = true, + }, + formatting = { + fields = { 'abbr', 'kind', 'menu' }, + format = function(_, item) + local ELLIPSIS_CHAR = '…' + local MAX_LABEL_WIDTH = 20 + item.kind = string.format('%s %s', utils.kind_icons[item.kind], item.kind) -- This concatonates the icons with the name of the item kind + + local label = item.abbr + local truncated_label = vim.fn.strcharpart(label, 0, MAX_LABEL_WIDTH) + if truncated_label ~= label then + item.abbr = truncated_label .. ELLIPSIS_CHAR + end + return item + end, + }, + mapping = { + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + [''] = cmp.mapping { + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }, + [''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item { behavior = cmp.SelectBehavior.Select } + elseif require('snippy').can_expand_or_advance() then + require('snippy').expand_or_advance() + elseif utils.has_words_before() then + cmp.complete() + else + fallback() + end + end, { 'i', 's' }), + + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item { behavior = cmp.SelectBehavior.Insert } + elseif require('snippy').can_jump(-1) then + require('snippy').previous() + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'snippy' }, + { name = 'path' }, + { name = 'buffer' }, + }, + } + cmp.setup.cmdline(':', { + completion = { autocomplete = { 'TextChanged' } }, + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'cmdline' }, + { name = 'path' }, + }, + -- view = { + -- entries = { name = 'wildmenu', separator = ' · ' }, + -- }, + }) + + cmp.setup.cmdline('/', { + sources = { + { name = 'buffer' }, + }, + -- view = { + -- entries = { name = 'wildmenu', separator = ' · ' }, + -- }, + }) + + cmp.setup.filetype({ 'dap-repl', 'dapui_watches', 'dapui_hover' }, { + sources = { + { name = 'dap' }, + }, + }) + + local npairs = require 'nvim-autopairs' + npairs.setup { + check_ts = true, -- treesitter integration + fast_wrap = { + map = '', + highlight = 'Search', + highlight_grey = 'Comment', + }, + map_c_w = true, + -- disable_filetype = { "TelescopePrompt" }, + } + + local cmp_autopairs = require 'nvim-autopairs.completion.cmp' + cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done {}) + end, } - -function M.config() - local kind_icons = { - 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 = '', - } - local cmp = require 'cmp' - - local has_words_before = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil - end - - cmp.setup { - enabled = function() - return vim.api.nvim_buf_get_option(0, 'buftype') ~= 'prompt' or require('cmp_dap').is_dap_buffer() - end, - view = { - entries = { - name = 'custom', -- can be "custom", "wildmenu" or "native" - -- separator = ' | ', - }, - }, - completion = { - autocomplete = { 'TextChanged', 'CmdlineChanged', 'TextChangedP' }, - -- autocomplete = false, - }, - snippet = { - expand = function(args) - require('snippy').expand_snippet(args.body) - end, - }, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - experimental = { - ghost_text = true, - }, - formatting = { - fields = { 'abbr', 'kind', 'menu' }, - format = function(_, item) - local ELLIPSIS_CHAR = '…' - local MAX_LABEL_WIDTH = 20 - item.kind = string.format('%s %s', kind_icons[item.kind], item.kind) -- This concatonates the icons with the name of the item kind - - local label = item.abbr - local truncated_label = vim.fn.strcharpart(label, 0, MAX_LABEL_WIDTH) - if truncated_label ~= label then - item.abbr = truncated_label .. ELLIPSIS_CHAR - end - return item - end, - }, - mapping = { - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), - [''] = cmp.mapping { - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }, - [''] = cmp.mapping.confirm { select = true }, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item { behavior = cmp.SelectBehavior.Select } - elseif require('snippy').can_expand_or_advance() then - require('snippy').expand_or_advance() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { 'i', 's' }), - - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item { behavior = cmp.SelectBehavior.Insert } - elseif require('snippy').can_jump(-1) then - require('snippy').previous() - else - fallback() - end - end, { 'i', 's' }), - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'snippy' }, - { name = 'path' }, - { name = 'buffer' }, - }, - } - cmp.setup.cmdline(':', { - completion = { autocomplete = { 'TextChanged' } }, - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = 'cmdline' }, - { name = 'path' }, - }, - -- view = { - -- entries = { name = 'wildmenu', separator = ' · ' }, - -- }, - }) - - cmp.setup.cmdline('/', { - sources = { - { name = 'buffer' }, - }, - -- view = { - -- entries = { name = 'wildmenu', separator = ' · ' }, - -- }, - }) - - cmp.setup.filetype({ 'dap-repl', 'dapui_watches', 'dapui_hover' }, { - sources = { - { name = 'dap' }, - }, - }) -end - -return M diff --git a/lua/plugins/colorizer.lua b/lua/plugins/colorizer.lua deleted file mode 100644 index 0cdabec..0000000 --- a/lua/plugins/colorizer.lua +++ /dev/null @@ -1,24 +0,0 @@ -return { - 'NvChad/nvim-colorizer.lua', - -- event = 'BufReadPre', - cmd = 'ColorizerToggle', - opts = { - filetypes = { '*', '!lazy' }, - buftype = { '*', '!prompt', '!nofile' }, - user_default_options = { - RGB = true, -- #RGB hex codes - RRGGBB = true, -- #RRGGBB hex codes #ffffff - names = false, -- "Name" codes like Blue - RRGGBBAA = true, -- #RRGGBBAA hex codes - AARRGGBB = false, -- 0xAARRGGBB hex codes - rgb_fn = true, -- CSS rgb() and rgba() functions - hsl_fn = true, -- CSS hsl() and hsla() functions - css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB - css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn - -- Available modes: foreground, background - -- Available modes for `mode`: foreground, background, virtualtext - -- mode = "background", -- Set the display mode. - -- virtualtext = "■", - }, - }, -} diff --git a/lua/plugins/feline.lua b/lua/plugins/feline.lua index fbbc0ab..0c6df99 100644 --- a/lua/plugins/feline.lua +++ b/lua/plugins/feline.lua @@ -1,4 +1,4 @@ -local M = { +return { 'feline-nvim/feline.nvim', -- lazy = false -- event = 'UIEnter', @@ -6,262 +6,59 @@ local M = { dependencies = { 'nvim-tree/nvim-web-devicons', }, + config = function() + local feline = require 'feline' + local utils = require 'config.utils' + local c = utils.feline_c + local theme = utils.feline_theme + local vi_mode_colors = utils.feline_vi_mode_colors + + local left = { + c.vim_mode, + c.file_info, + -- c.gitBranch, + -- c.gitDiffAdded, + -- c.gitDiffRemoved, + -- c.gitDiffChanged, + -- c.separator, + c.diagnostic_errors, + c.diagnostic_warnings, + c.diagnostic_info, + c.diagnostic_hints, + } + + local middle = { + c.lsp_client_names, + c.separator, + } + + local right = { + c.file_type, + c.search_count, + c.macro, + c.file_encoding, + c.position, + c.line_percentage, + c.scroll_bar, + } + + local components = { + active = { + left, + middle, + right, + }, + inactive = { + left, + middle, + right, + }, + } + + feline.setup { + components = components, + theme = theme, + vi_mode_colors = vi_mode_colors, + } + end, } - -function M.config() - local feline = require 'feline' - - local theme = { - fg = '#c9d1d9', - bg = '#1f2428', - green = '#66cc66', - yellow = '#d5992a', - purple = '#c678dd', - orange = '#b17135', - peanut = '#f6d5a4', - red = '#e06c75', - aqua = '#61afef', - bg2 = '#24293a', - dark_red = '#f75f5f', - } - - local vi_mode_colors = { - NORMAL = 'green', - OP = 'green', - INSERT = 'yellow', - VISUAL = 'purple', - LINES = 'orange', - BLOCK = 'dark_red', - REPLACE = 'red', - COMMAND = 'aqua', - } - - local c = { - vim_mode = { - provider = { - name = 'vi_mode', - opts = { - show_mode_name = true, - -- padding = "center", -- Uncomment for extra padding. - }, - }, - hl = function() - return { - fg = require('feline.providers.vi_mode').get_mode_color(), - bg = 'bg2', - style = 'bold', - name = 'NeovimModeHLColor', - } - end, - left_sep = 'block', - right_sep = 'block', - }, - gitBranch = { - provider = 'git_branch', - hl = { - fg = 'peanut', - bg = 'bg2', - style = 'bold', - }, - left_sep = 'block', - right_sep = 'block', - }, - gitDiffAdded = { - provider = 'git_diff_added', - hl = { - fg = 'green', - bg = 'bg2', - }, - left_sep = 'block', - right_sep = 'block', - }, - gitDiffRemoved = { - provider = 'git_diff_removed', - hl = { - fg = 'red', - bg = 'bg2', - }, - left_sep = 'block', - right_sep = 'block', - }, - gitDiffChanged = { - provider = 'git_diff_changed', - hl = { - fg = 'fg', - bg = 'bg2', - }, - left_sep = 'block', - right_sep = 'right_filled', - }, - separator = { - provider = '', - }, - file_info = { - provider = { - name = 'file_info', - opts = { - colored_icon = false, - type = 'relative-short', - }, - }, - hl = { - style = 'bold', - }, - left_sep = ' ', - right_sep = ' ', - }, - diagnostic_errors = { - provider = 'diagnostic_errors', - hl = { - fg = 'red', - }, - }, - diagnostic_warnings = { - provider = 'diagnostic_warnings', - hl = { - fg = 'yellow', - }, - }, - diagnostic_hints = { - provider = 'diagnostic_hints', - hl = { - fg = 'aqua', - }, - }, - diagnostic_info = { - provider = 'diagnostic_info', - }, - lsp_client_names = { - provider = 'lsp_client_names', - hl = { - fg = 'purple', - bg = 'bg2', - style = 'bold', - }, - left_sep = 'left_filled', - right_sep = 'right_filled', - }, - file_type = { - provider = { - name = 'file_type', - opts = { - -- filetype_icon = true, - colored_icon = false, - case = 'titlecase', - }, - }, - hl = { - fg = 'red', - bg = 'bg2', - style = 'bold', - }, - left_sep = 'left_filled', - right_sep = 'block', - }, - file_encoding = { - provider = 'file_encoding', - hl = { - fg = 'orange', - bg = 'bg2', - -- style = 'italic', - }, - left_sep = 'block', - right_sep = 'block', - }, - position = { - provider = 'position', - hl = { - fg = 'green', - bg = 'bg2', - style = 'bold', - }, - left_sep = 'block', - right_sep = 'block', - }, - line_percentage = { - provider = 'line_percentage', - hl = { - fg = 'aqua', - bg = 'bg2', - style = 'bold', - }, - left_sep = 'block', - right_sep = 'block', - }, - scroll_bar = { - provider = 'scroll_bar', - hl = { - fg = 'yellow', - style = 'bold', - }, - }, - search_count = { - provider = 'search_count', - hl = { - style = 'bold', - bg = 'bg2', - }, - left_sep = 'block', - right_sep = 'block', - }, - macro = { - provider = 'macro', - hl = { - style = 'bold', - bg = 'bg2', - }, - left_sep = 'block', - right_sep = 'block', - }, - } - - local left = { - c.vim_mode, - c.file_info, - -- c.gitBranch, - -- c.gitDiffAdded, - -- c.gitDiffRemoved, - -- c.gitDiffChanged, - -- c.separator, - c.diagnostic_errors, - c.diagnostic_warnings, - c.diagnostic_info, - c.diagnostic_hints, - } - - local middle = { - c.lsp_client_names, - c.separator, - } - - local right = { - c.file_type, - c.search_count, - c.macro, - c.file_encoding, - c.position, - c.line_percentage, - c.scroll_bar, - } - - local components = { - active = { - left, - middle, - right, - }, - inactive = { - left, - middle, - right, - }, - } - - feline.setup { - components = components, - theme = theme, - vi_mode_colors = vi_mode_colors, - } -end - -return M diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index ef52367..548e001 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -5,13 +5,16 @@ return { 'simrat39/rust-tools.nvim', 'MunifTanjim/nui.nvim', { 'jghauser/mkdir.nvim', lazy = false }, + { + url = 'https://dev.filnar.com/fiplox/neogruber.nvim', + lazy = false, + -- event = 'VeryLazy' + }, -- 'rcarriga/cmp-dap', { 'phaazon/hop.nvim', -- event = 'BufRead', keys = { { 's', ':HopChar2' }, { 'S', ':HopWord' } }, - config = function() - require('hop').setup() - end, + config = true, }, { 'stevearc/dressing.nvim', @@ -26,47 +29,443 @@ return { return vim.ui.input(...) end end, - config = function() - require('dressing').setup { - select = { - trim_prompt = false, + opts = { + select = { + trim_prompt = false, + }, + }, + }, + { + 'folke/noice.nvim', + opts = { + messages = { + view_search = false, + }, + cmdline = { + enabled = true, + view = 'cmdline', -- view for rendering the cmdline. Change to `cmdline` to get a classic cmdline at the bottom + }, + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = false, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, + lsp = { + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ['vim.lsp.util.convert_input_to_markdown_lines'] = true, + ['vim.lsp.util.stylize_markdown'] = true, + ['cmp.entry.get_documentation'] = true, }, + hover = { + enabled = false, + }, + signature = { + enabled = false, + }, + }, + }, + }, + { + 'numToStr/Comment.nvim', + -- event = 'VeryLazy', + keys = { 'gcc', { 'gc', mode = 'v' }, { 'gb', mode = 'v' } }, + opts = { + -- -LHS of operator-pending mappings in NORMAL and VISUAL mode + opleader = { + ---Line-comment keymap + line = 'gc', + ---Block-comment keymap + block = 'gb', + }, + ---LHS of extra mappings + extra = { + ---Add comment on the line above + above = 'gcO', + ---Add comment on the line below + below = 'gco', + ---Add comment at the end of line + eol = 'gca', + }, + ---Enable keybindings + ---NOTE: If given `false` then the plugin won't create any mappings + mappings = { + ---Operator-pending mapping; `gcc` `gbc` `gc[count]{motion}` `gb[count]{motion}` + basic = true, + ---Extra mapping; `gco`, `gcO`, `gcA` + extra = true, + ---Extended mapping; `g>` `g<` `g>[count]{motion}` `g<[count]{motion}` + extended = false, + }, + pre_hook = function(ctx) + -- Only calculate commentstring for tsx filetypes + if vim.bo.filetype == 'typescriptreact' then + local U = require 'Comment.utils' + + -- Determine whether to use linewise or blockwise commentstring + local type = ctx.ctype == U.ctype.linewise and '__default' or '__multiline' + + -- Determine the location where to calculate commentstring from + local location = nil + if ctx.ctype == U.ctype.blockwise then + location = require('ts_context_commentstring.utils').get_cursor_location() + elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then + location = require('ts_context_commentstring.utils').get_visual_start_location() + end + + return require('ts_context_commentstring.internal').calculate_commentstring { + key = type, + location = location, + } + end + end, + }, + }, + { + 'NvChad/nvim-colorizer.lua', + -- event = 'BufReadPre', + cmd = 'ColorizerToggle', + opts = { + filetypes = { '*', '!lazy' }, + buftype = { '*', '!prompt', '!nofile' }, + user_default_options = { + RGB = true, -- #RGB hex codes + RRGGBB = true, -- #RRGGBB hex codes #ffffff + names = false, -- "Name" codes like Blue + RRGGBBAA = true, -- #RRGGBBAA hex codes + AARRGGBB = false, -- 0xAARRGGBB hex codes + rgb_fn = true, -- CSS rgb() and rgba() functions + hsl_fn = true, -- CSS hsl() and hsla() functions + css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB + css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn + -- Available modes: foreground, background + -- Available modes for `mode`: foreground, background, virtualtext + -- mode = "background", -- Set the display mode. + -- virtualtext = "■", + }, + }, + }, + { + 'williamboman/mason.nvim', + cmd = 'Mason', + opts = { + settings = { + ui = { + border = 'rounded', + icons = { + package_installed = '◍', + package_pending = '◍', + package_uninstalled = '◍', + }, + }, + -- log_level = vim.log.levels.INFO, + max_concurrent_installers = 4, + }, + }, + }, + { + 'TimUntersberger/neogit', + dependencies = 'sindrets/diffview.nvim', + cmd = 'Neogit', + opts = { + disable_signs = false, + disable_hint = false, + disable_context_highlighting = false, + disable_commit_confirmation = true, + -- Neogit refreshes its internal state after specific events, which can be expensive depending on the repository size. + -- Disabling `auto_refresh` will make it so you have to manually refresh the status after you open it. + auto_refresh = true, + disable_builtin_notifications = false, + use_magit_keybindings = false, + -- Change the default way of opening neogit + kind = 'replace', + -- The time after which an output console is shown for slow running commands + console_timeout = 2000, + -- Automatically show console if a command takes more than console_timeout milliseconds + auto_show_console = true, + -- Change the default way of opening the commit popup + commit_popup = { + kind = 'split', + }, + -- Change the default way of opening popups + popup = { + kind = 'split', + }, + status = { + recent_commit_count = 50, + }, + -- customize displayed signs + signs = { + -- { CLOSED, OPENED } + section = { '>', 'v' }, + item = { '>', 'v' }, + hunk = { '', '' }, + }, + integrations = { + -- Neogit only provides inline diffs. If you want a more traditional way to look at diffs, you can use `sindrets/diffview.nvim`. + -- The diffview integration enables the diff popup, which is a wrapper around `sindrets/diffview.nvim`. + -- + -- Requires you to have `sindrets/diffview.nvim` installed. + -- use { + -- 'TimUntersberger/neogit', + -- requires = { + -- 'nvim-lua/plenary.nvim', + -- 'sindrets/diffview.nvim' + -- } + -- } + -- + diffview = true, + }, + -- Setting any section to `false` will make the section not render at all + sections = { + untracked = { + folded = false, + }, + unstaged = { + folded = false, + }, + staged = { + folded = false, + }, + stashes = { + folded = true, + }, + unpulled = { + folded = true, + }, + unmerged = { + folded = false, + }, + recent = { + folded = true, + }, + }, + -- override/add mappings + mappings = { + -- modify status buffer mappings + status = { + -- Adds a mapping with "B" as key that does the "BranchPopup" command + ['B'] = 'BranchPopup', + -- Removes the default mapping of "s" + -- ['s'] = '', + }, + }, + }, + }, + { + 'stevearc/oil.nvim', + -- lazy = false, + event = 'Syntax', + opts = { + -- Id is automatically added at the beginning, and name at the end + -- See :help oil-columns + columns = { + 'icon', + -- "permissions", + -- "size", + -- "mtime", + }, + -- Buffer-local options to use for oil buffers + buf_options = { + buflisted = false, + }, + -- Window-local options to use for oil buffers + win_options = { + wrap = false, + signcolumn = 'no', + cursorcolumn = false, + foldcolumn = '0', + spell = false, + list = false, + conceallevel = 3, + concealcursor = 'nvic', + }, + -- Restore window options to previous values when leaving an oil buffer + restore_win_options = true, + -- Skip the confirmation popup for simple operations + skip_confirm_for_simple_edits = false, + -- Keymaps in oil buffer. Can be any value that `vim.keymap.set` accepts OR a table of keymap + -- options with a `callback` (e.g. { callback = function() ... end, desc = "", nowait = true }) + -- Additionally, if it is a string that matches "actions.", + -- it will use the mapping at require("oil.actions"). + -- Set to `false` to remove a keymap + -- See :help oil-actions for a list of all available actions + keymaps = { + ['g?'] = 'actions.show_help', + [''] = 'actions.select', + [''] = 'actions.select_vsplit', + [''] = 'actions.select_split', + [''] = 'actions.preview', + [''] = 'actions.preview', + [''] = 'actions.close', + ['q'] = 'actions.close', + [''] = 'actions.refresh', + ['-'] = 'actions.parent', + ['l'] = 'actions.parent', + ['_'] = 'actions.open_cwd', + ['`'] = 'actions.cd', + ['~'] = 'actions.tcd', + ['g.'] = 'actions.toggle_hidden', + }, + -- Set to false to disable all of the above keymaps + use_default_keymaps = true, + view_options = { + -- Show files and directories that start with "." + show_hidden = false, + }, + -- Configuration for the floating window in oil.open_float + float = { + -- Padding around the floating window + padding = 2, + max_width = 0, + max_height = 0, + border = 'rounded', + win_options = { + winblend = 10, + }, + }, + }, + }, + { + 'akinsho/toggleterm.nvim', + cmd = 'ToggleTerm', + opts = { + -- size can be a number or function which is passed the current terminal + -- size = function(term) + -- if term.direction == 'horizontal' then + -- return 15 + -- elseif term.direction == 'vertical' then + -- return vim.o.columns * 0.4 + -- end + -- end, + shade_filetypes = { 'none', 'fzf' }, + -- open_mapping = [[]], + hide_numbers = true, -- hide the number column in toggleterm buffers + shade_terminals = true, + shading_factor = '2', -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light + start_in_insert = true, + insert_mappings = true, -- whether or not the open mapping applies in insert mode + persist_size = true, + -- direction = 'horizontal', -- 'vertical' | 'horizontal' | 'window' | 'float', + direction = 'float', -- 'vertical' | 'horizontal' | 'window' | 'float', + close_on_exit = true, -- close the terminal window when the process exits + shell = vim.o.shell, -- change the default shell + -- This field is only relevant if direction is set to 'float' + float_opts = { + -- The border key is *almost* the same as 'nvim_win_open' + -- see :h nvim_win_open for details on borders however + -- the 'curved' border is a custom border type + -- not natively supported but implemented in this plugin. + border = 'curved', -- | 'double' | 'shadow' | 'curved' --| ... other options supported by win open + -- width = 100, + -- height = 30, + -- winblend = 20, + -- highlights = { + -- border = 'Normal', + -- background = 'Normal', + -- }, + }, + }, + }, + { + 'nvim-treesitter/nvim-treesitter', + -- lazy = false, + -- dependencies = { 'nvim-treesitter/playground' }, + -- dependencies = 'windwp/nvim-ts-autotag', + config = function() + local configs = require 'nvim-treesitter.configs' + + configs.setup { + ignore_install = { 'haskell' }, + highlight = { + enable = true, -- false will disable the whole extension + disable = { 'html' }, + }, + -- context_commentstring = { enable = true, config = { css = '// %s' } }, + -- indent = {enable = true, disable = {"python", "html", "javascript"}}, + -- TODO seems to be broken + indent = { enable = true, disable = { 'python', 'css' } }, + -- autotag = { enable = true }, } end, }, { - 'folke/noice.nvim', - config = function() - require('noice').setup { - messages = { - view_search = false, + 'folke/trouble.nvim', + -- dependencies = { + -- 'nvim-tree/nvim-web-devicons', + -- }, + cmd = { 'TroubleToggle', 'Trouble' }, + opts = { + position = 'bottom', -- position of the list can be: bottom, top, left, right + height = 10, -- height of the trouble list when position is top or bottom + width = 50, -- width of the list when position is left or right + icons = true, -- use devicons for filenames + mode = 'quickfix', -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" + fold_open = '', -- icon used for open folds + fold_closed = '', -- icon used for closed folds + group = true, -- group results by file + padding = true, -- add an extra new line on top of the list + action_keys = { -- key mappings for actions in the trouble list + -- map to {} to remove a mapping, for example: + -- close = {}, + close = 'q', -- close the list + cancel = '', -- cancel the preview and get back to your last window / buffer / cursor + refresh = 'r', -- manually refresh + jump_close = { '', '' }, -- jump to the diagnostic or open / close folds + open_split = { '' }, -- open buffer in new split + open_vsplit = { '' }, -- open buffer in new vsplit + open_tab = { '' }, -- open buffer in new tab + jump = { 'o' }, -- jump to the diagnostic and close the list + toggle_mode = 'm', -- toggle between "workspace" and "document" diagnostics mode + toggle_preview = 'P', -- toggle auto_preview + hover = 'K', -- opens a small popup with the full multiline message + preview = 'p', -- preview the diagnostic location + close_folds = { 'zM', 'zm' }, -- close all folds + open_folds = { 'zR', 'zr' }, -- open all folds + toggle_fold = { 'zA', 'za' }, -- toggle fold of current file + previous = 'k', -- preview item + next = 'j', -- next item + }, + indent_lines = true, -- add an indent guide below the fold icons + auto_open = false, -- automatically open the list when you have diagnostics + auto_close = false, -- automatically close the list when you have no diagnostics + auto_preview = false, -- automatically preview the location of the diagnostic. to close preview and go back to last window + auto_fold = false, -- automatically fold a file trouble list at creation + auto_jump = { 'lsp_definitions' }, -- for the given modes, automatically jump if there is only a single result + signs = { + -- icons / text used for a diagnostic + error = '', + warning = '', + hint = '', + information = '', + other = '﫠', + }, + use_diagnostic_signs = false, -- enabling this will use the signs defined in your lsp client + }, + }, + { + 'j-morano/buffer_manager.nvim', + opts = { + -- line_keys = '', -- deactivate line keybindings + short_file_names = true, + short_term_names = false, + select_menu_item_commands = { + edit = { + key = '', + command = 'edit', }, - cmdline = { - enabled = true, - view = 'cmdline', -- view for rendering the cmdline. Change to `cmdline` to get a classic cmdline at the bottom + v = { + key = '', + command = 'vsplit', }, - presets = { - bottom_search = true, -- use a classic bottom cmdline for search - command_palette = false, -- position the cmdline and popupmenu together - long_message_to_split = true, -- long messages will be sent to a split - inc_rename = false, -- enables an input dialog for inc-rename.nvim - lsp_doc_border = false, -- add a border to hover docs and signature help + h = { + key = '', + command = 'split', }, - lsp = { - -- override markdown rendering so that **cmp** and other plugins use **Treesitter** - override = { - ['vim.lsp.util.convert_input_to_markdown_lines'] = true, - ['vim.lsp.util.stylize_markdown'] = true, - ['cmp.entry.get_documentation'] = true, - }, - hover = { - enabled = false, - }, - signature = { - enabled = false, - }, - }, - } - end, + }, + width = 0.6, + }, }, } diff --git a/lua/plugins/lsp/init.lua b/lua/plugins/lsp/init.lua index 582f071..190af26 100644 --- a/lua/plugins/lsp/init.lua +++ b/lua/plugins/lsp/init.lua @@ -3,129 +3,96 @@ local M = { name = 'lsp', event = { 'BufRead', 'BufNewFile' }, -- lazy = false, - dependencies = { 'hrsh7th/cmp-nvim-lsp', 'williamboman/mason-lspconfig.nvim' }, + dependencies = { 'hrsh7th/cmp-nvim-lsp', 'williamboman/mason.nvim' }, } -local function has_formatter(ft) - local sources = require 'null-ls.sources' - local available = sources.get_available(ft, 'NULL_LS_FORMATTING') - return #available > 0 -end +local servers = { 'clangd', 'rust_analyzer', 'lua_ls', 'pyright', 'gopls', 'jdtls' } function M.config() - require('mason-lspconfig').setup { - automatic_installation = false, - } - + local utils = require 'config.utils' local opts = {} local cmp_nvim_lsp = require 'cmp_nvim_lsp' - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities.textDocument.completion.completionItem.snippetSupport = true - capabilities = cmp_nvim_lsp.default_capabilities(capabilities) + local capabilities = cmp_nvim_lsp.default_capabilities() + local lspconfig = require 'lspconfig' - local on_attach = function(client, bufnr) - --[[ vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') ]] - if client.name == 'jdt.ls' then - client.server_capabilities.documentFormattingProvider = false - vim.lsp.codelens.refresh() - if JAVA_DAP_ACTIVE then - require('jdtls').setup_dap { hotcodereplace = 'auto' } - require('jdtls.dap').setup_dap_main_class_configs() - end + for _, server in ipairs(servers) do + opts = { + on_attach = utils.on_attach, + capabilities = capabilities, + } + + if server == 'lua_ls' then + local sumneko_opts = { + flags = { + debounce_text_changes = 150, + }, + settings = { + Lua = { + diagnostics = { + globals = { 'vim' }, + }, + -- workspace = { + -- library = { + -- [vim.fn.expand '$VIMRUNTIME/lua'] = true, + -- [vim.fn.stdpath 'config' .. '/lua'] = true, + -- }, + -- }, + telemetry = { + enable = false, + }, + }, + }, + } + opts = vim.tbl_deep_extend('force', sumneko_opts, opts) end - local ft = vim.api.nvim_buf_get_option(bufnr, 'filetype') - - local enable = false - if has_formatter(ft) then - enable = client.name == 'null-ls' - else - enable = not (client.name == 'null-ls') + if server == 'clangd' then + local clangd_flags = { + '-j=5', + '--all-scopes-completion', + '--suggest-missing-includes', + '--background-index', + '--pch-storage=disk', + '--cross-file-rename', + '--log=info', + '--completion-style=detailed', + '--enable-config', -- clangd 11+ supports reading from .clangd configuration file + '--clang-tidy', + -- "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*,modernize-*,-modernize-use-trailing-return-type", + -- "--fallback-style=Google", + -- "--header-insertion=never", + -- "--query-driver=" + } + local clang_opts = { + arg = { unpack(clangd_flags) }, + } + opts = vim.tbl_deep_extend('force', clang_opts, opts) end - - -- util.info(client.name .. " " .. (enable and "yes" or "no"), "format") - client.server_capabilities.documentFormattingProvider = enable - client.server_capabilities.semanticTokensProvider = false + if server == 'jdtls' then + vim.cmd "command! -buffer -nargs=? -complete=custom,v:lua.require'jdtls'._complete_compile JdtCompile lua require('jdtls').compile()" + vim.cmd "command! -buffer -nargs=? -complete=custom,v:lua.require'jdtls'._complete_set_runtime JdtSetRuntime lua require('jdtls').set_runtime()" + vim.cmd "command! -buffer JdtUpdateConfig lua require('jdtls').update_project_config()" + -- vim.cmd "command! -buffer JdtJol lua require('jdtls').jol()" + vim.cmd "command! -buffer JdtBytecode lua require('jdtls').javap()" + -- vim.cmd "command! -buffer JdtJshell lua require('jdtls').jshell()" + goto continue + end + lspconfig[server].setup(opts) + ::continue:: end - require('mason-lspconfig').setup_handlers { - function(server) -- default handler (optional) - opts = { - on_attach = on_attach, - capabilities = capabilities, - } - - if server == 'sumneko_lua' or server == 'lua_ls' then - local sumneko_opts = require 'plugins.lsp.settings.sumneko_lua' - opts = vim.tbl_deep_extend('force', sumneko_opts, opts) - end - if server == 'clangd' then - local clangd_flags = { - '-j=5', - '--all-scopes-completion', - '--suggest-missing-includes', - '--background-index', - '--pch-storage=disk', - '--cross-file-rename', - '--log=info', - '--completion-style=detailed', - '--enable-config', -- clangd 11+ supports reading from .clangd configuration file - '--clang-tidy', - -- "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*,modernize-*,-modernize-use-trailing-return-type", - -- "--fallback-style=Google", - -- "--header-insertion=never", - -- "--query-driver=" - } - local clang_opts = { - arg = { unpack(clangd_flags) }, - } - opts = vim.tbl_deep_extend('force', clang_opts, opts) - end - if server == 'jdtls' then - vim.cmd "command! -buffer -nargs=? -complete=custom,v:lua.require'jdtls'._complete_compile JdtCompile lua require('jdtls').compile()" - vim.cmd "command! -buffer -nargs=? -complete=custom,v:lua.require'jdtls'._complete_set_runtime JdtSetRuntime lua require('jdtls').set_runtime()" - vim.cmd "command! -buffer JdtUpdateConfig lua require('jdtls').update_project_config()" - -- vim.cmd "command! -buffer JdtJol lua require('jdtls').jol()" - vim.cmd "command! -buffer JdtBytecode lua require('jdtls').javap()" - -- vim.cmd "command! -buffer JdtJshell lua require('jdtls').jshell()" - goto continue - end - require('lspconfig')[server].setup(opts) - ::continue:: - end, - } - - local config = { - virtual_text = { - prefix = '●', - }, - signs = false, - underline = true, - update_in_insert = true, - severity_sort = false, - float = { - focusable = false, - -- style = 'minimal', - border = 'rounded', - source = 'always', - header = '', - prefix = '', - }, - } - vim.diagnostic.config(config) + vim.diagnostic.config(utils.lsp_config) vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'rounded', }) - vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = 'rounded', }) - - local on_references = vim.lsp.handlers['textDocument/references'] - vim.lsp.handlers['textDocument/references'] = vim.lsp.with(on_references, { - -- Use location list instead of quickfix list - loclist = true, - }) + -- local on_references = vim.lsp.handlers['textDocument/references'] + -- vim.lsp.handlers['textDocument/references'] = vim.lsp.with(on_references, { + -- -- Use location list instead of quickfix list + -- loclist = true, + -- }) end return M diff --git a/lua/plugins/lsp/settings/sumneko_lua.lua b/lua/plugins/lsp/settings/sumneko_lua.lua deleted file mode 100644 index 8c669c3..0000000 --- a/lua/plugins/lsp/settings/sumneko_lua.lua +++ /dev/null @@ -1,21 +0,0 @@ -return { - flags = { - debounce_text_changes = 150, - }, - settings = { - Lua = { - diagnostics = { - globals = { 'vim' }, - }, - -- workspace = { - -- library = { - -- [vim.fn.expand '$VIMRUNTIME/lua'] = true, - -- [vim.fn.stdpath 'config' .. '/lua'] = true, - -- }, - -- }, - telemetry = { - enable = false, - }, - }, - }, -} diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua deleted file mode 100644 index e69875e..0000000 --- a/lua/plugins/mason.lua +++ /dev/null @@ -1,44 +0,0 @@ -local M = { - 'williamboman/mason.nvim', - cmd = 'Mason', -} - --- M.tools = { --- 'clang-format', --- 'clangd', --- 'gopls', --- 'lua-language-server', --- 'rust-analyzer', --- 'prettierd', --- 'stylua', --- } --- --- function M.check() --- local mr = require 'mason-registry' --- for _, tool in ipairs(M.tools) do --- local p = mr.get_package(tool) --- if not p:is_installed() then --- p:install() --- end --- end --- end - -function M.config() - require('mason').setup { - settings = { - ui = { - border = 'rounded', - icons = { - package_installed = '◍', - package_pending = '◍', - package_uninstalled = '◍', - }, - }, - log_level = vim.log.levels.INFO, - max_concurrent_installers = 4, - }, - } - -- M.check() -end - -return M diff --git a/lua/plugins/neogit.lua b/lua/plugins/neogit.lua deleted file mode 100644 index 275c054..0000000 --- a/lua/plugins/neogit.lua +++ /dev/null @@ -1,94 +0,0 @@ -local M = { - 'TimUntersberger/neogit', - dependencies = 'sindrets/diffview.nvim', - cmd = 'Neogit', -} - -function M.config() - require('neogit').setup { - disable_signs = false, - disable_hint = false, - disable_context_highlighting = false, - disable_commit_confirmation = true, - -- Neogit refreshes its internal state after specific events, which can be expensive depending on the repository size. - -- Disabling `auto_refresh` will make it so you have to manually refresh the status after you open it. - auto_refresh = true, - disable_builtin_notifications = false, - use_magit_keybindings = false, - -- Change the default way of opening neogit - kind = 'replace', - -- The time after which an output console is shown for slow running commands - console_timeout = 2000, - -- Automatically show console if a command takes more than console_timeout milliseconds - auto_show_console = true, - -- Change the default way of opening the commit popup - commit_popup = { - kind = 'split', - }, - -- Change the default way of opening popups - popup = { - kind = 'split', - }, - status = { - recent_commit_count = 50, - }, - -- customize displayed signs - signs = { - -- { CLOSED, OPENED } - section = { '>', 'v' }, - item = { '>', 'v' }, - hunk = { '', '' }, - }, - integrations = { - -- Neogit only provides inline diffs. If you want a more traditional way to look at diffs, you can use `sindrets/diffview.nvim`. - -- The diffview integration enables the diff popup, which is a wrapper around `sindrets/diffview.nvim`. - -- - -- Requires you to have `sindrets/diffview.nvim` installed. - -- use { - -- 'TimUntersberger/neogit', - -- requires = { - -- 'nvim-lua/plenary.nvim', - -- 'sindrets/diffview.nvim' - -- } - -- } - -- - diffview = true, - }, - -- Setting any section to `false` will make the section not render at all - sections = { - untracked = { - folded = false, - }, - unstaged = { - folded = false, - }, - staged = { - folded = false, - }, - stashes = { - folded = true, - }, - unpulled = { - folded = true, - }, - unmerged = { - folded = false, - }, - recent = { - folded = true, - }, - }, - -- override/add mappings - mappings = { - -- modify status buffer mappings - status = { - -- Adds a mapping with "B" as key that does the "BranchPopup" command - ['B'] = 'BranchPopup', - -- Removes the default mapping of "s" - -- ['s'] = '', - }, - }, - } -end - -return M diff --git a/lua/plugins/null-ls.lua b/lua/plugins/null-ls.lua index ba9b38a..763b303 100644 --- a/lua/plugins/null-ls.lua +++ b/lua/plugins/null-ls.lua @@ -1,61 +1,58 @@ -local M = { +return { 'jose-elias-alvarez/null-ls.nvim', ft = 'markdown', + config = function() + local null_ls = require 'null-ls' + + -- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting + local formatting = null_ls.builtins.formatting + -- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics + local diagnostics = null_ls.builtins.diagnostics + + null_ls.setup { + debug = false, + sources = { + formatting.prettier.with { extra_args = { '--no-semi', '--single-quote', '--jsx-single-quote' } }, + formatting.black.with { extra_args = { '--fast' } }, + formatting.stylua.with { extra_args = { '--quote-style=AutoPreferSingle', '--call-parentheses=None' } }, + -- formatting.clang_format.with { + -- filetypes = { 'c' }, + -- extra_args = { + -- '--style', + -- '{BasedOnStyle: LLVM, IndentWidth: 8, UseTab: Always, BreakBeforeBraces: Linux, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, AlwaysBreakAfterReturnType: AllDefinitions}', + -- -- '{AccessModifierOffset : -2, AllowShortIfStatementsOnASingleLine : Never, AlignConsecutiveMacros : true, AllowShortLoopsOnASingleLine : false, AlwaysBreakTemplateDeclarations : true, Standard : c++20, NamespaceIndentation : All, IndentWidth : 4, TabWidth : 4, BreakBeforeBraces : Linux, AllowShortFunctionsOnASingleLine : Empty, AllowShortBlocksOnASingleLine : Never, FixNamespaceComments : true, PointerAlignment : Right, ColumnLimit : 120, ContinuationIndentWidth : 2, UseTab : Always }', + -- }, + -- }, + formatting.clang_format.with { + filetypes = { 'cpp' }, + extra_args = { + '--style', + 'google', + }, + }, + formatting.beautysh, + formatting.goimports, + formatting.gofumpt, + formatting.sql_formatter, + diagnostics.golangci_lint.with { + extra_args = { + '-E', + 'revive', + '-E', + 'errcheck', + '-E', + 'gosec', + '-E', + 'nilerr', + '-E', + 'nlreturn', + }, + }, + formatting.asmfmt.with { + filetypes = { 'asm', 's' }, + }, + -- diagnostics.flake8 + }, + } + end, } - -function M.config() - local null_ls = require 'null-ls' - - -- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting - local formatting = null_ls.builtins.formatting - -- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics - local diagnostics = null_ls.builtins.diagnostics - - null_ls.setup { - debug = false, - sources = { - formatting.prettier.with { extra_args = { '--no-semi', '--single-quote', '--jsx-single-quote' } }, - formatting.black.with { extra_args = { '--fast' } }, - formatting.stylua.with { extra_args = { '--quote-style=AutoPreferSingle', '--call-parentheses=None' } }, - formatting.clang_format.with { - filetypes = { 'c' }, - extra_args = { - '--style', - '{BasedOnStyle: LLVM, IndentWidth: 8, UseTab: Always, BreakBeforeBraces: Linux, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, AlwaysBreakAfterReturnType: AllDefinitions}', - -- '{AccessModifierOffset : -2, AllowShortIfStatementsOnASingleLine : Never, AlignConsecutiveMacros : true, AllowShortLoopsOnASingleLine : false, AlwaysBreakTemplateDeclarations : true, Standard : c++20, NamespaceIndentation : All, IndentWidth : 4, TabWidth : 4, BreakBeforeBraces : Linux, AllowShortFunctionsOnASingleLine : Empty, AllowShortBlocksOnASingleLine : Never, FixNamespaceComments : true, PointerAlignment : Right, ColumnLimit : 120, ContinuationIndentWidth : 2, UseTab : Always }', - }, - }, - formatting.clang_format.with { - filetypes = { 'cpp' }, - extra_args = { - '--style', - 'google', - }, - }, - formatting.beautysh, - formatting.goimports, - formatting.gofumpt, - formatting.sql_formatter, - diagnostics.golangci_lint.with { - extra_args = { - '-E', - 'revive', - '-E', - 'errcheck', - '-E', - 'gosec', - '-E', - 'nilerr', - '-E', - 'nlreturn', - }, - }, - formatting.asmfmt.with { - filetypes = { 'asm', 's' }, - }, - -- diagnostics.flake8 - }, - } -end - -return M diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua deleted file mode 100644 index 2808e45..0000000 --- a/lua/plugins/oil.lua +++ /dev/null @@ -1,79 +0,0 @@ -local M = { - 'stevearc/oil.nvim', - -- lazy = false, - event = 'Syntax', -} - -function M.config() - require('oil').setup { - -- Id is automatically added at the beginning, and name at the end - -- See :help oil-columns - columns = { - 'icon', - -- "permissions", - -- "size", - -- "mtime", - }, - -- Buffer-local options to use for oil buffers - buf_options = { - buflisted = false, - }, - -- Window-local options to use for oil buffers - win_options = { - wrap = false, - signcolumn = 'no', - cursorcolumn = false, - foldcolumn = '0', - spell = false, - list = false, - conceallevel = 3, - concealcursor = 'nvic', - }, - -- Restore window options to previous values when leaving an oil buffer - restore_win_options = true, - -- Skip the confirmation popup for simple operations - skip_confirm_for_simple_edits = false, - -- Keymaps in oil buffer. Can be any value that `vim.keymap.set` accepts OR a table of keymap - -- options with a `callback` (e.g. { callback = function() ... end, desc = "", nowait = true }) - -- Additionally, if it is a string that matches "actions.", - -- it will use the mapping at require("oil.actions"). - -- Set to `false` to remove a keymap - -- See :help oil-actions for a list of all available actions - keymaps = { - ['g?'] = 'actions.show_help', - [''] = 'actions.select', - [''] = 'actions.select_vsplit', - [''] = 'actions.select_split', - [''] = 'actions.preview', - [''] = 'actions.preview', - [''] = 'actions.close', - ['q'] = 'actions.close', - [''] = 'actions.refresh', - ['-'] = 'actions.parent', - ['l'] = 'actions.parent', - ['_'] = 'actions.open_cwd', - ['`'] = 'actions.cd', - ['~'] = 'actions.tcd', - ['g.'] = 'actions.toggle_hidden', - }, - -- Set to false to disable all of the above keymaps - use_default_keymaps = true, - view_options = { - -- Show files and directories that start with "." - show_hidden = false, - }, - -- Configuration for the floating window in oil.open_float - float = { - -- Padding around the floating window - padding = 2, - max_width = 0, - max_height = 0, - border = 'rounded', - win_options = { - winblend = 10, - }, - }, - } -end - -return M diff --git a/lua/plugins/theme.lua b/lua/plugins/theme.lua deleted file mode 100644 index 20cf39d..0000000 --- a/lua/plugins/theme.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - url = 'https://dev.filnar.com/fiplox/neogruber.nvim', - lazy = false, - -- event = 'VeryLazy' -} diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua deleted file mode 100644 index 01f0fca..0000000 --- a/lua/plugins/toggleterm.lua +++ /dev/null @@ -1,48 +0,0 @@ -local M = { - 'akinsho/toggleterm.nvim', - cmd = 'ToggleTerm', -} - -function M.config() - local toggleterm = require 'toggleterm' - - toggleterm.setup { - -- size can be a number or function which is passed the current terminal - size = function(term) - if term.direction == 'horizontal' then - return 15 - elseif term.direction == 'vertical' then - return vim.o.columns * 0.4 - end - end, - shade_filetypes = { 'none', 'fzf' }, - -- open_mapping = [[]], - hide_numbers = true, -- hide the number column in toggleterm buffers - shade_terminals = true, - shading_factor = '2', -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light - start_in_insert = true, - insert_mappings = true, -- whether or not the open mapping applies in insert mode - persist_size = true, - -- direction = 'horizontal', -- 'vertical' | 'horizontal' | 'window' | 'float', - direction = 'float', -- 'vertical' | 'horizontal' | 'window' | 'float', - close_on_exit = true, -- close the terminal window when the process exits - shell = vim.o.shell, -- change the default shell - -- This field is only relevant if direction is set to 'float' - float_opts = { - -- The border key is *almost* the same as 'nvim_win_open' - -- see :h nvim_win_open for details on borders however - -- the 'curved' border is a custom border type - -- not natively supported but implemented in this plugin. - border = 'curved', -- | 'double' | 'shadow' | 'curved' --| ... other options supported by win open - -- width = 100, - -- height = 30, - -- winblend = 20, - -- highlights = { - -- border = 'Normal', - -- background = 'Normal', - -- }, - }, - } -end - -return M diff --git a/lua/plugins/tresitter.lua b/lua/plugins/tresitter.lua deleted file mode 100644 index c79324c..0000000 --- a/lua/plugins/tresitter.lua +++ /dev/null @@ -1,47 +0,0 @@ -local M = { - 'nvim-treesitter/nvim-treesitter', - -- lazy = false, - -- dependencies = { 'nvim-treesitter/playground' }, - -- event = { 'BufReadPost', 'BufNewFile' }, - -- event = 'VeryLazy' -} - -function M.config() - local configs = require 'nvim-treesitter.configs' - - configs.setup { - ensure_installed = { - 'bash', - 'c', - 'cpp', - 'go', - 'json', - 'lua', - 'python', - 'rust', - 'markdown', - 'markdown_inline', - 'regex', - 'vim', - }, - ignore_install = { 'haskell' }, - -- matchup = { - -- enable = true -- mandatory, false will disable the whole extension - -- -- disable = { "c", "ruby" }, -- optional, list of language that will be disabled - -- }, - highlight = { - enable = true, -- false will disable the whole extension - disable = { 'html' }, - }, - -- context_commentstring = { enable = true, config = { css = '// %s' } }, - -- indent = {enable = true, disable = {"python", "html", "javascript"}}, - -- TODO seems to be broken - indent = { enable = true, disable = { 'python', 'css' } }, - -- autotag = { enable = true }, - -- autopairs = { - -- enable = true, - -- }, - } -end - -return M diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua deleted file mode 100644 index 6df27c7..0000000 --- a/lua/plugins/trouble.lua +++ /dev/null @@ -1,61 +0,0 @@ -local M = { - 'folke/trouble.nvim', - -- dependencies = { - -- 'nvim-tree/nvim-web-devicons', - -- }, - cmd = { 'TroubleToggle', 'Trouble' }, -} - -function M.config() - local trouble = require 'trouble' - - trouble.setup { - position = 'bottom', -- position of the list can be: bottom, top, left, right - height = 10, -- height of the trouble list when position is top or bottom - width = 50, -- width of the list when position is left or right - icons = true, -- use devicons for filenames - mode = 'quickfix', -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" - fold_open = '', -- icon used for open folds - fold_closed = '', -- icon used for closed folds - group = true, -- group results by file - padding = true, -- add an extra new line on top of the list - action_keys = { -- key mappings for actions in the trouble list - -- map to {} to remove a mapping, for example: - -- close = {}, - close = 'q', -- close the list - cancel = '', -- cancel the preview and get back to your last window / buffer / cursor - refresh = 'r', -- manually refresh - jump_close = { '', '' }, -- jump to the diagnostic or open / close folds - open_split = { '' }, -- open buffer in new split - open_vsplit = { '' }, -- open buffer in new vsplit - open_tab = { '' }, -- open buffer in new tab - jump = { 'o' }, -- jump to the diagnostic and close the list - toggle_mode = 'm', -- toggle between "workspace" and "document" diagnostics mode - toggle_preview = 'P', -- toggle auto_preview - hover = 'K', -- opens a small popup with the full multiline message - preview = 'p', -- preview the diagnostic location - close_folds = { 'zM', 'zm' }, -- close all folds - open_folds = { 'zR', 'zr' }, -- open all folds - toggle_fold = { 'zA', 'za' }, -- toggle fold of current file - previous = 'k', -- preview item - next = 'j', -- next item - }, - indent_lines = true, -- add an indent guide below the fold icons - auto_open = false, -- automatically open the list when you have diagnostics - auto_close = false, -- automatically close the list when you have no diagnostics - auto_preview = false, -- automatically preview the location of the diagnostic. to close preview and go back to last window - auto_fold = false, -- automatically fold a file trouble list at creation - auto_jump = { 'lsp_definitions' }, -- for the given modes, automatically jump if there is only a single result - signs = { - -- icons / text used for a diagnostic - error = '', - warning = '', - hint = '', - information = '', - other = '﫠', - }, - use_diagnostic_signs = false, -- enabling this will use the signs defined in your lsp client - } -end - -return M