diff options
Diffstat (limited to '.config/nvim/lua/custom/configs')
| -rw-r--r-- | .config/nvim/lua/custom/configs/language-servers.lua | 27 | ||||
| -rw-r--r-- | .config/nvim/lua/custom/configs/statusline.lua | 92 | ||||
| -rw-r--r-- | .config/nvim/lua/custom/configs/telescope.lua | 40 |
3 files changed, 146 insertions, 13 deletions
diff --git a/.config/nvim/lua/custom/configs/language-servers.lua b/.config/nvim/lua/custom/configs/language-servers.lua index 4fd3fff..1165994 100644 --- a/.config/nvim/lua/custom/configs/language-servers.lua +++ b/.config/nvim/lua/custom/configs/language-servers.lua @@ -1,19 +1,20 @@ -- 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 = { + -- 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 diff --git a/.config/nvim/lua/custom/configs/statusline.lua b/.config/nvim/lua/custom/configs/statusline.lua new file mode 100644 index 0000000..ce581c4 --- /dev/null +++ b/.config/nvim/lua/custom/configs/statusline.lua @@ -0,0 +1,92 @@ +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/telescope.lua b/.config/nvim/lua/custom/configs/telescope.lua new file mode 100644 index 0000000..b554a33 --- /dev/null +++ b/.config/nvim/lua/custom/configs/telescope.lua @@ -0,0 +1,40 @@ +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' }) |
