|
@@ -1,427 +0,0 @@
|
|
--- add extra filetypes for plenary
|
|
|
|
-require('plenary.filetype').add_table({
|
|
|
|
- extension = {
|
|
|
|
- ['elv'] = [[elvish]]
|
|
|
|
- }
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
--- add extra builtin filetypes
|
|
|
|
-vim.filetype.add({
|
|
|
|
- pattern = {
|
|
|
|
- ['.*%.ts$'] = 'typescript'
|
|
|
|
- },
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
--- helpers
|
|
|
|
-local function resolve_git_path(buf_id)
|
|
|
|
- local bufname = vim.api.nvim_buf_get_name(buf_id)
|
|
|
|
- if not vim.startswith(bufname, 'fugitive://') then
|
|
|
|
- return false
|
|
|
|
- end
|
|
|
|
-
|
|
|
|
- local parsed = vim.fn.FugitiveParse(bufname)
|
|
|
|
- local resolved_path = parsed[1]
|
|
|
|
- local repo = parsed[2]
|
|
|
|
-
|
|
|
|
- if resolved_path == '' then
|
|
|
|
- return false
|
|
|
|
- end
|
|
|
|
-
|
|
|
|
- local parts = vim.split(resolved_path, ':')
|
|
|
|
- local commit = parts[1]
|
|
|
|
- local path = parts[2]
|
|
|
|
-
|
|
|
|
- return {
|
|
|
|
- repo = repo,
|
|
|
|
- commit = commit,
|
|
|
|
- path = path,
|
|
|
|
- }
|
|
|
|
-end
|
|
|
|
-
|
|
|
|
--- file/buffer/etc picker
|
|
|
|
-local telescope_actions = require('telescope.actions')
|
|
|
|
-local action_state = require('telescope.actions.state')
|
|
|
|
-local actions = {}
|
|
|
|
-
|
|
|
|
-actions.git_show_commit = function(prompt_bufnr)
|
|
|
|
- local selection = action_state.get_selected_entry()
|
|
|
|
- local path = vim.fn.FugitiveFind(selection.value)
|
|
|
|
- telescope_actions.close(prompt_bufnr)
|
|
|
|
- vim.cmd.edit(path)
|
|
|
|
-end
|
|
|
|
-
|
|
|
|
-local commit_mappings = {
|
|
|
|
- i = {
|
|
|
|
- ['<CR>'] = actions.git_show_commit,
|
|
|
|
- ['<C-r>c'] = telescope_actions.git_checkout,
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-require('telescope').setup({
|
|
|
|
- defaults = {
|
|
|
|
- mappings = {
|
|
|
|
- i = {
|
|
|
|
- ['jj'] = 'close',
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- layout_config = {
|
|
|
|
- prompt_position = 'top',
|
|
|
|
- },
|
|
|
|
- sorting_strategy = 'ascending',
|
|
|
|
- -- use filename as preview window title
|
|
|
|
- dynamic_preview_title = true,
|
|
|
|
-
|
|
|
|
- path_display = {
|
|
|
|
- -- shorten directory names of everything but the last 3 parts
|
|
|
|
- -- foo/bar/baz/file.txt -> f/boo/bar/file.txt
|
|
|
|
- shorten = { len = 1, exclude = { -3, -2, -1 } },
|
|
|
|
-
|
|
|
|
- -- truncate the beginning of the file name if wider than the window
|
|
|
|
- truncate = true,
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- preview = {
|
|
|
|
- -- don't preview files larger than 1MB
|
|
|
|
- filesize_limit = 1,
|
|
|
|
- timeout = 500,
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- vimgrep_arguments = {
|
|
|
|
- -- defaults
|
|
|
|
- 'rg',
|
|
|
|
- '--color=never',
|
|
|
|
- '--no-heading',
|
|
|
|
- '--with-filename',
|
|
|
|
- '--line-number',
|
|
|
|
- '--column',
|
|
|
|
- '--smart-case',
|
|
|
|
- -- search "hidden" files except git folder
|
|
|
|
- '--hidden',
|
|
|
|
- '--iglob=!.git'
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- -- ignore things we're likely not to edit
|
|
|
|
- file_ignore_patterns = {
|
|
|
|
- '%.zip$',
|
|
|
|
- '%.yarn/releases/',
|
|
|
|
- '%.yarn/plugins/'
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- -- picker history
|
|
|
|
- cache_picker = {
|
|
|
|
- num_pickers = 10,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- pickers = {
|
|
|
|
- buffers = {
|
|
|
|
- sort_lastused = true,
|
|
|
|
- sort_mru = true,
|
|
|
|
- mappings = {
|
|
|
|
- i = {
|
|
|
|
- ['<C-k>'] = 'delete_buffer'
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- find_files = {
|
|
|
|
- find_command = { 'fd', '--type', 'f', '--strip-cwd-prefix' }
|
|
|
|
- },
|
|
|
|
- git_commits = {
|
|
|
|
- mappings = commit_mappings,
|
|
|
|
- },
|
|
|
|
- git_bcommits = {
|
|
|
|
- mappings = commit_mappings,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
--- use native sorter for better performance
|
|
|
|
-require('telescope').load_extension('fzf')
|
|
|
|
-
|
|
|
|
-local telescope_builtin = require('telescope.builtin')
|
|
|
|
-local telescope_pickers = require('telescope.pickers')
|
|
|
|
-local telescope_finders = require('telescope.finders')
|
|
|
|
-local telescope_previewers = require('telescope.previewers')
|
|
|
|
-local telescope_putils = require('telescope.previewers.utils')
|
|
|
|
-local telescope_conf = require('telescope.config').values
|
|
|
|
-
|
|
|
|
--- custom picker to fallback to files if no git
|
|
|
|
-_G.project_files = function()
|
|
|
|
- local ok = pcall(telescope_builtin.git_files, { show_untracked = true })
|
|
|
|
- if not ok then telescope_builtin.find_files({}) end
|
|
|
|
-end
|
|
|
|
-
|
|
|
|
--- custom picker for files within a commit
|
|
|
|
-_G.commit_files = function(opts)
|
|
|
|
- local resolved = resolve_git_path(0)
|
|
|
|
- if not resolved then
|
|
|
|
- vim.print('current file is not a fugitive path')
|
|
|
|
- return
|
|
|
|
- end
|
|
|
|
-
|
|
|
|
- opts = opts or {}
|
|
|
|
- telescope_pickers.new(opts, {
|
|
|
|
- prompt_title = resolved.commit,
|
|
|
|
- finder = telescope_finders.new_oneshot_job({ 'git', 'ls-tree', '--name-only', '-r', resolved.commit }, {
|
|
|
|
- entry_maker = function(entry)
|
|
|
|
- local path = string.format('fugitive://%s//%s/%s', resolved.repo, resolved.commit, entry)
|
|
|
|
- return {
|
|
|
|
- path = path,
|
|
|
|
- value = entry,
|
|
|
|
- display = entry,
|
|
|
|
- ordinal = entry,
|
|
|
|
- }
|
|
|
|
- end,
|
|
|
|
- }),
|
|
|
|
- sorter = telescope_conf.file_sorter(opts),
|
|
|
|
-
|
|
|
|
- -- the builtin previewer has fancy async loading which doesn't work for
|
|
|
|
- -- fugitive paths so we have to define our own
|
|
|
|
- previewer = telescope_previewers.new_buffer_previewer({
|
|
|
|
- title = function(self)
|
|
|
|
- return 'Commit Files'
|
|
|
|
- end,
|
|
|
|
- dyn_title = function(self, entry)
|
|
|
|
- return entry.value
|
|
|
|
- end,
|
|
|
|
- define_preview = function(self, entry, status)
|
|
|
|
- -- the builtin previewer does more things like using mime type
|
|
|
|
- -- fallbacks as well as binary file detection which ours doesn't do
|
|
|
|
- local ft = telescope_putils.filetype_detect(entry.value)
|
|
|
|
-
|
|
|
|
- vim.api.nvim_buf_call(self.state.bufnr, function()
|
|
|
|
- vim.cmd('Gread ' .. entry.path)
|
|
|
|
- telescope_putils.highlighter(self.state.bufnr, ft, opts)
|
|
|
|
- end)
|
|
|
|
- end,
|
|
|
|
- }),
|
|
|
|
- }):find()
|
|
|
|
-end
|
|
|
|
-
|
|
|
|
--- shows added/removed/changed lines
|
|
|
|
-local MiniDiff = require('mini.diff')
|
|
|
|
-MiniDiff.setup({
|
|
|
|
- view = {
|
|
|
|
- style = 'sign',
|
|
|
|
- signs = {
|
|
|
|
- delete = '_',
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- source = {
|
|
|
|
- MiniDiff.gen_source.git(),
|
|
|
|
- -- handle fugitive paths
|
|
|
|
- {
|
|
|
|
- name = 'fugitive',
|
|
|
|
- attach = function(buf_id)
|
|
|
|
- local resolved = resolve_git_path(buf_id)
|
|
|
|
- if not resolved or resolved.path == '' then
|
|
|
|
- return false
|
|
|
|
- end
|
|
|
|
-
|
|
|
|
- local source = vim.fn.FugitiveFind(string.format('%s~1:%s', resolved.commit, resolved.path))
|
|
|
|
- local text = vim.fn['fugitive#readfile'](source)
|
|
|
|
- MiniDiff.set_ref_text(buf_id, text)
|
|
|
|
- end
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
-local function section_git(args)
|
|
|
|
- if MiniStatusline.is_truncated(args.trunc_width) then return '' end
|
|
|
|
- return vim.fn.FugitiveHead()
|
|
|
|
-end
|
|
|
|
-
|
|
|
|
-require('mini.statusline').setup({
|
|
|
|
- content = {
|
|
|
|
- -- copy-pasted from default, we just want to remove the icon
|
|
|
|
- active = function()
|
|
|
|
- local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 })
|
|
|
|
- local git = section_git({ trunc_width = 75 })
|
|
|
|
- local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75, icon = '' })
|
|
|
|
- local filename = MiniStatusline.section_filename({ trunc_width = 140 })
|
|
|
|
- local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 })
|
|
|
|
- local location = MiniStatusline.section_location({ trunc_width = 75 })
|
|
|
|
-
|
|
|
|
- return MiniStatusline.combine_groups({
|
|
|
|
- { hl = mode_hl, strings = { mode } },
|
|
|
|
- { hl = 'MiniStatuslineDevinfo', strings = { git, diagnostics } },
|
|
|
|
- '%<', -- Mark general truncate point
|
|
|
|
- { hl = 'MiniStatuslineFilename', strings = { filename } },
|
|
|
|
- '%=', -- End left alignment
|
|
|
|
- { hl = 'MiniStatuslineFileinfo', strings = { fileinfo } },
|
|
|
|
- { hl = mode_hl, strings = { location } },
|
|
|
|
- })
|
|
|
|
- end
|
|
|
|
- },
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
--- delete buffer while preserving layout
|
|
|
|
-require('mini.bufremove').setup()
|
|
|
|
-
|
|
|
|
--- shows a line indicating the current indentation scope
|
|
|
|
-require('mini.indentscope').setup()
|
|
|
|
-
|
|
|
|
--- comment actions
|
|
|
|
-require('mini.comment').setup()
|
|
|
|
-
|
|
|
|
--- surround actions
|
|
|
|
-require('mini.surround').setup({
|
|
|
|
- custom_surroundings = {
|
|
|
|
- -- js template string
|
|
|
|
- ['$'] = {
|
|
|
|
- output = {
|
|
|
|
- left = '`${',
|
|
|
|
- right = '}`',
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
-local spec_treesitter = require('mini.ai').gen_spec.treesitter
|
|
|
|
-
|
|
|
|
-require('mini.ai').setup({
|
|
|
|
- -- only consider the current location
|
|
|
|
- search_method = 'cover',
|
|
|
|
- custom_textobjects = {
|
|
|
|
- ['.'] = spec_treesitter({
|
|
|
|
- a = '@call.outer',
|
|
|
|
- i = '@call.inner',
|
|
|
|
- }),
|
|
|
|
- [','] = spec_treesitter({
|
|
|
|
- a = '@parameter.outer',
|
|
|
|
- i = '@parameter.inner',
|
|
|
|
- }),
|
|
|
|
- },
|
|
|
|
-});
|
|
|
|
-
|
|
|
|
--- align actions
|
|
|
|
-require('mini.align').setup()
|
|
|
|
-
|
|
|
|
--- repeatable f/t
|
|
|
|
-require('mini.jump').setup({
|
|
|
|
- mappings = {
|
|
|
|
- repeat_jump = '',
|
|
|
|
- },
|
|
|
|
- delay = {
|
|
|
|
- highlight = 10000000,
|
|
|
|
- },
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
--- autopair brackets
|
|
|
|
-require('mini.pairs').setup({
|
|
|
|
- mappings = {
|
|
|
|
- -- default config includes (, [ and {
|
|
|
|
-
|
|
|
|
- -- autopair <> if preceded by a character, otherwise it might be a regular
|
|
|
|
- -- comparison operation
|
|
|
|
- ['<'] = { action = 'open', pair = '<>', neigh_pattern = '%w.' },
|
|
|
|
- ['>'] = { action = 'close', pair = '<>' },
|
|
|
|
- },
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
--- notifications
|
|
|
|
-require('mini.notify').setup()
|
|
|
|
-vim.notify = require('mini.notify').make_notify()
|
|
|
|
-
|
|
|
|
--- file explorer
|
|
|
|
-require('mini.files').setup({
|
|
|
|
- content = {
|
|
|
|
- -- remove icons
|
|
|
|
- prefix = function() end,
|
|
|
|
- }
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
--- Use Treesitter for syntax highlighting
|
|
|
|
-require('nvim-treesitter.configs').setup({
|
|
|
|
- highlight = {
|
|
|
|
- enable = true,
|
|
|
|
- },
|
|
|
|
- indent = {
|
|
|
|
- enable = true,
|
|
|
|
- },
|
|
|
|
- incremental_selection = {
|
|
|
|
- enable = true,
|
|
|
|
- keymaps = {
|
|
|
|
- init_selection = ']t',
|
|
|
|
- node_incremental = ']t',
|
|
|
|
- node_decremental = '[t',
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- textobjects = {
|
|
|
|
- swap = {
|
|
|
|
- enable = true,
|
|
|
|
- swap_next = {
|
|
|
|
- ['>,'] = '@parameter.inner',
|
|
|
|
- },
|
|
|
|
- swap_previous = {
|
|
|
|
- ['<,'] = '@parameter.inner',
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
-local tsj_utils = require('treesj.langs.utils')
|
|
|
|
-
|
|
|
|
--- Treesitter-aware split/join
|
|
|
|
-require('treesj').setup({
|
|
|
|
- use_default_keymaps = false,
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
--- Treesitter context
|
|
|
|
-require('treesitter-context').setup({
|
|
|
|
- enable = true,
|
|
|
|
- multiline_threshold = 5,
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
--- Treesitter navigation
|
|
|
|
-require('treewalker').setup()
|
|
|
|
-
|
|
|
|
--- completion
|
|
|
|
-require('blink.cmp').setup({
|
|
|
|
- cmdline = {
|
|
|
|
- enabled = false,
|
|
|
|
- },
|
|
|
|
- completion = {
|
|
|
|
- accept = {
|
|
|
|
- auto_brackets = {
|
|
|
|
- enabled = false,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- documentation = {
|
|
|
|
- auto_show = true,
|
|
|
|
- auto_show_delay_ms = 500,
|
|
|
|
- },
|
|
|
|
- trigger = {
|
|
|
|
- prefetch_on_insert = false,
|
|
|
|
- show_on_keyword = false,
|
|
|
|
- show_on_trigger_character = false,
|
|
|
|
- },
|
|
|
|
- menu = {
|
|
|
|
- draw = {
|
|
|
|
- columns = {
|
|
|
|
- { 'label', 'label_description', gap = 1 },
|
|
|
|
- { 'kind' },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- keymap = {
|
|
|
|
- ['<Enter>'] = { 'select_and_accept', 'fallback' },
|
|
|
|
- ['<C-u>'] = { 'scroll_documentation_up', 'fallback' },
|
|
|
|
- ['<C-d>'] = { 'scroll_documentation_down', 'fallback' },
|
|
|
|
- },
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
--- typescript-vim compiler options
|
|
|
|
-vim.g.typescript_compiler_options = '--incremental --noEmit'
|
|
|
|
-
|
|
|
|
--- stuff
|
|
|
|
-_G.toggle_end_char = function(char)
|
|
|
|
- local cursor = vim.api.nvim_win_get_cursor(0)
|
|
|
|
- local row = cursor[1] - 1
|
|
|
|
- local end_char = vim.api.nvim_buf_get_text(0, row, -2, row, -1, {})[1]
|
|
|
|
- if end_char == char then
|
|
|
|
- vim.api.nvim_buf_set_text(0, row, -2, row, -1, {})
|
|
|
|
- else
|
|
|
|
- vim.api.nvim_buf_set_text(0, row, -1, row, -1, { char })
|
|
|
|
- end
|
|
|
|
-end
|
|
|