neovim

Personal neovim configuration files
git clone git://gtms.dev/neovim.git
Log | Files | Refs

commit 411101818afab0c6ff553ed7f5cf70c50a36bf78
parent db6f1d569e4e938aedc2579ac02d13195fbb2adc
Author: Tomas Nemec <nemi@skaut.cz>
Date:   Wed, 19 Jan 2022 15:04:51 +0100

update

Diffstat:
Mlua/tms/lsp/servers.lua | 7+++++++
Alua/tms/p/sidebar/files.lua | 118+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Alua/tms/p/sidebar/gitlab.lua | 20++++++++++++++++++++
Alua/tms/p/sidebar/init.lua | 18++++++++++++++++++
Mlua/tms/plugins.lua | 5++---
5 files changed, 165 insertions(+), 3 deletions(-)

diff --git a/lua/tms/lsp/servers.lua b/lua/tms/lsp/servers.lua @@ -7,6 +7,13 @@ M.setup = function(name, opts) return opts end +M.sumneko_lua = function(opts) + opts.settings = { + Lua = {runtime = {version = 'LuaJIT'}, diagnostics = {globals = {'vim'}}, telemetry = {enable = false}}, + } + return opts +end + M.emmet_ls = function(opts) opts.root_dir = require('lspconfig').util.root_pattern('.git', vim.fn.getcwd()) return opts diff --git a/lua/tms/p/sidebar/files.lua b/lua/tms/p/sidebar/files.lua @@ -0,0 +1,118 @@ +local Loclist = require('sidebar-nvim.components.loclist') +local has_devicons, devicons = pcall(require, 'nvim-web-devicons') + +local M = {} + +local icons = { -- + directory_closed = '', + file = '', +} + +local loclist = Loclist:new({ommit_single_group = false, show_group_count = false}) + +local function get_fileicon(filename) + if has_devicons and devicons.has_loaded() then + local extension = filename:match('^.+%.(.+)$') + local fileicon, _ = devicons.get_icon_color(filename, extension) + local highlight = 'SidebarNvimNormal' + + if extension then highlight = 'DevIcon' .. extension end + return {text = fileicon or icons['file'], hl = highlight} + end + return {text = icons['file'] .. ' '} +end + +local function build_loclist(parent, files) + local items = {} + + for _, file in ipairs(files) do + if file.type == 'file' then + local icon = get_fileicon(file.name) + + items[#items + 1] = { + group = parent, + left = { -- + {text = icon.text .. ' ', hl = icon.hl}, + {text = file.name}, + }, + name = file.name, + path = file.path, + type = file.type, + parent = file.parent, + node = file, + } + elseif file.type == 'directory' then + local icon + icon = icons['directory_closed'] + + items[#items + 1] = { + group = parent, + left = { -- + {text = icon .. ' ' .. file.name, hl = 'SidebarNvimFilesDirectory'}, + }, + name = file.name, + path = file.path, + type = file.type, + parent = file.parent, + node = file, + } + end + end + return items +end + +M.update = function() + local ft = vim.api.nvim_buf_get_option(0, 'ft') + if ft == '' then return end + if ft == 'SidebarNvim' then return end + if ft == 'TelescopePrompt' then return end + if ft == 'help' then return end + + local directory = vim.fn.expand('%:p:h') + local relative = vim.fn.expand('%:h') + + local list = {} + local handle = vim.loop.fs_scandir(directory) + while handle do + local filename, filetype = vim.loop.fs_scandir_next(handle) + if not filename then break end + if filetype == 'file' then + table.insert(list, { -- + name = filename, + type = 'file', + path = directory .. '/' .. filename, + }) + elseif filetype == 'directory' then + table.insert(list, { -- + name = filename, + type = 'directory', + path = directory .. '/' .. filename, + }) + end + end + + loclist:set_items(build_loclist(relative, list), {remove_groups = true}) +end + +M.section = { + title = 'Files', + setup = function() + vim.api.nvim_exec([[ + augroup user_sidebar_files_update + autocmd! + autocmd BufEnter * lua require'tms.p.sidebar.files'.update() + augroup END + ]], false) + end, + update = function(_) M.update() end, + draw = function(ctx) + local lines = {} + local hl = {} + + loclist:draw(ctx, lines, hl) + + return {lines = lines, hl = hl} + end, +} + +return M diff --git a/lua/tms/p/sidebar/gitlab.lua b/lua/tms/p/sidebar/gitlab.lua @@ -0,0 +1,20 @@ +local M = {} + +local gitlab_issues = {} + +M.section = { + title = 'Gitlab issues', + setup = function(_) + require('plenary.job'):new({ + command = 'glab', + args = {'mis', 'list', '-a', '@me'}, + on_exit = function(j, code) + if code > 0 then gitlab_issues = {} end + gitlab_issues = j:result() + end, + }):start() + end, + draw = function(_) return gitlab_issues end, +} + +return M diff --git a/lua/tms/p/sidebar/init.lua b/lua/tms/p/sidebar/init.lua @@ -0,0 +1,18 @@ +local files = require('tms.p.sidebar.files') +local gitlab = require('tms.p.sidebar.gitlab') +local M = {} + +M.setup = function() + require('sidebar-nvim').setup({ + -- + initial_width = 80, + hide_statusline = true, + sections = {files.section, 'git', 'diagnostics', gitlab.section}, + disable_closing_prompt = true, + }) + + vim.keymap.nnoremap {'<space>s', '<cmd>SidebarNvimToggle<cr>'} + vim.keymap.nnoremap {'<space>S', '<cmd>SidebarNvimFocus<cr>'} +end + +return M diff --git a/lua/tms/plugins.lua b/lua/tms/plugins.lua @@ -199,6 +199,7 @@ return packer.startup({ end, } use {'luukvbaal/stabilize.nvim'} + use {'sidebar-nvim/sidebar.nvim', config = function() require('tms.p.sidebar').setup() end} -- Notes use { @@ -390,6 +391,7 @@ return packer.startup({ config = function() require('tms.p.nullls').setup() end, } use { + disable = true, 'stevearc/aerial.nvim', after = {'telescope.nvim', 'nvim-treesitter'}, setup = function() vim.g.aerial = {backends = {'lsp', 'treesitter'}, highlight_on_jump = 0} end, @@ -460,11 +462,8 @@ return packer.startup({ vim.keymap.nnoremap {'<space>k', telescope.keymaps} vim.keymap.nnoremap {'<space>m', telescope.b.man_pages} vim.keymap.nnoremap {'<space>p', telescope.reloader} - vim.keymap.nnoremap {'<space>S', telescope.spell_suggest} -- extensions - vim.keymap.nnoremap {'<space>s', telescope.snippets} vim.keymap.nnoremap {'<space>M', telescope.media_files} - vim.keymap.nnoremap {'<space>r', telescope.aerial} -- custom vim.keymap.nnoremap {'<space>n', telescope.edit_neovim} -- maybe - almost unsuedtelescope