From cc4f9a5c73410b500ffb3a22a745b09098fab9a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20=F0=9F=9A=B6?= Date: Wed, 9 Oct 2024 20:54:21 +1100 Subject: [PATCH] backup vima --- vima-old/README.md | 8 - vima-old/init.lua | 5 + vima-old/lua/vima/Languages/init.lua | 17 - vima-old/lua/vima/Languages/lua.lua | 60 ---- vima-old/lua/vima/core.lua | 83 ++--- vima-old/lua/vima/plugins/autopairs.lua | 25 -- vima-old/lua/vima/plugins/colorscheme.lua | 24 +- vima-old/lua/vima/plugins/comment.lua | 51 +-- vima-old/lua/vima/plugins/completion.lua | 145 --------- vima-old/lua/vima/plugins/gitsigns.lua | 13 - vima-old/lua/vima/plugins/init.lua | 294 +++++++++--------- vima-old/lua/vima/plugins/lsp.lua | 135 -------- .../lua/vima/plugins/lualine.lua | 0 vima-old/lua/vima/plugins/null-ls.lua | 23 -- vima-old/lua/vima/plugins/nvimtree.lua | 17 - .../lua/vima/plugins/pounce.lua | 0 vima-old/lua/vima/plugins/project.lua | 15 - vima-old/lua/vima/plugins/telescope.lua | 36 --- vima-old/lua/vima/plugins/treesitter.lua | 129 ++++++-- vima-old/lua/vima/plugins/whichkey.lua | 36 --- vima-old/lua/vima/utils.lua | 7 +- vima/init.lua | 7 - vima/lua/vima/core.lua | 70 ----- vima/lua/vima/plugins/colorscheme.lua | 25 -- vima/lua/vima/plugins/comment.lua | 21 -- vima/lua/vima/plugins/init.lua | 150 --------- vima/lua/vima/plugins/treesitter.lua | 109 ------- vima/lua/vima/utils.lua | 8 - 28 files changed, 338 insertions(+), 1175 deletions(-) delete mode 100644 vima-old/README.md delete mode 100644 vima-old/lua/vima/Languages/init.lua delete mode 100644 vima-old/lua/vima/Languages/lua.lua delete mode 100644 vima-old/lua/vima/plugins/autopairs.lua delete mode 100644 vima-old/lua/vima/plugins/completion.lua delete mode 100644 vima-old/lua/vima/plugins/gitsigns.lua delete mode 100644 vima-old/lua/vima/plugins/lsp.lua rename {vima => vima-old}/lua/vima/plugins/lualine.lua (100%) delete mode 100644 vima-old/lua/vima/plugins/null-ls.lua delete mode 100644 vima-old/lua/vima/plugins/nvimtree.lua rename {vima => vima-old}/lua/vima/plugins/pounce.lua (100%) delete mode 100644 vima-old/lua/vima/plugins/project.lua delete mode 100644 vima-old/lua/vima/plugins/telescope.lua delete mode 100644 vima-old/lua/vima/plugins/whichkey.lua delete mode 100644 vima/init.lua delete mode 100644 vima/lua/vima/core.lua delete mode 100644 vima/lua/vima/plugins/colorscheme.lua delete mode 100644 vima/lua/vima/plugins/comment.lua delete mode 100644 vima/lua/vima/plugins/init.lua delete mode 100644 vima/lua/vima/plugins/treesitter.lua delete mode 100644 vima/lua/vima/utils.lua diff --git a/vima-old/README.md b/vima-old/README.md deleted file mode 100644 index f2e6100..0000000 --- a/vima-old/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Vima - -My attempt to create a neovim config for typescript and python development. - -## Features - -* Packer.nvim for package management -* Color scheme base16 + sync to base16 shell diff --git a/vima-old/init.lua b/vima-old/init.lua index 97fd614..bc6b3f4 100644 --- a/vima-old/init.lua +++ b/vima-old/init.lua @@ -1,2 +1,7 @@ +local present, _ = pcall(require, 'impatient') +if not present then + require('vima.utils').notify_missing('impatient') +end + require('vima.core') require('vima.plugins') diff --git a/vima-old/lua/vima/Languages/init.lua b/vima-old/lua/vima/Languages/init.lua deleted file mode 100644 index 3676972..0000000 --- a/vima-old/lua/vima/Languages/init.lua +++ /dev/null @@ -1,17 +0,0 @@ -local M = {} - -local supported_languages = { 'lua' } - -M.get_treesitter_languages = function() - return supported_languages -end - -M.setup_supported_lsps = function(setup_lsp, add_null_ls_sources) - for _, lang in ipairs(supported_languages) do - local lang_config = require('vima.Languages.' .. lang) - setup_lsp(lang_config.get_lsp_configs()) - add_null_ls_sources(lang_config.get_null_ls_sources()) - end -end - -return M diff --git a/vima-old/lua/vima/Languages/lua.lua b/vima-old/lua/vima/Languages/lua.lua deleted file mode 100644 index bdf3171..0000000 --- a/vima-old/lua/vima/Languages/lua.lua +++ /dev/null @@ -1,60 +0,0 @@ -local M = {} - -local runtime_path = vim.split(package.path, ';') -table.insert(runtime_path, 'lua/?.lua') -table.insert(runtime_path, 'lua/?/init.lua') - -local lsp_config = { - Lua = { - runtime = { - - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT', - -- Setup your lua path - path = runtime_path, - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { 'vim' }, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file('', true), - }, - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = { - enable = false, - }, - }, -} - -local status_ok, lua_dev = pcall(require, 'lua-dev') -if status_ok then - lsp_config = lua_dev.setup({ lspconfig = lsp_config }) -end - -M.get_lsp_configs = function() - return { - sumneko_lua = { - settings = lsp_config, - on_attach = function(client, bufnr) end, - }, - } -end - -M.get_null_ls_sources = function() - local null_ls_status_ok, null_ls = pcall(require, 'null-ls') - if not null_ls_status_ok then - vim.notify('Failed to load null-ls.') - return {} - end - return { - null_ls.builtins.formatting.stylua.with({ - condition = function(utils) - return vim.fn.executable('stylua') > 0 - end, - }), - } -end - -return M diff --git a/vima-old/lua/vima/core.lua b/vima-old/lua/vima/core.lua index d51d427..95426d4 100644 --- a/vima-old/lua/vima/core.lua +++ b/vima-old/lua/vima/core.lua @@ -1,63 +1,70 @@ --- Core configuration --------------------------------------------------------------------------------- - local opt = vim.opt +local map = vim.keymap.set -opt.autowriteall = true +opt.backup = false opt.clipboard = 'unnamedplus' -opt.cmdheight = 2 -opt.colorcolumn = '120' -opt.completeopt = { 'menuone', 'preview' } -opt.cursorline = true opt.expandtab = true opt.fileencoding = 'utf-8' -opt.fillchars = { eob = ' ' } -opt.foldenable = false -opt.foldmethod = 'syntax' +opt.hidden = true +opt.hlsearch = true opt.ignorecase = true opt.iskeyword:append('-') -opt.list = true -opt.listchars = 'tab:⇥ ,trail:·' -opt.mouse = 'a' -opt.number = true -opt.pumheight = 15 -opt.relativenumber = true -opt.scrolloff = 5 opt.shiftround = true opt.shiftwidth = 2 -opt.shortmess:append('cI') -opt.showmode = false -opt.showtabline = 2 -opt.sidescrolloff = 10 -opt.signcolumn = 'yes' opt.smartcase = true opt.smartindent = true opt.splitbelow = true opt.splitright = true opt.swapfile = false -opt.switchbuf = 'useopen,usetab,newtab' -opt.tabstop = 2 -opt.termguicolors = true -opt.timeoutlen = 300 -opt.title = true +opt.tabstop = 4 +opt.timeout = true +opt.timeoutlen = 1000 opt.undofile = true opt.undolevels = 2000 opt.updatetime = 300 opt.visualbell = true opt.whichwrap:append('<>[]hl') -opt.wildignore = 'build,.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,*.pyc' -opt.wildmode = 'longest,full' opt.wrap = false opt.writebackup = false --- Core mappings --------------------------------------------------------------------------------- +if not vim.g.vscode then + opt.cmdheight = 2 + opt.colorcolumn = '120' + opt.completeopt = { 'menuone', 'noselect' } + opt.conceallevel = 0 + opt.cursorline = true + opt.fillchars = { eob = ' ' } + opt.foldenable = false + opt.foldmethod = 'syntax' + opt.list = true + opt.listchars = 'tab:⇥ ,trail:·' + opt.mouse = 'a' + opt.number = true + opt.numberwidth = 3 + opt.pumheight = 10 + opt.relativenumber = true + opt.ruler = true + opt.scrolloff = 5 + opt.shortmess:append('cI') + opt.showmode = false + opt.showtabline = 2 + opt.sidescrolloff = 10 + opt.signcolumn = 'yes' + opt.switchbuf = 'useopen,usetab,newtab' + opt.termguicolors = true + opt.title = true + opt.wildignore = 'build,.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,*.pyc' + opt.wildmode = 'longest,full' +end + +-- disable bundled plugins +vim.g.loaded_matchit = 1 -local map = require('vima.utils').map +map("i", "jj", "") +map("i", "jk", "") --- Space as leader key -vim.g.mapleader = ' ' -map('', '', '') +map("v", "<", "", ">gv") --- Insert mode mappings -map('i', 'jk', '') +map({ 'n', 'v' }, "c", '"_c') +map({ 'n', 'v' }, "d", '"_d') diff --git a/vima-old/lua/vima/plugins/autopairs.lua b/vima-old/lua/vima/plugins/autopairs.lua deleted file mode 100644 index 9e9f6ef..0000000 --- a/vima-old/lua/vima/plugins/autopairs.lua +++ /dev/null @@ -1,25 +0,0 @@ -local status_ok, npairs = pcall(require, 'nvim-autopairs') -if not status_ok then - vim.notify('Failed to load autopairs.') - return -end - -npairs.setup({ - check_ts = true, - ts_config = {}, - disable_filetype = { 'TelescopePrompt' }, - fast_wrap = { offset = 0 }, -}) - --- Map --- https://github.com/windwp/nvim-autopairs#you-need-to-add-mapping-cr-on-nvim-cmp-setupcheck-readmemd-on-nvim-cmp-repo - -local cmp_autopairs = require('nvim-autopairs.completion.cmp') - -local cmp_status_ok, cmp = pcall(require, 'cmp') -if not cmp_status_ok then - vim.notify('Failed to load nvim-cmp.') - return -end - -cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) diff --git a/vima-old/lua/vima/plugins/colorscheme.lua b/vima-old/lua/vima/plugins/colorscheme.lua index a4106fe..143313b 100644 --- a/vima-old/lua/vima/plugins/colorscheme.lua +++ b/vima-old/lua/vima/plugins/colorscheme.lua @@ -1,11 +1,25 @@ +if vim.g.vscode then + return +end + vim.g.base16colorspace = 256 -local status_ok, _ = pcall(vim.cmd, 'source $HOME/.vimrc_background') -if status_ok then - return -end +local base16_theme = 'base16-' .. (vim.env.BASE16_THEME or 'default-dark') -status_ok, _ = pcall(vim.cmd, 'colorscheme base16-default-dark') +status_ok, _ = pcall(vim.cmd, 'colorscheme ' .. base16_theme) if not status_ok then vim.notify('Failed to load base16 colorscheme.') + return end + +-- https://github.com/RRethy/nvim-base16/issues/32 fix telescope borders +vim.cmd([[highlight! link TelescopeSelection Visual]]) +vim.cmd([[highlight! link TelescopeNormal Normal]]) +vim.cmd([[highlight! link TelescopePromptNormal TelescopeNormal]]) +vim.cmd([[highlight! link TelescopeBorder TelescopeNormal]]) +vim.cmd([[highlight! link TelescopePromptBorder TelescopeBorder]]) +vim.cmd([[highlight! link TelescopeTitle TelescopeBorder]]) +vim.cmd([[highlight! link TelescopePromptTitle TelescopeTitle]]) +vim.cmd([[highlight! link TelescopeResultsTitle TelescopeTitle]]) +vim.cmd([[highlight! link TelescopePreviewTitle TelescopeTitle]]) +vim.cmd([[highlight! link TelescopePromptPrefix Identifier]]) diff --git a/vima-old/lua/vima/plugins/comment.lua b/vima-old/lua/vima/plugins/comment.lua index 066de4f..ddd6bd3 100644 --- a/vima-old/lua/vima/plugins/comment.lua +++ b/vima-old/lua/vima/plugins/comment.lua @@ -1,40 +1,21 @@ -local status_ok, comment = pcall(require, 'Comment') -if not status_ok then - vim.notify('Failed to load Comment.nvim.') - return +local present, comment = pcall(require, 'Comment') +if not present then + require('vima.utils').notify_missing('Comment.nvim') + return end -local status_ok, ts_context_commentstring = pcall(require, 'ts_context_commentstring') -if not status_ok then - vim.notify('Failed to load tree sitter comment string.') - return +local present, ts_context_commentstring = pcall(require, 'ts_context_commentstring') +if not present then + require('vima.utils').notify_missing('nvim_ts_context_commentstring') + return end --- TODO: fix whichkey --- TODO: Consider using ts_context_commentstring for all languages? - -comment.setup({ - ---@param ctx Ctx - pre_hook = function(ctx) - -- Only calculate commentstring for tsx filetypes - if vim.bo.filetype == 'typescriptreact' then - local U = require('Comment.utils') - - -- Detemine whether to use linewise or blockwise commentstring - local type = ctx.ctype == U.ctype.line and '__default' or '__multiline' - - -- Determine the location where to calculate commentstring from - local location = nil - if ctx.ctype == U.ctype.block 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, +require('Comment').setup({ + mappings = { + ---Operator-pending mapping; `gcc` `gbc` `gc[count]{motion}` `gb[count]{motion}` + basic = true, + ---Extra mapping; `gco`, `gcO`, `gcA` + extra = true, + }, + pre_hook = require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook(), }) diff --git a/vima-old/lua/vima/plugins/completion.lua b/vima-old/lua/vima/plugins/completion.lua deleted file mode 100644 index 5b128b1..0000000 --- a/vima-old/lua/vima/plugins/completion.lua +++ /dev/null @@ -1,145 +0,0 @@ -local cmp_status_ok, cmp = pcall(require, 'cmp') -if not cmp_status_ok then - vim.notify('Failed to load nvim-cmp.') - return -end - -local snip_status_ok, luasnip = pcall(require, 'luasnip') -if not snip_status_ok then - vim.notify('Failed to load luasnip.') - return -end - -require('luasnip/loaders/from_vscode').lazy_load() - -local check_backspace = function() - local col = vim.fn.col('.') - 1 - return col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') -end - ---   פּ ﯟ   some other good icons -local kind_icons = { - Text = '', - Method = 'm', - Function = '', - Constructor = '', - Field = '', - Variable = '', - Class = '', - Interface = '', - Module = '', - Property = '', - Unit = '', - Value = '', - Enum = '', - Keyword = '', - Snippet = '', - Color = '', - File = '', - Reference = '', - Folder = '', - EnumMember = '', - Constant = '', - Struct = '', - Event = '', - Operator = '', - TypeParameter = '', -} --- find more here: https://www.nerdfonts.com/cheat-sheet - -cmp.setup({ - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) -- For `luasnip` users. - end, - }, - mapping = { - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping(cmp.mapping.scroll_docs(-1), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.scroll_docs(1), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), - [''] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. - [''] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), - -- Accept currently selected item. If none selected, `select` first item. - -- Set `select` to `false` to only confirm explicitly selected items. - [''] = cmp.mapping.confirm({ select = true }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expandable() then - luasnip.expand() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif check_backspace() then - fallback() - else - fallback() - end - end, { - 'i', - 's', - }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { - 'i', - 's', - }), - }, - formatting = { - fields = { 'kind', 'abbr', 'menu' }, - format = function(entry, vim_item) - -- Kind icons - vim_item.kind = string.format('%s', kind_icons[vim_item.kind]) - vim_item.menu = ({ - nvim_lsp = '[L]', - luasnip = '[S]', - buffer = '[B]', - path = '[P]', - })[entry.source.name] - return vim_item - end, - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'buffer' }, - { name = 'path' }, - }, - confirm_opts = { - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }, - documentation = { - border = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' }, - }, - experimental = { - ghost_text = false, - native_menu = false, - }, -}) - --- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline('/', { - sources = { - { name = 'buffer' }, - }, -}) - --- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline(':', { - sources = cmp.config.sources({ - { name = 'path' }, - { name = 'cmdline' }, - }), -}) diff --git a/vima-old/lua/vima/plugins/gitsigns.lua b/vima-old/lua/vima/plugins/gitsigns.lua deleted file mode 100644 index 4cb89c2..0000000 --- a/vima-old/lua/vima/plugins/gitsigns.lua +++ /dev/null @@ -1,13 +0,0 @@ -local status_ok, gitsigns = pcall(require, 'gitsigns') -if not status_ok then - vim.notify('Failed to load gitsigns.') - return -end - --- TODO: define key maps in whichkey -gitsigns.setup({ - current_line_blame = true, - current_line_blame_formatter_opts = { - relative_time = true, - }, -}) diff --git a/vima-old/lua/vima/plugins/init.lua b/vima-old/lua/vima/plugins/init.lua index d654792..9a42b77 100644 --- a/vima-old/lua/vima/plugins/init.lua +++ b/vima-old/lua/vima/plugins/init.lua @@ -1,154 +1,150 @@ --- https://github.com/wbthomason/packer.nvim - --- Self install packer if not found on data path -local fn = vim.fn -local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' - -if fn.empty(fn.glob(install_path)) > 0 then - PACKER_BOOTSTRAP = fn.system({ - 'git', - 'clone', - '--depth', - '1', - 'https://github.com/wbthomason/packer.nvim', - install_path, - }) - vim.cmd([[packadd packer.nvim]]) -- necessary to let us require packer on first run -end - -local status_ok, packer = pcall(require, 'packer') -if not status_ok then - vim.notify('Failed to load packer.nvim.') - return +local present, packer = pcall(require, 'packer') + +if not present then + local packer_path = vim.fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' + + vim.notify('Bootstrapping packer.nvim . . .') + vim.fn.delete(packer_path, 'rf') + PACKER_BOOTSTRAP = vim.fn.system({ + 'git', + 'clone', + 'https://github.com/wbthomason/packer.nvim', + '--depth', + '20', + packer_path, + }) + vim.cmd('packadd packer.nvim') + present, packer = pcall(require, 'packer') + + if present then + vim.notify('Packer installed successfully.') + else + error('Could not bootstrap packer!') + return false + end end return packer.startup({ - function(use) - -- Packer can manage itself - use('wbthomason/packer.nvim') - - use('nvim-lua/popup.nvim') - use('nvim-lua/plenary.nvim') -- utility functions used by other plugins - use('kyazdani42/nvim-web-devicons') - - --color scheme - use({ - 'RRethy/nvim-base16', - config = function() - require('vima.plugins.colorscheme') - end, - }) - - -- which-key shows possible keys - use({ - 'folke/which-key.nvim', - config = function() - require('vima.plugins.whichkey') - end, - }) - - -- Treesitter syntax highlight - use({ - 'nvim-treesitter/nvim-treesitter', - run = ':TSUpdate', - }) - use({ 'JoosepAlviste/nvim-ts-context-commentstring', after = { 'nvim-treesitter' } }) - use({ - 'p00f/nvim-ts-rainbow', -- Rainbow brackets - after = { 'nvim-treesitter', 'nvim-ts-context-commentstring' }, - config = function() - require('vima.plugins.treesitter') - end, - }) - - -- git signs - use({ - 'lewis6991/gitsigns.nvim', - config = function() - require('vima.plugins.gitsigns') - end, - }) - - -- file tree - use({ - 'kyazdani42/nvim-tree.lua', - config = function() - require('vima.plugins.nvimtree') - end, - }) - - -- project - use({ - 'ahmedkhalf/project.nvim', - config = function() - require('vima.plugins.project') - end, - }) - - -- autocomplete and snippets plugins - use('hrsh7th/cmp-nvim-lsp') - use('hrsh7th/cmp-buffer') - use('hrsh7th/cmp-path') - use('hrsh7th/cmp-cmdline') - use('saadparwaiz1/cmp_luasnip') - use('L3MON4D3/LuaSnip') - use('rafamadriz/friendly-snippets') - use({ - 'hrsh7th/nvim-cmp', - config = function() - require('vima.plugins.completion') - end, - }) - - -- language servers - use('neovim/nvim-lspconfig') - use('folke/lua-dev.nvim') - use('ray-x/lsp_signature.nvim') - use('williamboman/nvim-lsp-installer') - use({ - 'jose-elias-alvarez/null-ls.nvim', - config = function() - require('vima.plugins.lsp') - end, - }) - - -- Telescope fuzzy finder - use({ - 'nvim-telescope/telescope.nvim', - requires = { 'nvim-lua/plenary.nvim', 'kyazdani42/nvim-web-devicons' }, - config = function() - require('vima.plugins.telescope') - end, - }) - - -- auto pairs - use({ - 'windwp/nvim-autopairs', - config = function() - require('vima.plugins.autopairs') - end, - }) - - use({ - 'numToStr/Comment.nvim', - after = { 'nvim-ts-context-commentstring' }, - config = function() - require('vima.plugins.comment') - end, - }) - - -- Automatically set up your configuration after cloning packer.nvim - if PACKER_BOOTSTRAP then - vim.cmd('hi clear Pmenu') - packer.sync() - end - end, - config = { - display = { - -- Have packer use a popup window - open_fn = function() - return require('packer.util').float({ border = 'rounded' }) - end, + function(use) + -- Packer can manage itself + use('wbthomason/packer.nvim') + + -- Speedup the start time + use('lewis6991/impatient.nvim') + + -- utility functions used by other plugins + + use('nvim-lua/plenary.nvim') + + -- icons used by other plugins + use({ + 'kyazdani42/nvim-web-devicons', + event = 'VimEnter', + cond = function() + return not vim.g.vscode + end + }) + + --color scheme + use({ + 'RRethy/nvim-base16', + config = function() + require('vima.plugins.colorscheme') + end, + after = { 'nvim-web-devicons' }, + cond = function() + return not vim.g.vscode + end + }) + + -- statusline + use({ + 'nvim-lualine/lualine.nvim', + config = function() + require('vima.plugins.lualine') + end, + cond = function() + return not vim.g.vscode + end + }) + + -- Treesitter syntax support + use({ + 'nvim-treesitter/nvim-treesitter', + run = function() + local ts_update = require('nvim-treesitter.install').update({ with_sync = true }) + ts_update() + end, + config = function() + require('vima.plugins.treesitter') + end + }) + + use({ + 'andymass/vim-matchup', + after = { 'nvim-treesitter' }, + setup = function() + -- may set any options here + vim.g.matchup_matchparen_offscreen = { method = "popup" } + end + }) + + use({ + 'p00f/nvim-ts-rainbow', -- Rainbow brackets + after = { 'nvim-treesitter' }, + cond = function() + return not vim.g.vscode + end + }) + + use({ + 'nvim-treesitter/nvim-treesitter-textobjects', + after = { 'nvim-treesitter' }, + }) + + use({ + 'JoosepAlviste/nvim-ts-context-commentstring', + after = { 'nvim-treesitter' }, + }) + + -- context aware commenting + use({ + 'numToStr/Comment.nvim', + after = { 'nvim-ts-context-commentstring' }, + config = function() + require('vima.plugins.comment') + end, + }) + + -- Surround + use({ + "kylechui/nvim-surround", + tag = "*", -- Use for stability; omit to use `main` branch for the latest features + config = function() + require("nvim-surround").setup({ + -- Configuration here, or leave empty to use defaults + }) + end + }) + + use({ + 'rlane/pounce.nvim', + config = function() + require('vima.plugins.pounce') + end + }) + + -- Automatically set up your configuration after cloning packer.nvim + if PACKER_BOOTSTRAP then + vim.cmd('hi clear Pmenu') + packer.sync() + end + end, + config = { + display = { + open_fn = function() + return require('packer.util').float({ border = 'rounded' }) + end, + }, }, - }, }) diff --git a/vima-old/lua/vima/plugins/lsp.lua b/vima-old/lua/vima/plugins/lsp.lua deleted file mode 100644 index 6135925..0000000 --- a/vima-old/lua/vima/plugins/lsp.lua +++ /dev/null @@ -1,135 +0,0 @@ -local status_ok, lsp_installer_servers = pcall(require, 'nvim-lsp-installer.servers') -if not status_ok then - vim.notify('Failed to load lsp-installer.') - return -end - -local status_ok, lsp_signature = pcall(require, 'lsp_signature') -if not status_ok then - vim.notify('Failed to load lsp_signature.') - return -end - -local status_ok, cmp_nvim_lsp = pcall(require, 'cmp_nvim_lsp') -if not status_ok then - vim.notify('Failed to load cmp_nvim_lsp.') - return -end - -local capabilities = cmp_nvim_lsp.update_capabilities(vim.lsp.protocol.make_client_capabilities()) - -local function lsp_highlight_document(client) - -- Set autocommands conditional on server_capabilities - if client.resolved_capabilities.document_highlight then - vim.api.nvim_exec( - [[ - augroup vima_lsp_document_highlight - autocmd! * - autocmd CursorHold lua vim.lsp.buf.document_highlight() - autocmd CursorMoved lua vim.lsp.buf.clear_references() - augroup END - ]], - false - ) - end -end - -local function lsp_keymaps(bufnr) - local status_ok, which_key = pcall(require, 'which-key') - if not status_ok then - vim.notify('Failed to load which-key.') - return - end - - which_key.register({ - ['gd'] = { 'lua vim.lsp.buf.definition()', 'Go to definition' }, - ['gD'] = { 'lua vim.lsp.buf.declaration()', 'Go to declaration' }, - ['gh'] = { 'lua vim.lsp.buf.hover({ border = "rounded" })', 'Hover' }, - ['gl'] = { 'lua vim.diagnostic.open_float()', 'Line diagnostics' }, - -- TODO: use Telescope for references and diagnostics - }, { buffer = bufnr }) -end - -local on_attach = function(client, bufnr) - -- TODO: format on save - lsp_signature.on_attach({ - bind = true, -- This is mandatory, otherwise border config won't get registered. - handler_opts = { - border = 'rounded', - }, - }, bufnr) - - vim.cmd([[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]) - - lsp_keymaps(bufnr) - lsp_highlight_document(client) -end - -local setup_lsp = function(lang_lsp_configs) - for lsp_name, lsp_config in pairs(lang_lsp_configs) do - local server_available, requested_server = lsp_installer_servers.get_server(lsp_name) - if server_available then - requested_server:on_ready(function() - requested_server:setup({ - capabilities = capabilities, - on_attach = function(client, bufnr) - if lsp_config.on_attach then - lsp_config.on_attach(client, bufnr) - end - on_attach(client, bufnr) - end, - settings = lsp_config.settings, - }) - end) - if not requested_server:is_installed() then - requested_server:install() - vim.notify(lsp_name .. ' is being installed.') - end - end - end -end - -local null_ls_config = require('vima.plugins.null-ls') -require('vima.Languages').setup_supported_lsps(setup_lsp, null_ls_config.add_sources) -null_ls_config.setup_null_ls() - --- LSP Common config --------------------------------------------------------------------------------- - -local signs = { - { name = 'DiagnosticSignError', text = '' }, - { name = 'DiagnosticSignWarn', text = '' }, - { name = 'DiagnosticSignHint', text = '' }, - { name = 'DiagnosticSignInfo', text = '' }, -} - -for _, sign in ipairs(signs) do - vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = '' }) -end - -vim.diagnostic.config({ - virtual_text = true, - -- show signs - signs = { - active = signs, - }, - update_in_insert = true, - underline = true, - severity_sort = true, - float = { - focusable = false, - style = 'minimal', - border = 'rounded', - source = 'always', - header = '', - prefix = '', - }, -}) - -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', -}) diff --git a/vima/lua/vima/plugins/lualine.lua b/vima-old/lua/vima/plugins/lualine.lua similarity index 100% rename from vima/lua/vima/plugins/lualine.lua rename to vima-old/lua/vima/plugins/lualine.lua diff --git a/vima-old/lua/vima/plugins/null-ls.lua b/vima-old/lua/vima/plugins/null-ls.lua deleted file mode 100644 index 43fa11b..0000000 --- a/vima-old/lua/vima/plugins/null-ls.lua +++ /dev/null @@ -1,23 +0,0 @@ -local M = {} - -local null_ls_status_ok, null_ls = pcall(require, 'null-ls') -if not null_ls_status_ok then - vim.notify('Failed to load null-ls.') - return -end - -local sources = {} - -M.add_sources = function(null_ls_sources) - sources = vim.tbl_deep_extend('force', null_ls_sources, sources) -end - -M.setup_null_ls = function() - null_ls.setup({ - debug = false, - update_in_insert = true, - sources = sources, - }) -end - -return M diff --git a/vima-old/lua/vima/plugins/nvimtree.lua b/vima-old/lua/vima/plugins/nvimtree.lua deleted file mode 100644 index 10a7ca3..0000000 --- a/vima-old/lua/vima/plugins/nvimtree.lua +++ /dev/null @@ -1,17 +0,0 @@ -local status_ok, nvim_tree = pcall(require, 'nvim-tree') -if not status_ok then - vim.notify('Failed to load nvim-tree.') - return -end - -vim.g.nvim_tree_respect_buf_cwd = 1 - --- TODO: whichkey shortcut -nvim_tree.setup({ - auto_close = true, - update_cwd = true, - update_focused_file = { - enable = true, - update_cwd = true, - }, -}) diff --git a/vima/lua/vima/plugins/pounce.lua b/vima-old/lua/vima/plugins/pounce.lua similarity index 100% rename from vima/lua/vima/plugins/pounce.lua rename to vima-old/lua/vima/plugins/pounce.lua diff --git a/vima-old/lua/vima/plugins/project.lua b/vima-old/lua/vima/plugins/project.lua deleted file mode 100644 index 67eb155..0000000 --- a/vima-old/lua/vima/plugins/project.lua +++ /dev/null @@ -1,15 +0,0 @@ -local status_ok, project_nvim = pcall(require, 'project_nvim') -if not status_ok then - vim.notify('Failed to load project_nvim.') - return -end - -local status_ok, telescope = pcall(require, 'telescope') -if not status_ok then - vim.notify('Failed to load Telescope.') - return -end - -project_nvim.setup({}) - -telescope.load_extension('projects') diff --git a/vima-old/lua/vima/plugins/telescope.lua b/vima-old/lua/vima/plugins/telescope.lua deleted file mode 100644 index 1c834de..0000000 --- a/vima-old/lua/vima/plugins/telescope.lua +++ /dev/null @@ -1,36 +0,0 @@ -local status_ok, telescope = pcall(require, 'telescope') -if not status_ok then - vim.notify('Failed to load Telescope.') - return -end - -local actions = require('telescope.actions') - -telescope.setup({ - defaults = { - - prompt_prefix = '  ', - selection_caret = ' ', - path_display = { 'smart' }, - - mappings = { - i = { - [''] = actions.cycle_history_next, - [''] = actions.cycle_history_prev, - - [''] = actions.move_selection_next, - [''] = actions.move_selection_previous, - - [''] = actions.which_key, - }, - - n = { - [''] = actions.close, - - [''] = actions.which_key, - }, - }, - }, - pickers = {}, - extensions = {}, -}) diff --git a/vima-old/lua/vima/plugins/treesitter.lua b/vima-old/lua/vima/plugins/treesitter.lua index 4a2418e..4ff15ff 100644 --- a/vima-old/lua/vima/plugins/treesitter.lua +++ b/vima-old/lua/vima/plugins/treesitter.lua @@ -1,28 +1,109 @@ -local status_ok, configs = pcall(require, 'nvim-treesitter.configs') -if not status_ok then - vim.notify('Failed to load treesitter configs.') - return +local present, ts_configs = pcall(require, 'nvim-treesitter.configs') +if not present then + require('vima.utils').notify_missing('nvim-treesitter') + return end --- TODO: textobjects and movements --- TODO: Folds, Locals, Indents, Injections --- TODO: key mappings --- TODO: incremental select - -configs.setup({ - ensure_installed = require('vima.Languages').get_treesitter_languages(), - sync_install = false, - highlight = { - enable = true, - additional_vim_regex_highlighting = true, - }, - indent = { enable = true }, - rainbow = { enable = true }, - context_commentstring = { - enable = true, - enable_autocmd = true, - }, +vim.api.nvim_create_autocmd({ 'BufEnter', 'BufAdd', 'BufNew', 'BufNewFile', 'BufWinEnter' }, { + group = vim.api.nvim_create_augroup('TS_FOLD_WORKAROUND', {}), + callback = function() + vim.opt.foldmethod = 'expr' + vim.opt.foldexpr = 'nvim_treesitter#foldexpr()' + end }) -vim.opt.foldmethod = 'expr' -vim.opt.foldexpr = 'nvim_treesitter#foldexpr()' +ts_configs.setup({ + ensure_installed = { 'help', 'lua', 'python', 'bash', 'javascript', 'typescript', 'json' }, + sync_install = false, + highlight = { + enable = true, + disable = function(lang, buf) + if vim.g.vscode then + return true + else + return false + end + end, + }, + indent = { + enable = true, + }, + incremental_selection = { + enable = true, + }, + context_commentstring = { + enable = true, + enable_autocmd = false, + }, + rainbow = { + enable = true, + }, + matchup = { + enable = true, + }, + textobjects = { + select = { + enable = true, + + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, + + keymaps = { + ['ab'] = '@block.outer', + ['ib'] = '@block.inner', + ['aa'] = '@call.outer', + ['ia'] = '@call.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + ['a/'] = '@comment.outer', + ['i/'] = '@comment.outer', -- inner does not work + ['ai'] = '@conditional.outer', + ['ii'] = '@conditional.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['al'] = '@loop.outer', + ['il'] = '@loop.inner', + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']b'] = '@block.inner', + [']a'] = '@call.outer', + [']c'] = '@class.outer', + [']/'] = '@comment.outer', + [']i'] = '@conditional.outer', + [']f'] = '@function.outer', + [']l'] = '@loop.outer', + }, + goto_next_end = { + [']B'] = '@block.inner', + [']A'] = '@call.outer', + [']C'] = '@class.outer', + [']?'] = '@comment.outer', + [']I'] = '@conditional.outer', + [']F'] = '@function.outer', + [']L'] = '@loop.outer', + }, + goto_previous_start = { + ['[b'] = '@block.inner', + ['[a'] = '@call.outer', + ['[c'] = '@class.outer', + ['[/'] = '@comment.outer', + ['[i'] = '@conditional.outer', + ['[f'] = '@function.outer', + ['[l'] = '@loop.outer', + }, + goto_previous_end = { + ['[B'] = '@block.inner', + ['[A'] = '@call.outer', + ['[C'] = '@class.outer', + ['[?'] = '@comment.outer', + ['[I'] = '@conditional.outer', + ['[F'] = '@function.outer', + ['[L'] = '@loop.outer', + }, + }, + }, +}) diff --git a/vima-old/lua/vima/plugins/whichkey.lua b/vima-old/lua/vima/plugins/whichkey.lua deleted file mode 100644 index 4d3478b..0000000 --- a/vima-old/lua/vima/plugins/whichkey.lua +++ /dev/null @@ -1,36 +0,0 @@ -local status_ok, which_key = pcall(require, 'which-key') -if not status_ok then - vim.notify('Failed to load which-key.') - return -end - -which_key.setup({ - window = { - border = 'rounded', - }, -}) - -which_key.register({ - f = { - name = 'find', - b = { 'Telescope buffers', 'Buffers' }, - f = { 'Telescope find_files', 'Files' }, - g = { 'Telescope live_grep', 'Grep' }, - r = { 'Telescope oldfiles', 'Recent file' }, - s = { 'Telescope git_status', 'Git status' }, - }, - g = { - name = 'Git', - b = { 'Gitsigns stage_buffer', 'Stage file' }, - d = { 'Gitsigns diffthis', 'Diff current file' }, - n = { 'Gitsigns next_hunk', 'Next hunk' }, - p = { 'Gitsigns prev_hunk', 'Prev hunk' }, - r = { 'Gitsigns refresh', 'Refresh' }, - s = { 'Gitsigns stage_hunk', 'Stage hunk' }, - u = { 'Gitsigns undo_stage_hunk', 'Undo stage hunk' }, - }, - t = { - name = 'Toggle', - f = { 'NvimTreeToggle', 'NVIMTree' }, - }, -}, { prefix = '' }) diff --git a/vima-old/lua/vima/utils.lua b/vima-old/lua/vima/utils.lua index 9a4244d..2f81bd9 100644 --- a/vima-old/lua/vima/utils.lua +++ b/vima-old/lua/vima/utils.lua @@ -1,9 +1,8 @@ local M = {} -M.map = function(mode, keys, command, options_override) - local options = { noremap = true, silent = true } - options = vim.tbl_extend('force', options, options_override or {}) - vim.api.nvim_set_keymap(mode, keys, command, options) +M.notify_missing = function(name, title) + title = title or name + vim.notify('Could not find ' .. name .. '.', 'warn', { title = title }) end return M diff --git a/vima/init.lua b/vima/init.lua deleted file mode 100644 index bc6b3f4..0000000 --- a/vima/init.lua +++ /dev/null @@ -1,7 +0,0 @@ -local present, _ = pcall(require, 'impatient') -if not present then - require('vima.utils').notify_missing('impatient') -end - -require('vima.core') -require('vima.plugins') diff --git a/vima/lua/vima/core.lua b/vima/lua/vima/core.lua deleted file mode 100644 index 95426d4..0000000 --- a/vima/lua/vima/core.lua +++ /dev/null @@ -1,70 +0,0 @@ -local opt = vim.opt -local map = vim.keymap.set - -opt.backup = false -opt.clipboard = 'unnamedplus' -opt.expandtab = true -opt.fileencoding = 'utf-8' -opt.hidden = true -opt.hlsearch = true -opt.ignorecase = true -opt.iskeyword:append('-') -opt.shiftround = true -opt.shiftwidth = 2 -opt.smartcase = true -opt.smartindent = true -opt.splitbelow = true -opt.splitright = true -opt.swapfile = false -opt.tabstop = 4 -opt.timeout = true -opt.timeoutlen = 1000 -opt.undofile = true -opt.undolevels = 2000 -opt.updatetime = 300 -opt.visualbell = true -opt.whichwrap:append('<>[]hl') -opt.wrap = false -opt.writebackup = false - -if not vim.g.vscode then - opt.cmdheight = 2 - opt.colorcolumn = '120' - opt.completeopt = { 'menuone', 'noselect' } - opt.conceallevel = 0 - opt.cursorline = true - opt.fillchars = { eob = ' ' } - opt.foldenable = false - opt.foldmethod = 'syntax' - opt.list = true - opt.listchars = 'tab:⇥ ,trail:·' - opt.mouse = 'a' - opt.number = true - opt.numberwidth = 3 - opt.pumheight = 10 - opt.relativenumber = true - opt.ruler = true - opt.scrolloff = 5 - opt.shortmess:append('cI') - opt.showmode = false - opt.showtabline = 2 - opt.sidescrolloff = 10 - opt.signcolumn = 'yes' - opt.switchbuf = 'useopen,usetab,newtab' - opt.termguicolors = true - opt.title = true - opt.wildignore = 'build,.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,*.pyc' - opt.wildmode = 'longest,full' -end - --- disable bundled plugins -vim.g.loaded_matchit = 1 - -map("i", "jj", "") -map("i", "jk", "") - -map("v", "<", "", ">gv") - -map({ 'n', 'v' }, "c", '"_c') -map({ 'n', 'v' }, "d", '"_d') diff --git a/vima/lua/vima/plugins/colorscheme.lua b/vima/lua/vima/plugins/colorscheme.lua deleted file mode 100644 index 143313b..0000000 --- a/vima/lua/vima/plugins/colorscheme.lua +++ /dev/null @@ -1,25 +0,0 @@ -if vim.g.vscode then - return -end - -vim.g.base16colorspace = 256 - -local base16_theme = 'base16-' .. (vim.env.BASE16_THEME or 'default-dark') - -status_ok, _ = pcall(vim.cmd, 'colorscheme ' .. base16_theme) -if not status_ok then - vim.notify('Failed to load base16 colorscheme.') - return -end - --- https://github.com/RRethy/nvim-base16/issues/32 fix telescope borders -vim.cmd([[highlight! link TelescopeSelection Visual]]) -vim.cmd([[highlight! link TelescopeNormal Normal]]) -vim.cmd([[highlight! link TelescopePromptNormal TelescopeNormal]]) -vim.cmd([[highlight! link TelescopeBorder TelescopeNormal]]) -vim.cmd([[highlight! link TelescopePromptBorder TelescopeBorder]]) -vim.cmd([[highlight! link TelescopeTitle TelescopeBorder]]) -vim.cmd([[highlight! link TelescopePromptTitle TelescopeTitle]]) -vim.cmd([[highlight! link TelescopeResultsTitle TelescopeTitle]]) -vim.cmd([[highlight! link TelescopePreviewTitle TelescopeTitle]]) -vim.cmd([[highlight! link TelescopePromptPrefix Identifier]]) diff --git a/vima/lua/vima/plugins/comment.lua b/vima/lua/vima/plugins/comment.lua deleted file mode 100644 index ddd6bd3..0000000 --- a/vima/lua/vima/plugins/comment.lua +++ /dev/null @@ -1,21 +0,0 @@ -local present, comment = pcall(require, 'Comment') -if not present then - require('vima.utils').notify_missing('Comment.nvim') - return -end - -local present, ts_context_commentstring = pcall(require, 'ts_context_commentstring') -if not present then - require('vima.utils').notify_missing('nvim_ts_context_commentstring') - return -end - -require('Comment').setup({ - mappings = { - ---Operator-pending mapping; `gcc` `gbc` `gc[count]{motion}` `gb[count]{motion}` - basic = true, - ---Extra mapping; `gco`, `gcO`, `gcA` - extra = true, - }, - pre_hook = require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook(), -}) diff --git a/vima/lua/vima/plugins/init.lua b/vima/lua/vima/plugins/init.lua deleted file mode 100644 index 9a42b77..0000000 --- a/vima/lua/vima/plugins/init.lua +++ /dev/null @@ -1,150 +0,0 @@ -local present, packer = pcall(require, 'packer') - -if not present then - local packer_path = vim.fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' - - vim.notify('Bootstrapping packer.nvim . . .') - vim.fn.delete(packer_path, 'rf') - PACKER_BOOTSTRAP = vim.fn.system({ - 'git', - 'clone', - 'https://github.com/wbthomason/packer.nvim', - '--depth', - '20', - packer_path, - }) - vim.cmd('packadd packer.nvim') - present, packer = pcall(require, 'packer') - - if present then - vim.notify('Packer installed successfully.') - else - error('Could not bootstrap packer!') - return false - end -end - -return packer.startup({ - function(use) - -- Packer can manage itself - use('wbthomason/packer.nvim') - - -- Speedup the start time - use('lewis6991/impatient.nvim') - - -- utility functions used by other plugins - - use('nvim-lua/plenary.nvim') - - -- icons used by other plugins - use({ - 'kyazdani42/nvim-web-devicons', - event = 'VimEnter', - cond = function() - return not vim.g.vscode - end - }) - - --color scheme - use({ - 'RRethy/nvim-base16', - config = function() - require('vima.plugins.colorscheme') - end, - after = { 'nvim-web-devicons' }, - cond = function() - return not vim.g.vscode - end - }) - - -- statusline - use({ - 'nvim-lualine/lualine.nvim', - config = function() - require('vima.plugins.lualine') - end, - cond = function() - return not vim.g.vscode - end - }) - - -- Treesitter syntax support - use({ - 'nvim-treesitter/nvim-treesitter', - run = function() - local ts_update = require('nvim-treesitter.install').update({ with_sync = true }) - ts_update() - end, - config = function() - require('vima.plugins.treesitter') - end - }) - - use({ - 'andymass/vim-matchup', - after = { 'nvim-treesitter' }, - setup = function() - -- may set any options here - vim.g.matchup_matchparen_offscreen = { method = "popup" } - end - }) - - use({ - 'p00f/nvim-ts-rainbow', -- Rainbow brackets - after = { 'nvim-treesitter' }, - cond = function() - return not vim.g.vscode - end - }) - - use({ - 'nvim-treesitter/nvim-treesitter-textobjects', - after = { 'nvim-treesitter' }, - }) - - use({ - 'JoosepAlviste/nvim-ts-context-commentstring', - after = { 'nvim-treesitter' }, - }) - - -- context aware commenting - use({ - 'numToStr/Comment.nvim', - after = { 'nvim-ts-context-commentstring' }, - config = function() - require('vima.plugins.comment') - end, - }) - - -- Surround - use({ - "kylechui/nvim-surround", - tag = "*", -- Use for stability; omit to use `main` branch for the latest features - config = function() - require("nvim-surround").setup({ - -- Configuration here, or leave empty to use defaults - }) - end - }) - - use({ - 'rlane/pounce.nvim', - config = function() - require('vima.plugins.pounce') - end - }) - - -- Automatically set up your configuration after cloning packer.nvim - if PACKER_BOOTSTRAP then - vim.cmd('hi clear Pmenu') - packer.sync() - end - end, - config = { - display = { - open_fn = function() - return require('packer.util').float({ border = 'rounded' }) - end, - }, - }, -}) diff --git a/vima/lua/vima/plugins/treesitter.lua b/vima/lua/vima/plugins/treesitter.lua deleted file mode 100644 index 4ff15ff..0000000 --- a/vima/lua/vima/plugins/treesitter.lua +++ /dev/null @@ -1,109 +0,0 @@ -local present, ts_configs = pcall(require, 'nvim-treesitter.configs') -if not present then - require('vima.utils').notify_missing('nvim-treesitter') - return -end - -vim.api.nvim_create_autocmd({ 'BufEnter', 'BufAdd', 'BufNew', 'BufNewFile', 'BufWinEnter' }, { - group = vim.api.nvim_create_augroup('TS_FOLD_WORKAROUND', {}), - callback = function() - vim.opt.foldmethod = 'expr' - vim.opt.foldexpr = 'nvim_treesitter#foldexpr()' - end -}) - -ts_configs.setup({ - ensure_installed = { 'help', 'lua', 'python', 'bash', 'javascript', 'typescript', 'json' }, - sync_install = false, - highlight = { - enable = true, - disable = function(lang, buf) - if vim.g.vscode then - return true - else - return false - end - end, - }, - indent = { - enable = true, - }, - incremental_selection = { - enable = true, - }, - context_commentstring = { - enable = true, - enable_autocmd = false, - }, - rainbow = { - enable = true, - }, - matchup = { - enable = true, - }, - textobjects = { - select = { - enable = true, - - -- Automatically jump forward to textobj, similar to targets.vim - lookahead = true, - - keymaps = { - ['ab'] = '@block.outer', - ['ib'] = '@block.inner', - ['aa'] = '@call.outer', - ['ia'] = '@call.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - ['a/'] = '@comment.outer', - ['i/'] = '@comment.outer', -- inner does not work - ['ai'] = '@conditional.outer', - ['ii'] = '@conditional.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['al'] = '@loop.outer', - ['il'] = '@loop.inner', - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - [']b'] = '@block.inner', - [']a'] = '@call.outer', - [']c'] = '@class.outer', - [']/'] = '@comment.outer', - [']i'] = '@conditional.outer', - [']f'] = '@function.outer', - [']l'] = '@loop.outer', - }, - goto_next_end = { - [']B'] = '@block.inner', - [']A'] = '@call.outer', - [']C'] = '@class.outer', - [']?'] = '@comment.outer', - [']I'] = '@conditional.outer', - [']F'] = '@function.outer', - [']L'] = '@loop.outer', - }, - goto_previous_start = { - ['[b'] = '@block.inner', - ['[a'] = '@call.outer', - ['[c'] = '@class.outer', - ['[/'] = '@comment.outer', - ['[i'] = '@conditional.outer', - ['[f'] = '@function.outer', - ['[l'] = '@loop.outer', - }, - goto_previous_end = { - ['[B'] = '@block.inner', - ['[A'] = '@call.outer', - ['[C'] = '@class.outer', - ['[?'] = '@comment.outer', - ['[I'] = '@conditional.outer', - ['[F'] = '@function.outer', - ['[L'] = '@loop.outer', - }, - }, - }, -}) diff --git a/vima/lua/vima/utils.lua b/vima/lua/vima/utils.lua deleted file mode 100644 index 2f81bd9..0000000 --- a/vima/lua/vima/utils.lua +++ /dev/null @@ -1,8 +0,0 @@ -local M = {} - -M.notify_missing = function(name, title) - title = title or name - vim.notify('Could not find ' .. name .. '.', 'warn', { title = title }) -end - -return M