diff options
| author | Kyren223 <ulmliad223@gmail.com> | 2024-07-23 19:53:55 +0300 |
|---|---|---|
| committer | Kyren223 <ulmliad223@gmail.com> | 2024-07-23 19:53:55 +0300 |
| commit | f7e480cd62e58e913bfb0a93f36f4dca026352e5 (patch) | |
| tree | 1dd98d7911acf2f2222d23cd267e22e41f1e12f8 /.config/nvim/lua/custom/configs | |
| parent | 09623783f8b2c5bf6fa3aa490f973d36080df907 (diff) | |
refactor(neovim): renamed custom/configs -> custom/config
Diffstat (limited to '.config/nvim/lua/custom/configs')
| -rw-r--r-- | .config/nvim/lua/custom/configs/completion.lua | 122 | ||||
| -rw-r--r-- | .config/nvim/lua/custom/configs/language-servers.lua | 29 | ||||
| -rw-r--r-- | .config/nvim/lua/custom/configs/lsp-keymaps.lua | 58 | ||||
| -rw-r--r-- | .config/nvim/lua/custom/configs/lsp.lua | 63 | ||||
| -rw-r--r-- | .config/nvim/lua/custom/configs/lualine.lua | 92 | ||||
| -rw-r--r-- | .config/nvim/lua/custom/configs/mason.lua | 33 | ||||
| -rw-r--r-- | .config/nvim/lua/custom/configs/telescope.lua | 40 |
7 files changed, 0 insertions, 437 deletions
diff --git a/.config/nvim/lua/custom/configs/completion.lua b/.config/nvim/lua/custom/configs/completion.lua deleted file mode 100644 index 127f7b3..0000000 --- a/.config/nvim/lua/custom/configs/completion.lua +++ /dev/null @@ -1,122 +0,0 @@ --- Load snippets -for _, ft_path in ipairs(vim.api.nvim_get_runtime_file('lua/custom/snippets/*.lua', true)) do - loadfile(ft_path)() -end - -local luasnip = require('luasnip') -local lspkind = require('lspkind') -local cmp = require('cmp') - --- Enable paretheses for function completions -cmp.event:on('confirm_done', require('nvim-autopairs.completion.cmp').on_confirm_done()) - --- Helper functions -local function snippet_jump(jump_amount) - return cmp.mapping(function(fallback) - if luasnip.locally_jumpable(jump_amount) then - luasnip.jump(jump_amount) - else - fallback() - end - end, { 'i', 's' }) -end - -local function is_enabled() - local context = require('cmp.config.context') - - local is_in_comment = context.in_treesitter_capture('comment') or context.in_syntax_group('Comment') - if is_in_comment then - return false - end - - return true -end - -cmp.setup({ - enabled = is_enabled, - completion = { completeopt = 'menu,menuone,noinsert' }, - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, -- for lsp - { name = 'luasnip' }, -- for snippets - { name = 'lazydev', group_index = 0 }, -- for lazydev.nvim - { name = 'path' }, -- for filesystem - }, {}), - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - window = { - documentation = cmp.config.window.bordered(), - completion = { - border = 'rounded', - winhighlight = 'Normal:Pmenu,FloatBorder:Pmenu,Search:None', - col_offset = -3, - side_padding = 0, - }, - }, - mapping = cmp.mapping.preset.insert({ - ['<Tab>'] = snippet_jump(1), - ['<S-Tab>'] = snippet_jump(-1), - ['<C-Space>'] = cmp.mapping.complete(), -- invoke completion - ['<CR>'] = cmp.mapping.confirm({ select = true, behavior = cmp.ConfirmBehavior.Insert }), - ['<C-u>'] = cmp.mapping.scroll_docs(-4), - ['<C-d>'] = cmp.mapping.scroll_docs(4), - ['<C-m>'] = cmp.mapping.abort(), - ['<C-n>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), - ['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), - }), - ---@diagnostic disable-next-line: missing-fields - formatting = { - fields = { 'kind', 'abbr', 'menu' }, - format = function(entry, vim_item) - local kind = lspkind.cmp_format({ mode = 'symbol_text', maxwidth = 50 })(entry, vim_item) - local strings = vim.split(kind.kind, '%s', { trimempty = true }) - kind.kind = ' ' .. (strings[1] or '') .. ' ' -- left (icon) - kind.menu = ' ' .. (strings[2] or '') .. '' -- right (text) - return kind - end, - }, -}) - --- -- Customization for Pmenu --- vim.api.nvim_set_hl(0, 'PmenuSel', { bg = '#282C34', fg = 'NONE' }) --- vim.api.nvim_set_hl(0, 'Pmenu', { fg = '#C5CDD9', bg = '#22252A' }) --- -vim.api.nvim_set_hl(0, 'CmpItemAbbrDeprecated', { fg = '#ff8294', bg = 'NONE', strikethrough = true }) --- vim.api.nvim_set_hl(0, 'CmpItemAbbrMatch', { fg = '#82AAFF', bg = 'NONE', bold = true }) --- vim.api.nvim_set_hl(0, 'CmpItemAbbrMatchFuzzy', { fg = '#82AAFF', bg = 'NONE', bold = true }) --- vim.api.nvim_set_hl(0, 'CmpItemMenu', { fg = '#C792EA', bg = 'NONE', italic = true }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindField', { fg = '#EED8DA', bg = '#B5585F' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindProperty', { fg = '#EED8DA', bg = '#B5585F' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindEvent', { fg = '#EED8DA', bg = '#B5585F' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindText', { fg = '#C3E88D', bg = '#9FBD73' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindEnum', { fg = '#C3E88D', bg = '#9FBD73' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindKeyword', { fg = '#C3E88D', bg = '#9FBD73' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindConstant', { fg = '#FFE082', bg = '#D4BB6C' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindConstructor', { fg = '#FFE082', bg = '#D4BB6C' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindReference', { fg = '#FFE082', bg = '#D4BB6C' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindFunction', { fg = '#EADFF0', bg = '#A377BF' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindStruct', { fg = '#EADFF0', bg = '#A377BF' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindClass', { fg = '#EADFF0', bg = '#A377BF' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindModule', { fg = '#EADFF0', bg = '#A377BF' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindOperator', { fg = '#EADFF0', bg = '#A377BF' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindVariable', { fg = '#C5CDD9', bg = '#7E8294' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindFile', { fg = '#C5CDD9', bg = '#7E8294' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindUnit', { fg = '#F5EBD9', bg = '#D4A959' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindSnippet', { fg = '#F5EBD9', bg = '#D4A959' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindFolder', { fg = '#F5EBD9', bg = '#D4A959' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindMethod', { fg = '#DDE5F5', bg = '#6C8ED4' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindValue', { fg = '#DDE5F5', bg = '#6C8ED4' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindEnumMember', { fg = '#DDE5F5', bg = '#6C8ED4' }) --- --- vim.api.nvim_set_hl(0, 'CmpItemKindInterface', { fg = '#D8EEEB', bg = '#58B5A8' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindColor', { fg = '#D8EEEB', bg = '#58B5A8' }) --- vim.api.nvim_set_hl(0, 'CmpItemKindTypeParameter', { fg = '#D8EEEB', bg = '#58B5A8' }) diff --git a/.config/nvim/lua/custom/configs/language-servers.lua b/.config/nvim/lua/custom/configs/language-servers.lua deleted file mode 100644 index 1165994..0000000 --- a/.config/nvim/lua/custom/configs/language-servers.lua +++ /dev/null @@ -1,29 +0,0 @@ --- NOTE: A list of language servers (and potentially their config) --- Accepts either true to enable, false to disable or a table with settings -return { - -- lua_ls = { - -- settings = { - -- diagnostics = { - -- globals = { 'vim' }, - -- }, - -- workspace = { - -- library = { - -- [vim.fn.expand('$VIMRUNTIME/lua')] = true, - -- [vim.fn.stdpath('config') .. '/lua'] = true, - -- }, - -- }, - -- }, - -- }, -- lua - lua_ls = true, -- lua - clangd = true, -- C/C++ - gradle_ls = true, -- java package manager - jdtls = true, -- java eclipse lsp - kotlin_language_server = true, -- kotlin - pyright = true, -- python - rust_analyzer = true, -- rust - bashls = true, -- bash - taplo = true, -- toml - lemminx = true, -- xml - yamlls = true, -- yaml - jsonls = true, -- json -} diff --git a/.config/nvim/lua/custom/configs/lsp-keymaps.lua b/.config/nvim/lua/custom/configs/lsp-keymaps.lua deleted file mode 100644 index f43a03e..0000000 --- a/.config/nvim/lua/custom/configs/lsp-keymaps.lua +++ /dev/null @@ -1,58 +0,0 @@ -local severity = vim.diagnostic.severity -local function next_diagnostic(diagnostic_severity) - return function() - require('lspsaga.diagnostic'):goto_next({ severity = diagnostic_severity }) - end -end -local function prev_diagnostic(diagnostic_severity) - return function() - require('lspsaga.diagnostic'):goto_prev({ severity = diagnostic_severity }) - end -end -local function cursor_diagnostics() - vim.diagnostic.open_float({ - scope = 'cursor', - border = 'single', - }) -end - -local keymaps = { - { 'n', 'gd', '<cmd>Telescope lsp_definitions<cr>', { desc = '[G]oto [D]efinition' } }, - { 'n', 'gu', '<cmd>Telescope lsp_references<cr>', { desc = '[G]oto [U]sages' } }, - { 'n', 'gi', '<cmd>Telescope lsp_implementations<cr>', { desc = '[G]oto [I]mplementations' } }, - { 'n', 'gt', '<cmd>Telescope lsp_type_definitions<cr>', { desc = '[G]oto [T]ype Definitions' } }, - { 'n', '<leader>ds', '<cmd>Telescope lsp_document_symbols<cr>', { desc = '[D]ocument [S]symbols' } }, - { 'n', '<leader>ps', '<cmd>Telescope lsp_workspace_symbols<cr>', { desc = '[P]roject [S]ymbols' } }, - { { 'n', 'i' }, '<C-p>', vim.lsp.buf.signature_help, { desc = 'Show [P]arameters' } }, - { 'n', 'K', '<cmd>Lspsaga hover_doc<cr>', { desc = 'Documentation' } }, - { 'n', 'R', '<cmd>Lspsaga rename<cr>', { desc = '[R]ename' } }, - { { 'n', 'i' }, '<M-Enter>', '<cmd>Lspsaga code_action<cr>', { desc = 'Code Actions' } }, - { 'n', '<leader>ca', '<cmd>Lspsaga code_action<cr><Esc>', { desc = '[C]ode [A]ctions' } }, - { 'n', 'ge', next_diagnostic(severity.ERROR), { desc = '[G]oto [E]rror' } }, - { 'n', 'gE', prev_diagnostic(severity.ERROR), { desc = '[G]oto [E]rror (prev)' } }, - { 'n', 'gw', next_diagnostic(severity.ERROR), { desc = '[G]oto [W]arning' } }, - { 'n', 'gW', prev_diagnostic(severity.ERROR), { desc = '[G]oto [W]arning (prev)' } }, - { 'n', '<leader>D', cursor_diagnostics, { desc = '[D]iagnostics under cursor' } }, -} - -local M = {} - ---- Registers LSP keymaps for the given buffer ----@param bufnr number: the id of the buffer -M.setup = function(bufnr) - for _, keymap in ipairs(keymaps) do - local mode = keymap[1] - local lhs = keymap[2] - local rhs = keymap[3] - local opts = keymap[4] - - if not opts then - opts = {} - end - - opts.buffer = bufnr - vim.keymap.set(mode, lhs, rhs, opts) - end -end - -return M diff --git a/.config/nvim/lua/custom/configs/lsp.lua b/.config/nvim/lua/custom/configs/lsp.lua deleted file mode 100644 index afae5af..0000000 --- a/.config/nvim/lua/custom/configs/lsp.lua +++ /dev/null @@ -1,63 +0,0 @@ -local capabilities = require('cmp_nvim_lsp').default_capabilities() -local servers = require('custom.configs.language-servers') - -local lspconfig = require('lspconfig') -for name, config in pairs(servers) do - if config == true then - ---@diagnostic disable-next-line: cast-local-type - config = {} - end - ---@diagnostic disable-next-line: cast-local-type - config = vim.tbl_deep_extend('force', {}, { - capabilities = capabilities, - }, config) - - lspconfig[name].setup(config) -end - -vim.api.nvim_create_autocmd('LspAttach', { - callback = function(args) - local bufnr = args.buf - local client = assert(vim.lsp.get_client_by_id(args.data.client_id), 'must have valid client') - - local settings = servers[client.name] - if type(settings) ~= 'table' then - ---@diagnostic disable-next-line: cast-local-type - settings = {} - end - - -- Override server capabilities - if settings.server_capabilities then - for k, v in pairs(settings.server_capabilities) do - if v == vim.NIL then - v = nil - end - client.server_capabilities[k] = v - end - end - - -- Register LSP keymaps local to buffer - require('custom.configs.lsp-keymaps').setup(bufnr) - end, -}) - --- TODO: Decide if you want to use conform or not --- --- -- Autoformatting Setup --- require('conform').setup({ --- formatters_by_ft = { --- lua = { 'stylua' }, --- }, --- }) --- --- vim.api.nvim_create_autocmd('BufWritePre', { --- callback = function(args) --- require('conform').format({ --- bufnr = args.buf, --- lsp_fallback = true, --- quiet = true, --- }) --- end, --- }) - -vim.diagnostic.config({ virtual_text = false }) diff --git a/.config/nvim/lua/custom/configs/lualine.lua b/.config/nvim/lua/custom/configs/lualine.lua deleted file mode 100644 index ce581c4..0000000 --- a/.config/nvim/lua/custom/configs/lualine.lua +++ /dev/null @@ -1,92 +0,0 @@ -local lualine = require('lualine') -local lsp_progress = require('lsp-progress') - -local progress_filled = '█' -local progress_empty = '░' -local function progress_bar(percentage, width) - -- Ensure i is an integer between 0 and width (inclusive) - local i = math.max(0, math.min(math.floor(width * percentage), width)) - return string.rep(progress_filled, i) .. string.rep(progress_empty, width - i) -end - -local progress_bar_width = 10 -lsp_progress.setup({ - format = function(client_messages) -- global - local sign = ' LSP' - if #client_messages > 0 then - return sign .. ' ' .. table.concat(client_messages, ' ') - end - if #require('lsp-progress.api').lsp_clients() > 0 then - return sign - end - return '' - end, - client_format = function(_, _, series_messages) -- per lsp - return #series_messages > 0 and table.concat(series_messages, ', ') or nil - end, - series_format = function(title, message, percentage, done) -- per progress - local builder = {} - local has_title = false - local has_message = false - if type(title) == 'string' and string.len(title) > 0 then - table.insert(builder, title .. ':') - has_title = true - end - if percentage then - table.insert(builder, string.format('%.0f%%', percentage)) - table.insert(builder, 1, progress_bar(percentage / 100, progress_bar_width)) - end - if type(message) == 'string' and string.len(message) > 0 then - table.insert(builder, string.format('(%s)', message)) - has_message = true - end - if done and (has_title or has_message) then - table.insert(builder, ' ') - end - return table.concat(builder, ' ') - end, -}) - -lualine.setup({ - options = { - globalstatus = true, - theme = 'auto', - }, - sections = { - lualine_a = { { 'mode', icon = '' } }, - lualine_b = { - require('auto-session.lib').current_session_name, - { 'branch', icon = '' }, - { - 'diagnostics', - symbols = { - error = ' ', - warn = ' ', - info = ' ', - hint = ' ', - }, - }, - }, - lualine_c = { - function() - return lsp_progress.progress() - end, - }, - lualine_x = { - 'searchcount', - 'encoding', - 'fileformat', - 'filetype', - }, - lualine_y = { 'progress' }, - lualine_z = { 'location' }, - }, - extensions = { 'oil', 'trouble' }, -}) - --- Refresh lualine when lsp progress is updated -vim.api.nvim_create_autocmd('User', { - group = vim.api.nvim_create_augroup('lualine_augroup', { clear = true }), - pattern = 'LspProgressStatusUpdated', - callback = require('lualine').refresh, -}) diff --git a/.config/nvim/lua/custom/configs/mason.lua b/.config/nvim/lua/custom/configs/mason.lua deleted file mode 100644 index d7a537b..0000000 --- a/.config/nvim/lua/custom/configs/mason.lua +++ /dev/null @@ -1,33 +0,0 @@ --- NOTE: Not language servers but still make sure mason installs them -local ensure_installed = { - stylua = true, -- lua formatting -} -local servers = require('custom.configs.language-servers') - -require('mason').setup({ - ui = { - icons = { - package_installed = '✓', - package_pending = '➜', - package_uninstalled = '✗', - }, - }, -}) - -local servers_to_install = vim.tbl_filter(function(key) - local server = servers[key] - if type(server) == 'table' then - return true - else - return server - end -end, vim.tbl_keys(servers)) - -vim.list_extend(ensure_installed, servers_to_install) -require('mason-lspconfig').setup({ ensure_installed = servers_to_install }) - -require('mason-tool-installer').setup({ - ensure_installed = { - 'stylua', -- lua formatter - }, -}) diff --git a/.config/nvim/lua/custom/configs/telescope.lua b/.config/nvim/lua/custom/configs/telescope.lua deleted file mode 100644 index b554a33..0000000 --- a/.config/nvim/lua/custom/configs/telescope.lua +++ /dev/null @@ -1,40 +0,0 @@ -local telescope = require('telescope') -telescope.setup({ - pickers = { - find_files = { follow = true }, - grep_string = { additional_args = '--follow' }, - live_grep = { additional_args = '--follow' }, - }, - extensions = { - fzf = { - fuzzy = true, -- false will only do exact matching - override_generic_sorter = true, - override_file_sorter = true, - case_mode = 'smart_case', -- default "smart_case" or "ignore_case" or "respect_case" - }, - ['ui-select'] = { - require('telescope.themes').get_dropdown({}), - }, - }, -}) - -pcall(telescope.load_extension('ui-select')) -pcall(telescope.load_extension('fzf')) - -local builtin = require('telescope.builtin') -local function find_all() - builtin.find_files({ - cwd = '~', - hidden = true, - no_ignore = true, - no_ignore_parent = true, - }) -end - -vim.keymap.set('n', '<leader>fs', builtin.find_files, { desc = '[F]ile [S]ystem' }) -vim.keymap.set('n', '<leader>fa', find_all, { desc = '[F]ind [A]ll files' }) -vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = '[F]ind [H]elp' }) -vim.keymap.set('n', '<leader>fm', builtin.man_pages, { desc = '[F]ind [M]an Pages' }) -vim.keymap.set('n', '<leader>lv', builtin.live_grep, { desc = '[L]ive [G]rep' }) -vim.keymap.set('n', '<leader>f.', builtin.oldfiles, { desc = '[F]ind Recent Files' }) -vim.keymap.set('n', '<leader>th', builtin.colorscheme, { desc = 'List [Th]eme' }) |
