no coq for latex

This commit is contained in:
EvilMuffinHa 2022-11-08 20:32:39 -05:00
parent 5989e4213d
commit 914b98ff69
4 changed files with 492 additions and 439 deletions

View File

@ -1,5 +1,5 @@
vim.g.coq_settings = {
auto_start = 'shut-up',
-- auto_start = 'shut-up',
keymap = {
eval_snips = "<Leader>se",
},
@ -26,9 +26,9 @@ vim.g.coq_settings = {
local coq = require('coq')
require('coq_3p') {
{ src = 'vimtex', short_name = 'TEX'},
{ src = 'nvimlua', short_name = 'NLUA', conf_only = true},
{ src = 'bc', short_name = 'CALC', precision = 8},
{ src = 'vimtex', short_name = 'TEX' },
{ src = 'nvimlua', short_name = 'NLUA', conf_only = true },
{ src = 'bc', short_name = 'CALC', precision = 8 },
}
@ -38,8 +38,8 @@ lspstatus.register_progress()
local function find_repo_root(names)
local util = require("lspconfig.util")
local config = names.configfiles
for _, i in ipairs(config) do
local gitroot = util.root_pattern('.git')(i)
local function matcher(filename, _bufnr)
local gitroot = util.root_pattern('.git')(filename)
if gitroot then
for _, file in ipairs(config) do
if util.path.is_file(util.path.join(gitroot, file)) then
@ -47,49 +47,52 @@ local function find_repo_root(names)
end
end
end
return util.root_pattern(unpack(config))(filename)
end
return matcher
end
local lsp_confs = {
sumneko_lua = {
settings = {
Lua = {
-- Settings for working with nvim (copied from https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sumneko_lua)
runtime = {
version = 'LuaJIT',
path = runtime_path,
},
diagnostics = {
globals = {'vim'},
},
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
},
},
},
},
rust_analyzer = {
cmd_env = {
CARGO_TARGET_DIR = "/tmp/rust-analyzer"
},
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy",
allTargets = false,
},
sumneko_lua = {
settings = {
Lua = {
-- Settings for working with nvim (copied from https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sumneko_lua)
runtime = {
version = 'LuaJIT',
path = runtime_path,
},
diagnostics = {
globals = { 'vim' },
},
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
},
},
},
},
rust_analyzer = {
cmd_env = {
CARGO_TARGET_DIR = "/tmp/rust-analyzer"
},
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy",
allTargets = false,
},
cargo = {
features = "all",
}
},
},
},
ccls = {},
},
},
},
ccls = {},
jedi_language_server = {
filetypes = { "python", "sage.python" },
},
gopls = {},
gopls = {},
dartls = {},
tsserver = {
root_dir = find_repo_root({
@ -100,17 +103,17 @@ local lsp_confs = {
root_dir = find_repo_root({
configfiles = { ".eslintrc", ".eslintrc.js", "package.json" }
}),
on_new_config = function (config, new_root_dir)
local default_config = require('lspconfig.server_configurations.eslint').default_config
default_config.on_new_config(config, new_root_dir)
on_new_config = function(config, new_root_dir)
local default_config = require('lspconfig.server_configurations.eslint').default_config
default_config.on_new_config(config, new_root_dir)
local util = require('lspconfig.util')
local pnp_cjs = util.path.join(new_root_dir, '.pnp.cjs')
local pnp_js = util.path.join(new_root_dir, '.pnp.js')
if util.path.exists(pnp_cjs) or util.path.exists(pnp_js) then
config.cmd = { 'yarn', 'exec', unpack(default_config.cmd) }
end
end
local util = require('lspconfig.util')
local pnp_cjs = util.path.join(new_root_dir, '.pnp.cjs')
local pnp_js = util.path.join(new_root_dir, '.pnp.js')
if util.path.exists(pnp_cjs) or util.path.exists(pnp_js) then
config.cmd = { 'yarn', 'exec', unpack(default_config.cmd) }
end
end
},
svelte = {},
svls = {},
@ -120,89 +123,123 @@ local lsp_confs = {
local lsp_special_setup = {
}
local function on_attach(client, _bufnr)
lspstatus.on_attach(client)
end
local lspconfig = require('lspconfig')
for server, conf in pairs(lsp_confs) do
local source_on_attach = conf.on_attach
if source_on_attach == nil then
conf.on_attach = on_attach
else
conf.on_attach = function(client, bufnr)
on_attach(client, bufnr)
source_on_attach(client, bufnr)
end
end
local source_on_attach = conf.on_attach
if source_on_attach == nil then
conf.on_attach = on_attach
else
conf.on_attach = function(client, bufnr)
on_attach(client, bufnr)
source_on_attach(client, bufnr)
end
end
conf.capabilities = vim.tbl_deep_extend(
"keep",
conf.capabilities or {},
lspstatus.capabilities
)
conf.capabilities = vim.tbl_deep_extend(
"keep",
conf.capabilities or {},
lspstatus.capabilities
)
local final_config = coq.lsp_ensure_capabilities(conf)
local final_config = coq.lsp_ensure_capabilities(conf)
local special_setup = lsp_special_setup[server]
if special_setup then
special_setup(final_config)
else
lspconfig[server].setup(final_config)
end
local special_setup = lsp_special_setup[server]
if special_setup then
special_setup(final_config)
else
lspconfig[server].setup(final_config)
end
end
local null_ls = require('null-ls')
null_ls.setup({
sources = {
null_ls.builtins.diagnostics.chktex,
null_ls.builtins.diagnostics.cppcheck,
null_ls.builtins.diagnostics.shellcheck,
sources = {
null_ls.builtins.diagnostics.chktex,
null_ls.builtins.diagnostics.cppcheck,
null_ls.builtins.diagnostics.shellcheck,
null_ls.builtins.code_actions.gitsigns,
},
null_ls.builtins.code_actions.gitsigns,
},
})
vim.diagnostic.config({
severity_sort = true,
update_in_insert = true,
float = {
source = true,
},
severity_sort = true,
update_in_insert = true,
float = {
source = true,
},
})
do -- signs
local signs = {
{'DiagnosticSignError', text='×', texthl='DiagnosticSignError'},
{'DiagnosticSignWarn', text='>', texthl='DiagnosticSignWarn'},
{'DiagnosticSignInfo', text='I', texthl='DiagnosticSignInfo'},
{'DiagnosticSignHint', text='H', texthl='DiagnosticSignHint'},
}
for _, sign in pairs(signs) do
local name = sign[1]
local opts = sign
opts[1] = nil
vim.fn.sign_define(name, opts)
end
local signs = {
{ 'DiagnosticSignError', text = '×', texthl = 'DiagnosticSignError' },
{ 'DiagnosticSignWarn', text = '>', texthl = 'DiagnosticSignWarn' },
{ 'DiagnosticSignInfo', text = 'I', texthl = 'DiagnosticSignInfo' },
{ 'DiagnosticSignHint', text = 'H', texthl = 'DiagnosticSignHint' },
}
for _, sign in pairs(signs) do
local name = sign[1]
local opts = sign
opts[1] = nil
vim.fn.sign_define(name, opts)
end
end
local map = vim.api.nvim_set_keymap
map(
'n',
'K',
[[luaeval('next(vim.lsp.buf_get_clients()) == nil') ? 'K' : '<Cmd>lua vim.lsp.buf.hover()<CR>']],
{noremap = true, expr = true}
'n',
'K',
[[luaeval('next(vim.lsp.buf_get_clients()) == nil') ? 'K' : '<Cmd>lua vim.lsp.buf.hover()<CR>']],
{ noremap = true, expr = true }
)
map(
'n',
'<C-]>',
[[luaeval('next(vim.lsp.buf_get_clients()) == nil') ? '<C-]>' : '<Cmd>lua vim.lsp.buf.definition()<CR>']],
{noremap = true, expr = true}
'n',
'<C-]>',
[[luaeval('next(vim.lsp.buf_get_clients()) == nil') ? '<C-]>' : '<Cmd>lua vim.lsp.buf.definition()<CR>']],
{ noremap = true, expr = true }
)
local M = {}
M.format_on_save_hook = function()
local enabled = vim.b.format_on_save
if enabled == nil then
enabled = true
end
if enabled ~= 0 and enabled ~= false then
vim.lsp.buf.format({ async = false })
end
end
vim.cmd [[
augroup lspconfig
augroup hoverlspconfig
au!
" diagnostic on hover
au BufWritePre * lua require'lsp'.format_on_save_hook()
au CursorHold * lua vim.diagnostic.open_float({focus = false})
augroup END
]]
vim.api.nvim_create_autocmd('FileType', {
pattern = "*",
callback = function()
if vim.bo.filetype ~= "plaintex" and vim.bo.filetype ~= "tex" and vim.bo.filetype ~= "latex" then
vim.cmd [[ :COQnow -s ]]
end
end
})
-- vim.cmd [[
-- augroup disabletexlsp
-- autocmd!
-- autocmd FileType tex :COQstop
-- augroup END
-- ]]
return M

View File

@ -18,32 +18,32 @@ o.termguicolors = true
vim.cmd('colorscheme theme')
vim.g.airline_theme='theme'
vim.g.airline_theme = 'theme'
map('n', '<Leader>s', ':%s//g<Left><Left>', {})
map('n', '<Leader>e', ':make!<CR>', {noremap = true})
map('n', '<C-o>', ':cclose<CR>', {noremap = true})
map('n', '<C-L>', ':nohlsearch<CR><C-L>', {noremap = true, silent = true})
map('n', ';', ':', {noremap = true})
map('v', ';', ':', {noremap = true})
map('n', '<Leader>e', ':make!<CR>', { noremap = true })
map('n', '<C-o>', ':cclose<CR>', { noremap = true })
map('n', '<C-L>', ':nohlsearch<CR><C-L>', { noremap = true, silent = true })
map('n', ';', ':', { noremap = true })
map('v', ';', ':', { noremap = true })
for i = 1,9,1 do
map('', '<Leader>' .. tostring(i), tostring(i) .. 'gt', {noremap = true})
for i = 1, 9, 1 do
map('', '<Leader>' .. tostring(i), tostring(i) .. 'gt', { noremap = true })
end
map('n', '<C-Left>', ':tabprevious<CR>', {noremap = true})
map('n', '<C-Right>', ':tabnext<CR>', {noremap = true})
map('', '<Leader>0', ':tablast<CR>', {noremap = true})
map('n', 'ZX', '<Cmd>q<CR>', {noremap = true, silent = true})
map('n', '<C-Left>', ':tabprevious<CR>', { noremap = true })
map('n', '<C-Right>', ':tabnext<CR>', { noremap = true })
map('', '<Leader>0', ':tablast<CR>', { noremap = true })
map('n', 'ZX', '<Cmd>q<CR>', { noremap = true, silent = true })
map('t', '<Esc>', '<C-\\><C-n>', {noremap = true})
map('t', '<Esc>', '<C-\\><C-n>', { noremap = true })
o.list=true
o.list = true
o.listchars = {
tab = '',
eol = '¬',
trail = '·',
extends = ''
tab = '',
eol = '¬',
trail = '·',
extends = ''
}
vim.cmd [[

View File

@ -1,69 +1,73 @@
local bootstrap = require('bootstrap')
local function import(name)
return ([[require '%s']]):format(name)
return ([[require '%s']]):format(name)
end
return require('packer').startup({function(use)
use 'wbthomason/packer.nvim'
return require('packer').startup({ function(use)
use 'wbthomason/packer.nvim'
use {
'vim-airline/vim-airline',
requires = {
'ryanoasis/vim-devicons',
}
}
use {
'mustache/vim-mustache-handlebars'
'vim-airline/vim-airline',
requires = {
'ryanoasis/vim-devicons',
}
}
use {
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate'
'mustache/vim-mustache-handlebars'
}
use {
'petRUShka/vim-sage'
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate'
}
use {
'evanleck/vim-svelte'
'petRUShka/vim-sage'
}
use {
'tpope/vim-fugitive',
config = function()
local map = vim.api.nvim_set_keymap
map('n', '<Leader>g', '<Cmd>Git<CR>', {noremap = true})
end,
}
use {
'evanleck/vim-svelte'
}
use {
'tpope/vim-surround',
}
use {
'tpope/vim-fugitive',
config = function()
local map = vim.api.nvim_set_keymap
map('n', '<Leader>g', '<Cmd>Git<CR>', { noremap = true })
end,
}
use {
'tpope/vim-repeat',
}
use {
'tpope/vim-surround',
}
use {
'lewis6991/gitsigns.nvim',
requires = {
'nvim-lua/plenary.nvim'
},
config = function()
require('gitsigns').setup {
signs = {
add = {hl = 'GitSignsAdd' , text = '', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'},
change = {hl = 'GitSignsChange', text = '', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'},
delete = {hl = 'GitSignsDelete', text = '_', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
topdelete = {hl = 'GitSignsDelete', text = '', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
changedelete = {hl = 'GitSignsChange', text = '~', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'},
},
}
end
}
use {
'tpope/vim-repeat',
}
use {
'lewis6991/gitsigns.nvim',
requires = {
'nvim-lua/plenary.nvim'
},
config = function()
require('gitsigns').setup {
signs = {
add = { hl = 'GitSignsAdd', text = '', numhl = 'GitSignsAddNr', linehl = 'GitSignsAddLn' },
change = { hl = 'GitSignsChange', text = '', numhl = 'GitSignsChangeNr',
linehl = 'GitSignsChangeLn' },
delete = { hl = 'GitSignsDelete', text = '_', numhl = 'GitSignsDeleteNr',
linehl = 'GitSignsDeleteLn' },
topdelete = { hl = 'GitSignsDelete', text = '', numhl = 'GitSignsDeleteNr',
linehl = 'GitSignsDeleteLn' },
changedelete = { hl = 'GitSignsChange', text = '~', numhl = 'GitSignsChangeNr',
linehl = 'GitSignsChangeLn' },
},
}
end
}
use {
'akinsho/flutter-tools.nvim',
@ -71,7 +75,7 @@ return require('packer').startup({function(use)
'nvim-lua/plenary.nvim'
},
config = function()
require('flutter-tools').setup{
require('flutter-tools').setup {
lsp = {
color = {
enabled = false
@ -81,106 +85,117 @@ return require('packer').startup({function(use)
end
}
use {
'numToStr/Comment.nvim',
config = function()
local map = vim.api.nvim_set_keymap
require('Comment').setup({})
map('n', '<C-_>',
'<Cmd>lua require("Comment.api").toggle_linewise_op(vim.fn.visualmode())<CR>',
{noremap = true, silent = true})
end
}
use {
'nvim-telescope/telescope.nvim',
requires = {
'nvim-lua/plenary.nvim',
{
'nvim-telescope/telescope-fzf-native.nvim',
run = 'make',
},
'nvim-telescope/telescope-symbols.nvim',
},
config = import('tel'),
}
use {
'stevearc/dressing.nvim',
config = function()
require('dressing').setup({
input = {
default_prompt = '',
winhighlight = 'NormalFloat:Normal',
},
})
vim.cmd [[highlight link FloatTitle NonText]]
vim.cmd [[highlight link DressingInputText Normal]]
end,
}
use {
'antoinemadec/FixCursorHold.nvim',
config = function()
vim.g.cursorhold_updatetime = 500
end,
}
use {
'neovim/nvim-lspconfig',
-- commit = "607ff48b970b89c3e4e3825b88d9cfd05b7aaea5",
requires = {
'nvim-lua/lsp-status.nvim',
'ms-jpq/coq.thirdparty',
{
'ms-jpq/coq_nvim',
run = ':COQdeps',
requires = {
'ms-jpq/coq.artifacts',
},
},
{
'jose-elias-alvarez/null-ls.nvim',
requires = {
'nvim-lua/plenary.nvim',
},
},
},
config = import('lsp'),
}
use {
'lervag/vimtex',
config = function()
vim.g.vimtex_view_general_viewer = 'zathura'
-- vim.g.vimtex_view_general_options = = '-x nvim -n -c "Vimtex'
-- 'file:@pdf\\#src:@line@tex'
-- vim.g.vimtex_quickfix_enabled = 0
-- vim.g.Tex_GotoError = 0
-- vim.g.Tex_ShowErrorContext = 0
end,
}
use {
'iamcco/markdown-preview.nvim',
commit = "02cc3874738bc0f86e4b91f09b8a0ac88aef8e96",
run = "cd app && npm install",
setup = function() vim.g.mkdp_filetypes = { "markdown" } end, ft = { "markdown" },
config = function()
local map = vim.api.nvim_set_keymap
map('n', '<C-m>', '<Plug>MarkdownPreviewToggle', {})
map('n', '<Leader>m', '<Plug>MarkdownPreviewToggle', {})
vim.g.mkdp_markdown_css = os.getenv("HOME") .. "/.config/nvim/lua/markdownStyle.css"
vim.g.mkdp_highlight_css = os.getenv("HOME") .. "/.cache/wal/colors.css"
end
use {
'numToStr/Comment.nvim',
config = function()
local map = vim.api.nvim_set_keymap
require('Comment').setup({})
map('n', '<C-_>',
'<Cmd>lua require("Comment.api").toggle_linewise_op(vim.fn.visualmode())<CR>',
{ noremap = true, silent = true })
end
}
if bootstrap.is_bootstrap then
require('packer').sync()
end
use {
'nvim-telescope/telescope.nvim',
requires = {
'nvim-lua/plenary.nvim',
{
'nvim-telescope/telescope-fzf-native.nvim',
run = 'make',
},
'nvim-telescope/telescope-symbols.nvim',
},
config = import('tel'),
}
use {
'stevearc/dressing.nvim',
config = function()
require('dressing').setup({
input = {
default_prompt = '',
winhighlight = 'NormalFloat:Normal',
},
})
vim.cmd [[highlight link FloatTitle NonText]]
vim.cmd [[highlight link DressingInputText Normal]]
end,
}
use {
'antoinemadec/FixCursorHold.nvim',
config = function()
vim.g.cursorhold_updatetime = 500
end,
}
use {
'sirver/ultisnips',
ft = { 'latex', 'plaintex', 'tex' },
config = function()
vim.g.UltiSnipsExpandTrigger = '<tab>'
vim.g.UltiSnipsJumpForwardTrigger = '<tab>'
vim.g.UltiSnipsJumpBackwardTrigger = '<s-tab>'
end
}
use {
'neovim/nvim-lspconfig',
-- commit = "607ff48b970b89c3e4e3825b88d9cfd05b7aaea5",
requires = {
'nvim-lua/lsp-status.nvim',
{
'ms-jpq/coq.thirdparty',
},
{
'ms-jpq/coq_nvim',
run = ':COQdeps',
requires = {
'ms-jpq/coq.artifacts',
},
},
{
'jose-elias-alvarez/null-ls.nvim',
requires = {
'nvim-lua/plenary.nvim',
},
},
},
config = import('lsp'),
}
use {
'lervag/vimtex',
config = function()
vim.g.vimtex_view_general_viewer = 'zathura'
-- vim.g.vimtex_view_general_options = = '-x nvim -n -c "Vimtex'
-- 'file:@pdf\\#src:@line@tex'
-- vim.g.vimtex_quickfix_enabled = 0
-- vim.g.Tex_GotoError = 0
-- vim.g.Tex_ShowErrorContext = 0
end,
}
use {
'iamcco/markdown-preview.nvim',
commit = "02cc3874738bc0f86e4b91f09b8a0ac88aef8e96",
run = "cd app && npm install",
setup = function() vim.g.mkdp_filetypes = { "markdown" } end, ft = { "markdown" },
config = function()
local map = vim.api.nvim_set_keymap
map('n', '<C-m>', '<Plug>MarkdownPreviewToggle', {})
map('n', '<Leader>m', '<Plug>MarkdownPreviewToggle', {})
vim.g.mkdp_markdown_css = os.getenv("HOME") .. "/.config/nvim/lua/markdownStyle.css"
vim.g.mkdp_highlight_css = os.getenv("HOME") .. "/.cache/wal/colors.css"
end
}
if bootstrap.is_bootstrap then
require('packer').sync()
end
end,
config = {
compile_path = require('packer.util').join_paths(vim.fn.stdpath('data'), 'site', 'plugin', 'packer_compiled.lua'),
}})
config = {
compile_path = require('packer.util').join_paths(vim.fn.stdpath('data'), 'site', 'plugin', 'packer_compiled.lua'),
} })

View File

@ -1,202 +1,204 @@
local telescope = require('telescope')
telescope.setup({
defaults = {
file_ignore_patterns = {'.git'},
mappings = {
i = {
['<C-o>'] = { '<Esc>', type = 'command' },
['<Esc>'] = 'close',
defaults = {
file_ignore_patterns = { '.git' },
mappings = {
i = {
['<C-o>'] = { '<Esc>', type = 'command' },
['<Esc>'] = 'close',
['<C-s>'] = 'select_horizontal',
},
n = {
q = 'close',
['<C-s>'] = 'select_horizontal',
},
n = {
q = 'close',
['<C-o>'] = { '<Nop>', type = 'command' },
['<C-o>'] = { '<Nop>', type = 'command' },
['<C-s>'] = 'select_horizontal',
},
},
sorting_strategy = 'ascending',
layout_config = {
prompt_position = 'top',
},
prompt_prefix = ' ',
selection_caret = ' ',
multi_icon = '',
},
pickers = {
buffers = {
mappings = {
n = {
dd = 'delete_buffer',
},
},
},
find_files = {
hidden = true,
},
lsp_code_actions = {
initial_mode = 'normal',
},
lsp_range_code_actions = {
initial_mode = 'normal',
},
},
['<C-s>'] = 'select_horizontal',
},
},
sorting_strategy = 'ascending',
layout_config = {
prompt_position = 'top',
},
prompt_prefix = ' ',
selection_caret = ' ',
multi_icon = '',
},
pickers = {
buffers = {
mappings = {
n = {
dd = 'delete_buffer',
},
},
},
find_files = {
hidden = true,
},
lsp_code_actions = {
initial_mode = 'normal',
},
lsp_range_code_actions = {
initial_mode = 'normal',
},
},
})
telescope.load_extension('fzf')
-- taken from https://github.com/nvim-telescope/telescope-ui-select.nvim for code actions
telescope.register_extension {
setup = function(topts)
local specific_opts = vim.F.if_nil(topts.specific_opts, {})
topts.specific_opts = nil
setup = function(topts)
local specific_opts = vim.F.if_nil(topts.specific_opts, {})
topts.specific_opts = nil
if #topts == 1 and topts[1] ~= nil then
topts = topts[1]
end
if #topts == 1 and topts[1] ~= nil then
topts = topts[1]
end
local pickers = require "telescope.pickers"
local finders = require "telescope.finders"
local conf = require("telescope.config").values
local actions = require "telescope.actions"
local action_state = require "telescope.actions.state"
local strings = require "plenary.strings"
local entry_display = require "telescope.pickers.entry_display"
local utils = require "telescope.utils"
local pickers = require "telescope.pickers"
local finders = require "telescope.finders"
local conf = require("telescope.config").values
local actions = require "telescope.actions"
local action_state = require "telescope.actions.state"
local strings = require "plenary.strings"
local entry_display = require "telescope.pickers.entry_display"
local utils = require "telescope.utils"
__TelescopeUISelectSpecificOpts = vim.F.if_nil(
__TelescopeUISelectSpecificOpts,
vim.tbl_extend("keep", specific_opts, {
["codeaction"] = {
make_indexed = function(items)
local indexed_items = {}
local widths = {
idx = 0,
command_title = 0,
client_name = 0,
}
for idx, item in ipairs(items) do
local client = vim.lsp.get_client_by_id(item[1])
local entry = {
idx = idx,
["add"] = {
command_title = item[2].title:gsub("\r\n", "\\r\\n"):gsub("\n", "\\n"),
client_name = client and client.name or "",
},
text = item,
}
table.insert(indexed_items, entry)
widths.idx = math.max(widths.idx, strings.strdisplaywidth(entry.idx))
widths.command_title = math.max(widths.command_title, strings.strdisplaywidth(entry.add.command_title))
widths.client_name = math.max(widths.client_name, strings.strdisplaywidth(entry.add.client_name))
end
return indexed_items, widths
end,
make_displayer = function(widths)
return entry_display.create {
separator = " ",
items = {
{ width = widths.idx + 1 }, -- +1 for ":" suffix
{ width = widths.command_title },
{ width = widths.client_name },
},
}
end,
make_display = function(displayer)
return function(e)
return displayer {
{ e.value.idx .. ":", "TelescopePromptPrefix" },
{ e.value.add.command_title },
{ e.value.add.client_name, "TelescopeResultsComment" },
}
end
end,
make_ordinal = function(e)
return e.idx .. e.add["command_title"]
end,
},
})
)
__TelescopeUISelectSpecificOpts = vim.F.if_nil(
__TelescopeUISelectSpecificOpts,
vim.tbl_extend("keep", specific_opts, {
["codeaction"] = {
make_indexed = function(items)
local indexed_items = {}
local widths = {
idx = 0,
command_title = 0,
client_name = 0,
}
for idx, item in ipairs(items) do
local client = vim.lsp.get_client_by_id(item[1])
local entry = {
idx = idx,
["add"] = {
command_title = item[2].title:gsub("\r\n", "\\r\\n"):gsub("\n", "\\n"),
client_name = client and client.name or "",
},
text = item,
}
table.insert(indexed_items, entry)
widths.idx = math.max(widths.idx, strings.strdisplaywidth(entry.idx))
widths.command_title = math.max(widths.command_title,
strings.strdisplaywidth(entry.add.command_title))
widths.client_name = math.max(widths.client_name,
strings.strdisplaywidth(entry.add.client_name))
end
return indexed_items, widths
end,
make_displayer = function(widths)
return entry_display.create {
separator = " ",
items = {
{ width = widths.idx + 1 }, -- +1 for ":" suffix
{ width = widths.command_title },
{ width = widths.client_name },
},
}
end,
make_display = function(displayer)
return function(e)
return displayer {
{ e.value.idx .. ":", "TelescopePromptPrefix" },
{ e.value.add.command_title },
{ e.value.add.client_name, "TelescopeResultsComment" },
}
end
end,
make_ordinal = function(e)
return e.idx .. e.add["command_title"]
end,
},
})
)
vim.ui.select = function(items, opts, on_choice)
opts = opts or {}
local prompt = vim.F.if_nil(opts.prompt, "Select one of")
if prompt:sub(-1, -1) == ":" then
prompt = prompt:sub(1, -2)
end
opts.format_item = vim.F.if_nil(opts.format_item, function(e)
return tostring(e)
end)
vim.ui.select = function(items, opts, on_choice)
opts = opts or {}
local prompt = vim.F.if_nil(opts.prompt, "Select one of")
if prompt:sub(-1, -1) == ":" then
prompt = prompt:sub(1, -2)
end
opts.format_item = vim.F.if_nil(opts.format_item, function(e)
return tostring(e)
end)
-- We want or here because __TelescopeUISelectSpecificOpts[x] can be either nil or even false -> {}
local sopts = __TelescopeUISelectSpecificOpts[vim.F.if_nil(opts.kind, "")] or {}
local indexed_items, widths = vim.F.if_nil(sopts.make_indexed, function(items_)
local indexed_items = {}
for idx, item in ipairs(items_) do
table.insert(indexed_items, { idx = idx, text = item })
end
return indexed_items
end)(items)
local displayer = vim.F.if_nil(sopts.make_displayer, function() end)(widths)
local make_display = vim.F.if_nil(sopts.make_display, function(_)
return function(e)
local x, _ = opts.format_item(e.value.text)
return x
end
end)(displayer)
local make_ordinal = vim.F.if_nil(sopts.make_ordinal, function(e)
return opts.format_item(e.text)
end)
pickers.new(topts, {
prompt_title = prompt,
finder = finders.new_table {
results = indexed_items,
entry_maker = function(e)
return {
value = e,
display = make_display,
ordinal = make_ordinal(e),
}
end,
},
attach_mappings = function(prompt_bufnr)
actions.select_default:replace(function()
local selection = action_state.get_selected_entry()
if selection == nil then
utils.__warn_no_selection "ui-select"
return
end
actions.close(prompt_bufnr)
on_choice(selection.value.text, selection.value.idx)
end)
return true
end,
sorter = conf.generic_sorter(topts),
}):find()
end
end,
-- We want or here because __TelescopeUISelectSpecificOpts[x] can be either nil or even false -> {}
local sopts = __TelescopeUISelectSpecificOpts[vim.F.if_nil(opts.kind, "")] or {}
local indexed_items, widths = vim.F.if_nil(sopts.make_indexed, function(items_)
local indexed_items = {}
for idx, item in ipairs(items_) do
table.insert(indexed_items, { idx = idx, text = item })
end
return indexed_items
end)(items)
local displayer = vim.F.if_nil(sopts.make_displayer, function() end)(widths)
local make_display = vim.F.if_nil(sopts.make_display, function(_)
return function(e)
local x, _ = opts.format_item(e.value.text)
return x
end
end)(displayer)
local make_ordinal = vim.F.if_nil(sopts.make_ordinal, function(e)
return opts.format_item(e.text)
end)
pickers.new(topts, {
prompt_title = prompt,
finder = finders.new_table {
results = indexed_items,
entry_maker = function(e)
return {
value = e,
display = make_display,
ordinal = make_ordinal(e),
}
end,
},
attach_mappings = function(prompt_bufnr)
actions.select_default:replace(function()
local selection = action_state.get_selected_entry()
if selection == nil then
utils.__warn_no_selection "ui-select"
return
end
actions.close(prompt_bufnr)
on_choice(selection.value.text, selection.value.idx)
end)
return true
end,
sorter = conf.generic_sorter(topts),
}):find()
end
end,
}
local map = vim.api.nvim_set_keymap
map('n', '<Leader>pf', '<Cmd>Telescope find_files<CR>', {noremap = true})
map('n', '<Leader>pb', '<Cmd>Telescope buffers<CR>', {noremap = true})
map('n', '<Leader>po', '<Cmd>Telescope lsp_document_symbols<CR>', {noremap = true})
map('n', '<Leader>ps', '<Cmd>Telescope lsp_workspace_symbols<CR>', {noremap = true})
map('n', '<Leader>pd', '<Cmd>Telescope lsp_definitions<CR>', {noremap = true})
map('n', '<Leader>pr', '<Cmd>Telescope lsp_references<CR>', {noremap = true})
map('n', '<Leader>p', ':Telescope ', {noremap = true})
map('n', '<Leader>p ', ':Telescope ', {noremap = true})
map('n', '<Leader>pf', '<Cmd>Telescope find_files<CR>', { noremap = true })
map('n', '<Leader>pb', '<Cmd>Telescope buffers<CR>', { noremap = true })
map('n', '<Leader>po', '<Cmd>Telescope lsp_document_symbols<CR>', { noremap = true })
map('n', '<Leader>ps', '<Cmd>Telescope lsp_workspace_symbols<CR>', { noremap = true })
map('n', '<Leader>pd', '<Cmd>Telescope lsp_definitions<CR>', { noremap = true })
map('n', '<Leader>pr', '<Cmd>Telescope lsp_references<CR>', { noremap = true })
map('n', '<Leader>pp', '<C-^>', { noremap = true })
map('n', '<Leader>p', ':Telescope ', { noremap = true })
map('n', '<Leader>p ', ':Telescope ', { noremap = true })
map('n', '<Leader>.', ':lua vim.lsp.buf.code_action()<CR>', {noremap = true})
map('n', '<Leader>.', ':lua vim.lsp.buf.code_action()<CR>', { noremap = true })
-- vim.cmd [[
-- function! s:telescope_hlsetup() abort
-- highlight link TelescopeBorder NonText
-- highlight link TelescopeBorder NonText
-- highlight link TelescopeTitle NonText
-- endfunction
-- call s:telescope_hlsetup()
@ -205,4 +207,3 @@ map('n', '<Leader>.', ':lua vim.lsp.buf.code_action()<CR>', {noremap = true})
-- au ColorScheme * call s:telescope_hlsetup()
-- augroup END
-- ]]