nvim: switch to lazy
This commit is contained in:
6
nvim/.config/nvim/init.lua
Normal file
6
nvim/.config/nvim/init.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
require("config.builtins")
|
||||
require("config.utils")
|
||||
require("config.settings")
|
||||
require("config.filetypes")
|
||||
require("config.lazy")
|
||||
require("config.mappings")
|
||||
30
nvim/.config/nvim/lazy-lock.json
Normal file
30
nvim/.config/nvim/lazy-lock.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||
"cmp-git": { "branch": "main", "commit": "ec049036e354ed8ed0215f2427112882e1ea7051" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
|
||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"cmp-spell": { "branch": "master", "commit": "694a4e50809d6d645c1ea29015dad0c293f019d6" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
|
||||
"conform.nvim": { "branch": "master", "commit": "02fd64fb3d4b18ec029c0e0683c3dc3ec6d2c5b8" },
|
||||
"dressing.nvim": { "branch": "master", "commit": "fc78a3ca96f4db9f8893bb7e2fd9823e0780451b" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "3388a26417c48b15d5266d954f62a4d47fe99490" },
|
||||
"lsp-format-modifications.nvim": { "branch": "main", "commit": "006d4cd88f4f09fdc4375fcb75dd5b7d981a723b" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "8e46de9241d3997927af12196bd8faa0ed08c29a" },
|
||||
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
|
||||
"neoconf.nvim": { "branch": "main", "commit": "d5ca361c77a7a5f58476f1d0aab43532c4bbb289" },
|
||||
"neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" },
|
||||
"neodim": { "branch": "master", "commit": "7d31f389a6bb01707fb9b7a811abdb685c09ab08" },
|
||||
"nord": { "branch": "main", "commit": "4cc19936b1b57ba08eb461c5f450b3976cbb8e0c" },
|
||||
"nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "ca4d3330d386e76967e53b85953c170658255ecb" },
|
||||
"nvim-lsp-file-operations": { "branch": "master", "commit": "9744b738183a5adca0f916527922078a965515ed" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "2c007c79eedfca0ec652c50d571cb0c52d1577ba" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "ca7c4c33cac2ad66ec69d45e465379716ef0cc97" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "acada1a685f5decd0f10e1672963bf3425eafa45" },
|
||||
"oil.nvim": { "branch": "master", "commit": "9a59256c8e88b29d2150e99b5960b2f111e51f75" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
|
||||
"rustaceanvim": { "branch": "master", "commit": "bf3d8c7bcbf20a7e7f4af36c2d5390ca6ad43281" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
|
||||
"trouble.nvim": { "branch": "main", "commit": "46cf952fc115f4c2b98d4e208ed1e2dce08c9bf6" },
|
||||
"vim-tmux-navigator": { "branch": "master", "commit": "424b5caa154bff34dc258ee53cec5a8e36cf7ea8" }
|
||||
}
|
||||
@@ -15,3 +15,4 @@ vim.g.loaded_matchit = 1
|
||||
vim.g.loaded_matchparen = 1
|
||||
vim.g.loaded_logiPat = 1
|
||||
vim.g.loaded_rrhelper = 1
|
||||
vim.g.loaded_shada_plugin = 1
|
||||
34
nvim/.config/nvim/lua/config/lazy.lua
Normal file
34
nvim/.config/nvim/lua/config/lazy.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
-- Bootstrap lazy.nvim
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.api.nvim_echo({
|
||||
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||
{ out, "WarningMsg" },
|
||||
{ "\nPress any key to exit..." },
|
||||
}, true, {})
|
||||
vim.fn.getchar()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
vim.g.mapleader = ' '
|
||||
|
||||
-- Setup lazy.nvim
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
-- import your plugins
|
||||
{ import = "plugins" },
|
||||
},
|
||||
-- Configure any other settings here. See the documentation for more details.
|
||||
-- colorscheme that will be used when installing plugins.
|
||||
install = { colorscheme = { "nord" } },
|
||||
-- automatically check for plugin updates
|
||||
checker = { enabled = false },
|
||||
change_detection = {
|
||||
notify = false,
|
||||
},
|
||||
})
|
||||
@@ -12,6 +12,14 @@ end
|
||||
-- Essentials
|
||||
vim.g.mapleader = ' '
|
||||
|
||||
-- TODO: move to keys (lazy telescope)
|
||||
vim.keymap.set('n', '<leader>ff', function() require('telescope.builtin').find_files({ hidden = true }) end)
|
||||
vim.keymap.set('n', '<leader>fb', function() require('telescope.builtin').buffers({ hidden = true }) end)
|
||||
vim.keymap.set('n', '<leader>fo', function() require('telescope.builtin').find_files({ cwd = '~/Syncthing/Obsidian/Personal/', search_file = '*.md' }) end)
|
||||
vim.keymap.set('n', '<leader>fO', function() require('telescope.builtin').live_grep({ cwd = '~/Syncthing/Obsidian/Personal/', search_file = '*.md' }) end)
|
||||
vim.keymap.set('n', '<leader>fh', function() require('telescope.builtin').help_tags() end)
|
||||
vim.keymap.set('n', '<leader>fq', function() require('telescope.builtin').quickfix() end)
|
||||
|
||||
nmap(';', ':')
|
||||
map('v', ';', ':')
|
||||
nmap(',,', '<C-^>')
|
||||
@@ -70,24 +78,42 @@ nmap('<leader>gs', ':Git<CR>')
|
||||
nmap('<leader>gb', ':Git blame<CR>')
|
||||
|
||||
-- rails-vim
|
||||
nmap('<leader>a', ':A<CR>')
|
||||
-- nmap('<leader>a', ':A<CR>')
|
||||
nmap('<leader>a', function()
|
||||
local path = vim.fn.expand('%')
|
||||
|
||||
vim.print(path)
|
||||
|
||||
-- if path.ends('_spec.rb') then
|
||||
-- vim.print('spec')
|
||||
-- elseif path.contains('app') then
|
||||
-- vim.print('app')
|
||||
-- else
|
||||
-- vim.print('nothing')
|
||||
-- end
|
||||
end)
|
||||
|
||||
-- test
|
||||
nmap('<leader>r', function() os.execute("tmux send-keys -t '{down-of}' './bin/rspec '" .. vim.fn.expand("%") .. " Enter") end)
|
||||
nmap('<leader>R', function() os.execute("tmux send-keys -t '{down-of}' './bin/rspec .' Enter") end)
|
||||
|
||||
-- CtrlSF
|
||||
nmap('<C-f>', '<Plug>CtrlSFPrompt')
|
||||
-- grep
|
||||
nmap('<C-f>', ':grep ')
|
||||
|
||||
-- trim whitespace
|
||||
nmap('<leader>W', ':TrimWhitespace<CR>')
|
||||
|
||||
-- EXPERIMENTAL:
|
||||
nmap('<leader>x', ":call delete(expand('%')) | bdelete!<CR>")
|
||||
-- this is bad because of the accidental missclicks
|
||||
-- nmap('<leader>x', ":call delete(expand('%')) | bdelete!<CR>")
|
||||
|
||||
nmap('<leader>q', ':copen<CR>')
|
||||
|
||||
-- pick one (comma makes more sense?)
|
||||
nmap(']q', ':cnext<CR>')
|
||||
nmap('[q', ':cprevious<CR>')
|
||||
nmap('[q', ':cprev<CR>')
|
||||
nmap(',w', ':cnext<CR>')
|
||||
nmap(',q', ':cprev<CR>')
|
||||
|
||||
-- command mode
|
||||
vim.keymap.set('c', '<C-a>', '<Home>')
|
||||
@@ -103,6 +129,13 @@ vim.keymap.set('x', 'P', [['Pgv"'.v:register.'y`>']], expr)
|
||||
vim.keymap.set('n', '<C-d>', '<C-d>zz', { desc = 'Scroll downwards' })
|
||||
vim.keymap.set('n', '<C-u>', '<C-u>zz', { desc = 'Scroll upwards' })
|
||||
|
||||
-- TODO: luaify
|
||||
-- create alternate buffer if not exist
|
||||
-- vim.api.nvim_exec([[
|
||||
-- command AC :execute "e " . eval('rails#buffer().alternate()')
|
||||
-- ]], false)
|
||||
|
||||
|
||||
-- vim.keymap.set('n', '<leader>to', '<cmd>tabonly<cr>', { desc = 'Close other tab pages' })
|
||||
|
||||
-- Make U opposite to u.
|
||||
@@ -1,7 +1,7 @@
|
||||
local opt, g = vim.opt, vim.g
|
||||
|
||||
opt.smartindent = true -- Autoindenting when starting a new line
|
||||
opt.completeopt = {'menu', 'menuone', 'noselect'}
|
||||
opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||
opt.tabstop = 2 -- Tab counts as 2 columns
|
||||
opt.shiftwidth = 2 -- Numbers of spaces to (auto)indent
|
||||
opt.expandtab = true -- Tabs to spaces
|
||||
@@ -77,7 +77,6 @@ opt.shortmess = {
|
||||
|
||||
if vim.fn.executable('rg') > 0 then
|
||||
vim.o.grepprg = [[rg --glob "!.git" --no-heading --vimgrep --follow $*]]
|
||||
-- opt.grepformat = opt.grepformat ^ { '%f:%l:%c:%m' }
|
||||
end
|
||||
|
||||
-- ignore when autocompleting
|
||||
@@ -90,17 +89,17 @@ opt.wildignore = {
|
||||
}
|
||||
|
||||
-- CtrlSF
|
||||
g.ctrlsf_ackprg = 'rg'
|
||||
g.ctrlsf_regex_pattern = 1
|
||||
g.ctrlsf_case_sensitive = 'smart'
|
||||
g.ctrlsf_default_root = 'project'
|
||||
g.ctrlsf_context = '-B 1 -A 1'
|
||||
g.ctrlsf_position = 'bottom'
|
||||
g.ctrlsf_winsize = '40%'
|
||||
g.ctrlsf_mapping = {
|
||||
next = 'n',
|
||||
prev = 'N',
|
||||
}
|
||||
-- g.ctrlsf_ackprg = 'rg'
|
||||
-- g.ctrlsf_regex_pattern = 1
|
||||
-- g.ctrlsf_case_sensitive = 'smart'
|
||||
-- g.ctrlsf_default_root = 'project'
|
||||
-- g.ctrlsf_context = '-B 1 -A 1'
|
||||
-- g.ctrlsf_position = 'bottom'
|
||||
-- g.ctrlsf_winsize = '40%'
|
||||
-- g.ctrlsf_mapping = {
|
||||
-- next = 'n',
|
||||
-- prev = 'N',
|
||||
-- }
|
||||
|
||||
g.ruby_host_prog = 'asdf exec neovim-ruby-host'
|
||||
|
||||
@@ -139,5 +138,3 @@ opt.updatetime = 100
|
||||
opt.timeout = true
|
||||
opt.timeoutlen = 1000
|
||||
opt.ttimeoutlen = 10
|
||||
|
||||
vim.cmd('packadd cfilter')
|
||||
1
nvim/.config/nvim/lua/plugins/bqf.lua
Normal file
1
nvim/.config/nvim/lua/plugins/bqf.lua
Normal file
@@ -0,0 +1 @@
|
||||
return { 'kevinhwang91/nvim-bqf' }
|
||||
165
nvim/.config/nvim/lua/plugins/cmp.lua
Normal file
165
nvim/.config/nvim/lua/plugins/cmp.lua
Normal file
@@ -0,0 +1,165 @@
|
||||
return {
|
||||
{
|
||||
'hrsh7th/nvim-cmp',
|
||||
event = 'InsertEnter',
|
||||
opts = function()
|
||||
local lsp = {
|
||||
kinds = {
|
||||
-- Text = '',
|
||||
-- Method = '',
|
||||
-- Function = '',
|
||||
-- Constructor = '',
|
||||
-- Field = '',
|
||||
-- Variable = '',
|
||||
-- Class = '',
|
||||
-- Interface = '',
|
||||
-- Module = '',
|
||||
-- Property = '',
|
||||
-- Unit = '',
|
||||
-- Value = '',
|
||||
-- Enum = '',
|
||||
-- Keyword = '',
|
||||
-- Snippet = '',
|
||||
-- Color = '',
|
||||
-- File = '',
|
||||
-- Reference = '',
|
||||
-- Folder = '',
|
||||
-- EnumMember = '',
|
||||
-- Constant = '',
|
||||
-- Struct = '',
|
||||
-- Event = '',
|
||||
-- Operator = '',
|
||||
TypeParameter = '',
|
||||
},
|
||||
}
|
||||
local menu = {
|
||||
luasnip = '[snip]',
|
||||
nvim_lsp = '[LSP]',
|
||||
git = '[git]',
|
||||
spell = '[spell]',
|
||||
path = '[path]',
|
||||
buffer = '[buf]',
|
||||
}
|
||||
|
||||
local cmp = require 'cmp'
|
||||
|
||||
-- supertab-like mapping
|
||||
local mapping = {
|
||||
['<C-n>'] = cmp.mapping.select_next_item {
|
||||
behavior = cmp.SelectBehavior.Insert,
|
||||
},
|
||||
['<C-p>'] = cmp.mapping.select_prev_item {
|
||||
behavior = cmp.SelectBehavior.Insert,
|
||||
},
|
||||
['<C-y>'] = cmp.mapping(
|
||||
cmp.mapping.confirm {
|
||||
behavior = cmp.SelectBehavior.Insert,
|
||||
select = true,
|
||||
},
|
||||
{ 'i', 'c' }
|
||||
),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-c>'] = cmp.mapping.complete {
|
||||
config = {
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
},
|
||||
},
|
||||
},
|
||||
['<Up>'] = cmp.config.disable,
|
||||
['<Down>'] = cmp.config.disable,
|
||||
}
|
||||
|
||||
return {
|
||||
completion = {
|
||||
autocomplete = {
|
||||
cmp.TriggerEvent.TextChanged,
|
||||
cmp.TriggerEvent.InsertEnter,
|
||||
},
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.snippet.expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = mapping,
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
-- {
|
||||
-- name = 'nvim_lsp',
|
||||
-- entry_filter = function(entry, ctx)
|
||||
-- return require('cmp.types').lsp.CompletionItemKind[entry:get_kind()]
|
||||
-- ~= 'Snippet'
|
||||
-- end,
|
||||
-- },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'git' },
|
||||
}, {
|
||||
-- { name = 'spell' },
|
||||
{ name = 'buffer', keyword_length = 4 },
|
||||
{ name = 'path' },
|
||||
}),
|
||||
-- sorting = {
|
||||
-- comparators = {
|
||||
-- cmp.config.compare.offset,
|
||||
-- cmp.config.compare.exact,
|
||||
-- cmp.config.compare.score,
|
||||
-- -- function(entry1, entry2)
|
||||
-- -- local entry1_kind = require('cmp.types').lsp.CompletionItemKind[entry1:get_kind()]
|
||||
-- -- == 'Snippet'
|
||||
-- -- local entry2_kind = require('cmp.types').lsp.CompletionItemKind[entry2:get_kind()]
|
||||
-- -- == 'Snippet'
|
||||
-- -- print(entry1_kind)
|
||||
-- -- print(entry2_kind)
|
||||
-- -- -- if entry1_kind and not entry2_kind then
|
||||
-- -- -- return false
|
||||
-- -- -- else
|
||||
-- -- -- return true
|
||||
-- -- -- end
|
||||
-- -- return true
|
||||
-- -- end,
|
||||
-- -- cmp.config.compare.kind,
|
||||
-- cmp.config.compare.sort_text,
|
||||
-- cmp.config.compare.length,
|
||||
-- cmp.config.compare.order,
|
||||
-- },
|
||||
-- },
|
||||
-- formatting = {
|
||||
-- format = function(entry, vim_item)
|
||||
-- -- source name
|
||||
-- vim_item.menu = menu[entry.source.name]
|
||||
-- -- lsp kinds
|
||||
-- if vim_item.kind ~= nil then
|
||||
-- vim_item.kind = string.format(
|
||||
-- '%s [%s]',
|
||||
-- lsp.kinds[vim_item.kind],
|
||||
-- vim_item.kind:lower()
|
||||
-- )
|
||||
-- end
|
||||
-- -- shorten long items
|
||||
-- vim_item.abbr = vim_item.abbr:sub(1, 30)
|
||||
-- return vim_item
|
||||
-- end,
|
||||
-- },
|
||||
-- experimental = { ghost_text = true },
|
||||
}
|
||||
end,
|
||||
dependencies = {
|
||||
'saadparwaiz1/cmp_luasnip',
|
||||
'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/cmp-path',
|
||||
'f3fora/cmp-spell',
|
||||
{
|
||||
'petertriho/cmp-git',
|
||||
opts = {
|
||||
filetypes = {
|
||||
'gitcommit',
|
||||
'octo',
|
||||
'markdown', -- for gh & glab CLI
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
4
nvim/.config/nvim/lua/plugins/dressing.lua
Normal file
4
nvim/.config/nvim/lua/plugins/dressing.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
return {
|
||||
'stevearc/dressing.nvim',
|
||||
opts = {},
|
||||
}
|
||||
835
nvim/.config/nvim/lua/plugins/lsp.lua
Normal file
835
nvim/.config/nvim/lua/plugins/lsp.lua
Normal file
@@ -0,0 +1,835 @@
|
||||
local au = vim.api.nvim_create_augroup('LspAttach', { clear = true })
|
||||
|
||||
return {
|
||||
{
|
||||
'williamboman/mason.nvim',
|
||||
cmd = 'Mason',
|
||||
opts = {
|
||||
ensure_installed = {},
|
||||
registries = {
|
||||
'github:mason-org/mason-registry',
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require('mason').setup(opts)
|
||||
|
||||
local registry = require 'mason-registry'
|
||||
registry:on('package:install:success', function()
|
||||
vim.defer_fn(function()
|
||||
-- trigger FileType event to possibly load this newly installed LSP server
|
||||
require('lazy.core.handler.event').trigger {
|
||||
event = 'FileType',
|
||||
buf = vim.api.nvim_get_current_buf(),
|
||||
}
|
||||
end, 100)
|
||||
end)
|
||||
|
||||
local function ensure_installed()
|
||||
for _, tool in ipairs(opts.ensure_installed) do
|
||||
local package = registry.get_package(tool)
|
||||
if not package:is_installed() then
|
||||
package:install()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if registry.refresh then
|
||||
registry.refresh(ensure_installed)
|
||||
else
|
||||
ensure_installed()
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
'neovim/nvim-lspconfig',
|
||||
event = { 'BufReadPost', 'BufNewFile' },
|
||||
init = function()
|
||||
-- client log level
|
||||
vim.lsp.set_log_level(vim.lsp.log_levels.INFO)
|
||||
|
||||
vim.api.nvim_create_user_command('LspFormat', function()
|
||||
vim.lsp.buf.format { async = false }
|
||||
end, {})
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = au,
|
||||
desc = 'LSP tagfunc',
|
||||
callback = function(args)
|
||||
local bufnr = args.buf
|
||||
vim.api.nvim_set_option_value(
|
||||
'tagfunc',
|
||||
'v:lua.vim.lsp.tagfunc',
|
||||
{ buf = bufnr }
|
||||
)
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = au,
|
||||
desc = 'LSP keymaps',
|
||||
callback = function(args)
|
||||
local bufnr = args.buf
|
||||
local function map(mode, lhs, rhs)
|
||||
vim.keymap.set(mode, lhs, rhs, { buffer = bufnr })
|
||||
end
|
||||
|
||||
map('n', 'gD', vim.lsp.buf.declaration)
|
||||
map('n', 'gd', vim.lsp.buf.definition)
|
||||
map('n', 'K', vim.lsp.buf.hover)
|
||||
map('n', 'gi', vim.lsp.buf.implementation)
|
||||
-- map({ 'n', 'i' }, '<C-s>', vim.lsp.buf.signature_help)
|
||||
-- map('n', '<leader>wa', vim.lsp.buf.add_workspace_folder)
|
||||
-- map('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder)
|
||||
-- map('n', '<leader>wl', function()
|
||||
-- print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
-- end)
|
||||
map('n', '<leader>D', vim.lsp.buf.type_definition)
|
||||
-- map('n', '<leader>r', function()
|
||||
-- require('conf.nui_lsp').lsp_rename()
|
||||
-- end)
|
||||
map('n', 'gr', function()
|
||||
require('trouble').open { mode = 'lsp_references' }
|
||||
end)
|
||||
map('n', '<leader>li', vim.lsp.buf.incoming_calls)
|
||||
map('n', '<leader>lo', vim.lsp.buf.outgoing_calls)
|
||||
vim.opt.shortmess:append 'c'
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = au,
|
||||
desc = 'LSP highlight',
|
||||
callback = function(args)
|
||||
local bufnr = args.buf
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
if
|
||||
client
|
||||
and client.supports_method 'textDocument/documentHighlight'
|
||||
then
|
||||
local augroup_lsp_highlight = 'lsp_highlight'
|
||||
vim.api.nvim_create_augroup(
|
||||
augroup_lsp_highlight,
|
||||
{ clear = false }
|
||||
)
|
||||
vim.api.nvim_create_autocmd(
|
||||
{ 'CursorHold', 'CursorHoldI' },
|
||||
{
|
||||
group = augroup_lsp_highlight,
|
||||
buffer = bufnr,
|
||||
callback = vim.lsp.buf.document_highlight,
|
||||
}
|
||||
)
|
||||
vim.api.nvim_create_autocmd('CursorMoved', {
|
||||
group = augroup_lsp_highlight,
|
||||
buffer = bufnr,
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = au,
|
||||
desc = 'LSP inlay hints',
|
||||
callback = function(args)
|
||||
local bufnr = args.buf
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
if
|
||||
client
|
||||
and client.supports_method 'textDocument/inlayHint'
|
||||
and pcall(require, 'vim.lsp.inlay_hint') -- NOTE: check that API exists
|
||||
then
|
||||
-- vim.notify(
|
||||
-- 'register inlay hints',
|
||||
-- vim.lsp.log_levels.DEBUG
|
||||
-- )
|
||||
vim.api.nvim_create_autocmd({
|
||||
'BufWritePost',
|
||||
'BufEnter',
|
||||
'InsertLeave',
|
||||
'FocusGained',
|
||||
'CursorHold',
|
||||
}, {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.inlay_hint.enable(
|
||||
true,
|
||||
{ bufnr = bufnr }
|
||||
)
|
||||
end,
|
||||
})
|
||||
vim.api.nvim_create_autocmd('InsertEnter', {
|
||||
callback = function()
|
||||
vim.lsp.inlay_hint.enable(
|
||||
false,
|
||||
{ bufnr = bufnr }
|
||||
)
|
||||
end,
|
||||
})
|
||||
-- initial request
|
||||
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = au,
|
||||
desc = 'LSP code actions',
|
||||
callback = function(args)
|
||||
local bufnr = args.buf
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
if
|
||||
client
|
||||
and client.supports_method 'textDocument/codeAction'
|
||||
then
|
||||
vim.keymap.set(
|
||||
{ 'n', 'v' },
|
||||
'<leader>ca',
|
||||
vim.lsp.buf.code_action,
|
||||
{ buffer = bufnr }
|
||||
)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = au,
|
||||
desc = 'LSP notify',
|
||||
callback = function(args)
|
||||
-- local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
-- if client then
|
||||
-- vim.notify(
|
||||
-- ('%s attached to buffer %s'):format(
|
||||
-- client.name,
|
||||
-- args.buf
|
||||
-- ),
|
||||
-- vim.log.levels.DEBUG
|
||||
-- )
|
||||
-- end
|
||||
end,
|
||||
})
|
||||
|
||||
-- local function periodic_refresh_semantic_tokens()
|
||||
-- -- vim.notify(
|
||||
-- -- 'periodic refresh semantic tokens',
|
||||
-- -- vim.log.levels.DEBUG
|
||||
-- -- )
|
||||
-- vim.lsp.semantic_tokens.force_refresh()
|
||||
-- vim.defer_fn(periodic_refresh_semantic_tokens, 30000)
|
||||
-- end
|
||||
|
||||
-- local function debounce(ms, fn)
|
||||
-- local timer = assert(vim.uv.new_timer())
|
||||
-- return function(...)
|
||||
-- local argv = { ... }
|
||||
-- timer:start(ms, 0, function()
|
||||
-- timer:stop()
|
||||
-- vim.schedule_wrap(fn)(unpack(argv))
|
||||
-- end)
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- vim.api.nvim_create_autocmd({ 'TextChanged', 'InsertLeave' }, {
|
||||
-- callback = debounce(1000, function()
|
||||
-- -- vim.notify('refresh semantic tokens', vim.log.levels.DEBUG)
|
||||
-- vim.lsp.semantic_tokens.force_refresh()
|
||||
-- end),
|
||||
-- })
|
||||
end,
|
||||
dependencies = {
|
||||
{
|
||||
'folke/neoconf.nvim',
|
||||
cmd = 'Neoconf',
|
||||
config = false,
|
||||
dependencies = { 'nvim-lspconfig' },
|
||||
},
|
||||
{ 'folke/neodev.nvim', opts = {} },
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'mason.nvim',
|
||||
{
|
||||
'williamboman/mason-lspconfig.nvim',
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
'lua_ls',
|
||||
-- 'ruby-lsp ',
|
||||
-- 'pylyzer',
|
||||
-- 'rust_analyzer',
|
||||
'dockerls',
|
||||
'docker_compose_language_service',
|
||||
'yamlls',
|
||||
'jsonls',
|
||||
'html',
|
||||
'cssls',
|
||||
'gopls',
|
||||
'clangd',
|
||||
'texlab',
|
||||
'vtsls',
|
||||
-- 'denols',
|
||||
-- 'eslint',
|
||||
-- 'vale_ls',
|
||||
'terraformls',
|
||||
'helm_ls',
|
||||
'bashls'
|
||||
},
|
||||
handlers = {
|
||||
function(server_name)
|
||||
-- vim.notify(
|
||||
-- 'Mason LSP setup ' .. server_name,
|
||||
-- vim.log.levels.DEBUG
|
||||
-- )
|
||||
require('lspconfig')[server_name].setup {}
|
||||
end,
|
||||
['yamlls'] = function()
|
||||
require('lspconfig').yamlls.setup {
|
||||
single_file_support = true,
|
||||
filetypes = {
|
||||
'yaml',
|
||||
'yaml.gha',
|
||||
},
|
||||
root_dir = function(filename)
|
||||
return require('lspconfig.util').find_git_ancestor(
|
||||
filename
|
||||
) or vim.uv.cwd()
|
||||
end,
|
||||
settings = {
|
||||
yaml = {
|
||||
editor = { formatOnType = true },
|
||||
schemas = {
|
||||
-- GitHub CI workflows
|
||||
['https://json.schemastore.org/github-workflow.json'] = '/.github/workflows/*',
|
||||
-- Helm charts
|
||||
['https://json.schemastore.org/chart.json'] = '/templates/*',
|
||||
},
|
||||
customTags = {
|
||||
-- mkdocs
|
||||
'tag:yaml.org,2002:python/name:material.extensions.emoji.twemoji',
|
||||
'tag:yaml.org,2002:python/name:material.extensions.emoji.to_svg',
|
||||
'tag:yaml.org,2002:python/name:pymdownx.superfences.fence_code_format',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
require('lspconfig').yamlls.setup {
|
||||
name = 'yamlls GitLab',
|
||||
filetypes = { 'yaml.gitlab' },
|
||||
settings = {
|
||||
yaml = {
|
||||
customTags = {
|
||||
'!reference sequence',
|
||||
'!reference scalar',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
-- ['pylyzer'] = function() end, -- disable
|
||||
-- ['vale_ls'] = function() end, -- disable
|
||||
-- ['rust_analyzer'] = function() end, -- use rustaceanvim instead
|
||||
['dockerls'] = function()
|
||||
require('lspconfig').dockerls.setup {
|
||||
settings = {
|
||||
docker = {
|
||||
languageserver = {
|
||||
formatter = {
|
||||
ignoreMultilineInstructions = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
['jsonls'] = function()
|
||||
require('lspconfig').jsonls.setup {
|
||||
filetypes = { 'json', 'jsonc' },
|
||||
settings = {
|
||||
json = {
|
||||
schemas = {
|
||||
{
|
||||
fileMatch = { 'package.json' },
|
||||
url = 'https://json.schemastore.org/package.json',
|
||||
},
|
||||
{
|
||||
fileMatch = { 'tsconfig*.json' },
|
||||
url = 'https://json.schemastore.org/tsconfig.json',
|
||||
},
|
||||
{
|
||||
fileMatch = {
|
||||
'.prettierrc',
|
||||
'.prettierrc.json',
|
||||
'prettier.config.json',
|
||||
},
|
||||
url = 'https://json.schemastore.org/prettierrc.json',
|
||||
},
|
||||
{
|
||||
fileMatch = {
|
||||
'.eslintrc',
|
||||
'.eslintrc.json',
|
||||
},
|
||||
url = 'https://json.schemastore.org/eslintrc.json',
|
||||
},
|
||||
{
|
||||
fileMatch = {
|
||||
'.stylelintrc',
|
||||
'.stylelintrc.json',
|
||||
'stylelint.config.json',
|
||||
},
|
||||
url = 'http://json.schemastore.org/stylelintrc.json',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
['html'] = function()
|
||||
require('lspconfig').html.setup {
|
||||
settings = {
|
||||
html = {
|
||||
format = {
|
||||
templating = true,
|
||||
wrapLineLength = 120,
|
||||
wrapAttributes = 'auto',
|
||||
},
|
||||
hover = {
|
||||
documentation = true,
|
||||
references = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
['tsserver'] = function()
|
||||
require('lspconfig').tsserver.setup {
|
||||
autostart = false,
|
||||
root_dir = require('lspconfig.util').root_pattern 'package.json',
|
||||
commands = {
|
||||
OrganizeImports = {
|
||||
function()
|
||||
local params = {
|
||||
command = '_typescript.organizeImports',
|
||||
arguments = {
|
||||
vim.api.nvim_buf_get_name(
|
||||
0
|
||||
),
|
||||
},
|
||||
title = '',
|
||||
}
|
||||
vim.lsp.buf.execute_command(params)
|
||||
end,
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
['lua_ls'] = function()
|
||||
require('lspconfig').lua_ls.setup {
|
||||
settings = {
|
||||
Lua = {
|
||||
completion = {
|
||||
callSnippet = 'Replace',
|
||||
},
|
||||
workspace = { checkThirdParty = false },
|
||||
telemetry = { enable = false },
|
||||
diagnostics = {
|
||||
unusedLocalExclude = { '_*' },
|
||||
},
|
||||
format = { enable = false },
|
||||
hint = {
|
||||
enable = true,
|
||||
arrayIndex = 'Disable',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
-- ['denols'] = function()
|
||||
-- require('lspconfig').denols.setup {
|
||||
-- autostart = false,
|
||||
-- root_dir = require('lspconfig.util').root_pattern(
|
||||
-- 'deno.json',
|
||||
-- 'deno.jsonc'
|
||||
-- ),
|
||||
-- filetypes = {
|
||||
-- 'javascript',
|
||||
-- 'javascriptreact',
|
||||
-- 'javascript.jsx',
|
||||
-- 'typescript',
|
||||
-- 'typescriptreact',
|
||||
-- 'typescript.tsx',
|
||||
-- 'yaml',
|
||||
-- 'json',
|
||||
-- 'markdown',
|
||||
-- 'html',
|
||||
-- 'css',
|
||||
-- },
|
||||
-- init_options = {
|
||||
-- enable = true,
|
||||
-- lint = true,
|
||||
-- unstable = true,
|
||||
-- importMap = './import_map.json',
|
||||
-- },
|
||||
-- single_file_support = false,
|
||||
-- }
|
||||
-- end,
|
||||
['texlab'] = function()
|
||||
require('lspconfig').texlab.setup {
|
||||
settings = {
|
||||
texlab = {
|
||||
auxDirectory = '.',
|
||||
bibtexFormatter = 'texlab',
|
||||
build = {
|
||||
args = {
|
||||
'-pdflua',
|
||||
'-shell-escape',
|
||||
'-interaction=nonstopmode',
|
||||
'-synctex=1',
|
||||
'-pv',
|
||||
'%f',
|
||||
},
|
||||
executable = 'latexmk',
|
||||
forwardSearchAfter = false,
|
||||
onSave = false,
|
||||
},
|
||||
chktex = {
|
||||
onEdit = false,
|
||||
onOpenAndSave = false,
|
||||
},
|
||||
diagnosticsDelay = 300,
|
||||
formatterLineLength = 80,
|
||||
forwardSearch = {
|
||||
args = {},
|
||||
},
|
||||
latexFormatter = 'latexindent',
|
||||
latexindent = {
|
||||
modifyLineBreaks = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
'antosha417/nvim-lsp-file-operations',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
'nvim-tree/nvim-tree.lua',
|
||||
},
|
||||
opts = {},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
'zbirenbaum/neodim',
|
||||
event = { 'BufReadPost', 'BufNewFile' },
|
||||
opts = {
|
||||
alpha = 0.70,
|
||||
blend_color = '#000000',
|
||||
update_in_insert = {
|
||||
enable = false,
|
||||
delay = 100,
|
||||
},
|
||||
hide = {
|
||||
virtual_text = false,
|
||||
signs = false,
|
||||
underline = true,
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = au,
|
||||
desc = 'LSP dim unused',
|
||||
callback = function()
|
||||
require('neodim').setup(opts)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
'stevearc/conform.nvim',
|
||||
event = { 'BufWritePre' },
|
||||
dependencies = {
|
||||
{
|
||||
'williamboman/mason.nvim',
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = opts.ensure_installed or {}
|
||||
vim.list_extend(opts.ensure_installed, {
|
||||
'stylua',
|
||||
'ruff',
|
||||
-- 'dprint',
|
||||
'isort',
|
||||
'black',
|
||||
'prettierd',
|
||||
'shfmt',
|
||||
})
|
||||
end,
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
formatters_by_ft = {
|
||||
lua = { 'stylua' },
|
||||
python = function(bufnr)
|
||||
if
|
||||
require('conform').get_formatter_info(
|
||||
'ruff_format',
|
||||
bufnr
|
||||
).available
|
||||
then
|
||||
return { 'ruff_fix', 'ruff_format' }
|
||||
else
|
||||
return { 'isort', 'black' }
|
||||
end
|
||||
end,
|
||||
json = { 'dprint' },
|
||||
jsonc = { 'dprint' },
|
||||
markdown = { 'dprint', 'injected' },
|
||||
-- javascript = { 'dprint' },
|
||||
-- javascriptreact = { 'dprint' },
|
||||
-- typescript = { 'dprint' },
|
||||
-- typescriptreact = { 'dprint' },
|
||||
toml = { 'dprint' },
|
||||
dockerfile = { 'dprint' },
|
||||
css = { 'dprint' },
|
||||
html = { 'dprint' },
|
||||
htmldjango = { 'dprint' },
|
||||
yaml = { 'dprint' },
|
||||
graphql = { { 'prettierd', 'prettier' } },
|
||||
sh = { 'shfmt' },
|
||||
http = {
|
||||
'injected',
|
||||
-- 'trim_newlines', -- FIXME: breaks injected
|
||||
'trim_whitespace',
|
||||
},
|
||||
['_'] = { 'trim_newlines', 'trim_whitespace' },
|
||||
},
|
||||
format_on_save = function(bufnr)
|
||||
-- Disable with a global or buffer-local variable
|
||||
if
|
||||
vim.g.disable_autoformat
|
||||
or vim.b[bufnr].disable_autoformat
|
||||
then
|
||||
return
|
||||
end
|
||||
return {
|
||||
timeout_ms = 5000, -- HACK: high because dprint needs to download WASM plugins on first run
|
||||
lsp_fallback = true,
|
||||
}
|
||||
end,
|
||||
log_level = vim.log.levels.TRACE,
|
||||
},
|
||||
init = function()
|
||||
vim.api.nvim_create_user_command('Format', function()
|
||||
require('conform').format()
|
||||
end, { desc = 'Format buffer using conform' })
|
||||
|
||||
vim.api.nvim_create_user_command('FormatDisable', function(args)
|
||||
if args.bang then
|
||||
-- FormatDisable! will disable formatting just for this buffer
|
||||
---@diagnostic disable-next-line: inject-field
|
||||
vim.b.disable_autoformat = true
|
||||
else
|
||||
vim.g.disable_autoformat = true
|
||||
end
|
||||
end, {
|
||||
desc = 'Disable autoformat-on-save',
|
||||
bang = true,
|
||||
})
|
||||
vim.api.nvim_create_user_command('FormatEnable', function()
|
||||
---@diagnostic disable-next-line: inject-field
|
||||
vim.b.disable_autoformat = false
|
||||
vim.g.disable_autoformat = false
|
||||
end, {
|
||||
desc = 'Re-enable autoformat-on-save',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = au,
|
||||
desc = 'LSP formatexpr',
|
||||
callback = function(args)
|
||||
local bufnr = args.buf
|
||||
vim.api.nvim_set_option_value(
|
||||
'formatexpr',
|
||||
'v:lua.require\'conform\'.formatexpr()',
|
||||
{ buf = bufnr }
|
||||
)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
config = function(_, opts)
|
||||
local conform = require 'conform'
|
||||
conform.setup(opts)
|
||||
|
||||
conform.formatters.stylua = {
|
||||
require_cwd = true,
|
||||
}
|
||||
-- conform.formatters.ruff_fix = {
|
||||
-- prepend_args = { '--respect-gitignore' },
|
||||
-- }
|
||||
-- conform.formatters.ruff_format = {
|
||||
-- prepend_args = { '--silent', '--respect-gitignore' },
|
||||
-- }
|
||||
conform.formatters.shfmt = {
|
||||
prepend_args = { '-i', '4', '-ci' },
|
||||
}
|
||||
conform.formatters.dprint = {
|
||||
prepend_args = function(self, ctx)
|
||||
if not self:cwd(ctx) then
|
||||
vim.notify 'falling back to global dprint config'
|
||||
return {
|
||||
'--config',
|
||||
vim.fn.expand '~/.config/dprint.jsonc',
|
||||
}
|
||||
end
|
||||
end,
|
||||
}
|
||||
conform.formatters.dprint_injected = vim.tbl_deep_extend(
|
||||
'force',
|
||||
require 'conform.formatters.dprint',
|
||||
conform.formatters.dprint,
|
||||
{
|
||||
args = function(self, ctx)
|
||||
local extension = vim.fn.fnamemodify(ctx.filename, ':e')
|
||||
local ret = vim.list_extend(
|
||||
{ 'fmt', '--stdin', extension },
|
||||
self:prepend_args(ctx)
|
||||
)
|
||||
return ret
|
||||
end,
|
||||
}
|
||||
)
|
||||
conform.formatters.injected = {
|
||||
options = {
|
||||
ignore_errors = false,
|
||||
lang_to_formatters = {
|
||||
json = { 'dprint_injected' },
|
||||
python = { 'black' }, -- FIXME: ruff_format deletes content
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- TODO: custom formatters
|
||||
conform.formatters.blackd = {
|
||||
command = 'blackd-client',
|
||||
}
|
||||
end,
|
||||
},
|
||||
{
|
||||
'joechrisellis/lsp-format-modifications.nvim',
|
||||
lazy = true,
|
||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
||||
init = function()
|
||||
vim.api.nvim_create_user_command('FormatModified', function()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local clients = vim.lsp.get_clients {
|
||||
bufnr = bufnr,
|
||||
method = require('vim.lsp.protocol').Methods.textDocument_rangeFormatting,
|
||||
}
|
||||
|
||||
if #clients == 0 then
|
||||
vim.notify '[LSP] Format request failed, no matching language servers.'
|
||||
end
|
||||
|
||||
for _, client in pairs(clients) do
|
||||
require('lsp-format-modifications').format_modifications(
|
||||
client,
|
||||
bufnr
|
||||
)
|
||||
end
|
||||
end, {})
|
||||
end,
|
||||
},
|
||||
{
|
||||
'mrcjkb/rustaceanvim',
|
||||
ft = 'rust',
|
||||
opts = function()
|
||||
vim.g.rustaceanvim = {
|
||||
server = {
|
||||
cmd = function()
|
||||
local mason_registry = require 'mason-registry'
|
||||
local ra_binary = mason_registry.is_installed 'rust-analyzer'
|
||||
and mason_registry
|
||||
.get_package('rust-analyzer')
|
||||
:get_install_path() .. '/rust-analyzer'
|
||||
or 'rust-analyzer'
|
||||
return { ra_binary }
|
||||
end,
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
{
|
||||
'folke/trouble.nvim',
|
||||
cmd = 'Trouble',
|
||||
keys = {
|
||||
{
|
||||
'<leader>xx',
|
||||
function()
|
||||
require('trouble').toggle()
|
||||
end,
|
||||
},
|
||||
{
|
||||
'<leader>xw',
|
||||
function()
|
||||
require('trouble').toggle { mode = 'diagnostics' }
|
||||
end,
|
||||
},
|
||||
{
|
||||
'<leader>xb',
|
||||
function()
|
||||
require('trouble').toggle {
|
||||
mode = 'diagnostics',
|
||||
filter = { buf = 0 },
|
||||
}
|
||||
end,
|
||||
},
|
||||
{
|
||||
'<leader>xq',
|
||||
function()
|
||||
require('trouble').toggle { mode = 'quickfix' }
|
||||
end,
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
fold_open = '', -- ▾
|
||||
fold_closed = '', -- ▸
|
||||
indent_lines = false,
|
||||
padding = false,
|
||||
signs = {
|
||||
error = '',
|
||||
warning = '',
|
||||
hint = '',
|
||||
information = '',
|
||||
other = '', --
|
||||
},
|
||||
action_keys = { jump = { '<cr>' }, toggle_fold = { '<tab>' } },
|
||||
},
|
||||
config = function(_, opts)
|
||||
require('trouble').setup(opts)
|
||||
vim.api.nvim_set_hl(0, 'TroubleText', { link = 'CursorLineNr' })
|
||||
|
||||
vim.api.nvim_create_autocmd('QuitPre', {
|
||||
callback = function()
|
||||
local invalid_wins = {}
|
||||
local wins = vim.api.nvim_list_wins()
|
||||
for _, w in ipairs(wins) do
|
||||
local bufname = vim.api.nvim_buf_get_name(
|
||||
vim.api.nvim_win_get_buf(w)
|
||||
)
|
||||
if
|
||||
bufname:match 'Trouble' ~= nil
|
||||
or vim.api.nvim_win_get_config(w).relative ~= '' -- floating window
|
||||
then
|
||||
table.insert(invalid_wins, w)
|
||||
end
|
||||
end
|
||||
if #invalid_wins == #wins - 1 then
|
||||
-- Should quit, so we close all invalid windows.
|
||||
for _, w in ipairs(invalid_wins) do
|
||||
vim.api.nvim_win_close(w, true)
|
||||
end
|
||||
end
|
||||
end,
|
||||
desc = 'Close Trouble if last window',
|
||||
})
|
||||
end,
|
||||
}
|
||||
}
|
||||
16
nvim/.config/nvim/lua/plugins/nord.lua
Normal file
16
nvim/.config/nvim/lua/plugins/nord.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
return {
|
||||
'gbprod/nord.nvim', name = 'nord',
|
||||
lazy = false,
|
||||
priority = 1000,
|
||||
config = function()
|
||||
vim.g.nord_contrast = true
|
||||
vim.g.nord_borders = true
|
||||
vim.g.nord_disable_background = false
|
||||
vim.g.nord_cursorline_transparent = false
|
||||
vim.g.nord_enable_sidebar_background = false
|
||||
vim.g.nord_italic = true
|
||||
vim.g.nord_uniform_diff_background = true
|
||||
vim.g.nord_bold = false
|
||||
vim.cmd [[colorscheme nord]]
|
||||
end
|
||||
}
|
||||
33
nvim/.config/nvim/lua/plugins/oil.lua
Normal file
33
nvim/.config/nvim/lua/plugins/oil.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
return {
|
||||
"stevearc/oil.nvim",
|
||||
config = function()
|
||||
require("oil").setup({
|
||||
-- prompt_save_on_select_new_entry = true,
|
||||
skip_confirm_for_simple_edits = true,
|
||||
default_file_explorer = false, -- so `gx` and `:GBrowse` works
|
||||
use_default_keymap = false,
|
||||
keymaps = {
|
||||
["g?"] = "actions.show_help",
|
||||
["<CR>"] = "actions.select",
|
||||
["<C-s>"] = "actions.select_vsplit",
|
||||
["<C-h>"] = false,
|
||||
["<C-t>"] = "actions.select_tab",
|
||||
["<C-p>"] = "actions.preview",
|
||||
["<C-c>"] = "actions.close",
|
||||
["<C-l>"] = false,
|
||||
["-"] = "actions.parent",
|
||||
["_"] = "actions.open_cwd",
|
||||
["`"] = "actions.cd",
|
||||
["~"] = "actions.tcd",
|
||||
["gs"] = "actions.change_sort",
|
||||
["gx"] = false,
|
||||
["g."] = "actions.toggle_hidden",
|
||||
["g\\"] = "actions.toggle_trash",
|
||||
},
|
||||
view_options = {
|
||||
-- Show files and directories that start with "."
|
||||
show_hidden = false,
|
||||
}
|
||||
})
|
||||
end
|
||||
}
|
||||
7
nvim/.config/nvim/lua/plugins/telescope.lua
Normal file
7
nvim/.config/nvim/lua/plugins/telescope.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
return {
|
||||
'nvim-telescope/telescope.nvim', tag = '0.1.8',
|
||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
||||
config = function()
|
||||
require('telescope').setup()
|
||||
end
|
||||
}
|
||||
1
nvim/.config/nvim/lua/plugins/tmux-navigator.lua
Normal file
1
nvim/.config/nvim/lua/plugins/tmux-navigator.lua
Normal file
@@ -0,0 +1 @@
|
||||
return { 'christoomey/vim-tmux-navigator' }
|
||||
60
nvim/.config/nvim/lua/plugins/treesitter.lua
Normal file
60
nvim/.config/nvim/lua/plugins/treesitter.lua
Normal file
@@ -0,0 +1,60 @@
|
||||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
build = ":TSUpdate",
|
||||
config = function ()
|
||||
require('nvim-treesitter.configs').setup {
|
||||
-- one of "all", "maintained" (parsers with maintainers), or a list of languages
|
||||
ensure_installed = { 'bash', 'c', 'cpp', 'c_sharp', 'clojure', 'cmake', 'comment', 'commonlisp',
|
||||
'css', 'dockerfile', 'elixir', 'erlang', 'fish', 'go', 'html', 'http', 'java',
|
||||
'javascript', 'json', 'kotlin', 'latex', 'lua', 'make', 'markdown', 'perl', 'php',
|
||||
'python', 'ruby', 'rust', 'scss', 'swift', 'toml', 'tsx', 'vim', 'vue', 'yaml' },
|
||||
-- ignore_install = { 'norg' },
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
context_commentstring = {
|
||||
enable = true,
|
||||
enable_autocmd = false,
|
||||
},
|
||||
rainbow = {
|
||||
enable = true,
|
||||
disable = { "html" },
|
||||
extended_mode = false,
|
||||
max_file_lines = nil,
|
||||
},
|
||||
indent = { enable = false },
|
||||
autopairs = { enable = true },
|
||||
autotag = { enable = true },
|
||||
incremental_selection = { enable = true },
|
||||
textobjects = { -- syntax-aware textobjects
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
|
||||
disable = {},
|
||||
keymaps = {
|
||||
-- You can use the capture groups defined in textobjects.scm
|
||||
['af'] = '@function.outer',
|
||||
['if'] = '@function.inner',
|
||||
['aC'] = '@class.outer',
|
||||
['iC'] = '@class.inner',
|
||||
['ac'] = '@conditional.outer',
|
||||
['ic'] = '@conditional.inner',
|
||||
['ab'] = '@block.outer',
|
||||
['ib'] = '@block.inner',
|
||||
['al'] = '@loop.outer',
|
||||
['il'] = '@loop.inner',
|
||||
['is'] = '@statement.inner',
|
||||
['as'] = '@statement.outer',
|
||||
['am'] = '@call.outer',
|
||||
['im'] = '@call.inner',
|
||||
['ad'] = '@comment.outer',
|
||||
['id'] = '@comment.inner',
|
||||
['aa'] = '@parameter.outer',
|
||||
['ia'] = '@parameter.inner',
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
-- Author: Konstantin Bukley <madundead@gmail.com>
|
||||
-- License: WTFPL
|
||||
-- Description: Personal neovim configuration
|
||||
|
||||
vim.loader.enable()
|
||||
|
||||
require('filetypes')
|
||||
require('builtins')
|
||||
require('plugins')
|
||||
require('util')
|
||||
require('settings')
|
||||
require('mappings')
|
||||
@@ -1,19 +0,0 @@
|
||||
local cmp = require('cmp')
|
||||
local cmp_action = require('lsp-zero').cmp_action()
|
||||
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
|
||||
cmp.setup({
|
||||
sources = {
|
||||
{name = 'path'},
|
||||
{name = 'nvim_lsp'},
|
||||
{name = 'buffer', keyword_length = 3},
|
||||
{name = 'luasnip', keyword_length = 2},
|
||||
},
|
||||
mapping = {
|
||||
-- `Enter` key to confirm completion
|
||||
['<CR>'] = cmp.mapping.confirm({select = false}),
|
||||
['<Tab>'] = cmp_action.luasnip_supertab(),
|
||||
['<S-Tab>'] = cmp_action.luasnip_shift_supertab(),
|
||||
}
|
||||
})
|
||||
@@ -1 +0,0 @@
|
||||
require('Comment').setup()
|
||||
@@ -1 +0,0 @@
|
||||
require('gitsigns').setup()
|
||||
@@ -1,153 +0,0 @@
|
||||
local cmd, fn, opt, g = vim.cmd, vim.fn, vim.opt, vim.g
|
||||
|
||||
vim.loader.enable()
|
||||
|
||||
cmd [[packadd packer.nvim]]
|
||||
local packer = require('packer')
|
||||
local use = packer.use
|
||||
|
||||
-- NB: Difference between config and setup (https://github.com/wbthomason/packer.nvim#specifying-plugins)
|
||||
--
|
||||
-- `config` - Specifies code to run after this plugin is loaded.
|
||||
--
|
||||
-- The setup key implies opt = true
|
||||
-- `setup` - Specifies code to run before this plugin is loaded. The code is ran even if
|
||||
-- the plugin is waiting for other conditions (ft, cond...) to be met.
|
||||
|
||||
packer.startup(function()
|
||||
use { 'wbthomason/packer.nvim', opt = true }
|
||||
|
||||
use {
|
||||
'shaunsingh/nord.nvim',
|
||||
config = function()
|
||||
require('plugins.nord').config()
|
||||
end,
|
||||
setup = function()
|
||||
require('plugins.nord').setup()
|
||||
end
|
||||
}
|
||||
|
||||
use {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
run = ':TSUpdate',
|
||||
event = { 'BufRead', 'BufNewFile' },
|
||||
config = function()
|
||||
require('plugins/treesitter').config()
|
||||
end,
|
||||
requires = {
|
||||
{
|
||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||
after = 'nvim-treesitter'
|
||||
},
|
||||
{
|
||||
'nvim-treesitter/playground',
|
||||
cmd = 'TSPlaygroundToggle',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use { 'nvim-tree/nvim-tree.lua',
|
||||
config = function()
|
||||
require('plugins/nvim-tree').config()
|
||||
end,
|
||||
opt = true,
|
||||
cmd = { 'NvimTreeToggle', 'NvimTreeFindFile' }
|
||||
}
|
||||
|
||||
use 'numtostr/comment.nvim'
|
||||
|
||||
use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', cond = fn.executable "make" == 1 }
|
||||
use { 'nvim-telescope/telescope.nvim',
|
||||
module = 'telescope',
|
||||
requires = { 'nvim-lua/plenary.nvim' },
|
||||
config = function()
|
||||
require('plugins/telescope').config()
|
||||
end,
|
||||
setup = function()
|
||||
require('plugins/telescope').setup()
|
||||
end
|
||||
}
|
||||
|
||||
-- Vimscript
|
||||
use { 'junegunn/vim-easy-align',
|
||||
-- opt = false,
|
||||
-- event = { 'BufRead', 'BufNewFile' },
|
||||
-- cmd = { 'EasyAlign' }
|
||||
}
|
||||
|
||||
use 'christoomey/vim-tmux-navigator'
|
||||
use 'lewis6991/gitsigns.nvim'
|
||||
|
||||
-- tpope
|
||||
use 'tpope/vim-surround'
|
||||
use 'tpope/vim-fugitive'
|
||||
use 'tpope/vim-rails'
|
||||
use 'tpope/vim-rhubarb'
|
||||
use 'tpope/vim-repeat'
|
||||
|
||||
-- TODO: find lua replacement / or learn :grep / cfdo
|
||||
use 'dyng/ctrlsf.vim'
|
||||
|
||||
use 'andrewradev/splitjoin.vim'
|
||||
|
||||
use 'ggandor/leap.nvim'
|
||||
|
||||
use {
|
||||
'VonHeikemen/lsp-zero.nvim',
|
||||
branch = 'v3.x',
|
||||
requires = {
|
||||
-- LSP Support
|
||||
{'neovim/nvim-lspconfig'}, -- Required
|
||||
{ -- Optional
|
||||
'williamboman/mason.nvim',
|
||||
run = function()
|
||||
pcall(vim.cmd, 'MasonUpdate')
|
||||
end,
|
||||
},
|
||||
{'williamboman/mason-lspconfig.nvim'}, -- Optional
|
||||
|
||||
-- Autocompletion
|
||||
{'hrsh7th/nvim-cmp'}, -- Required
|
||||
{'hrsh7th/cmp-nvim-lsp'}, -- Required
|
||||
{'hrsh7th/cmp-buffer'}, -- Optional
|
||||
{'hrsh7th/cmp-path'}, -- Optional
|
||||
{'saadparwaiz1/cmp_luasnip'}, -- Optional
|
||||
{'hrsh7th/cmp-nvim-lua'}, -- Optional
|
||||
|
||||
-- Snippets
|
||||
{'L3MON4D3/LuaSnip'}, -- Required
|
||||
{'rafamadriz/friendly-snippets'}, -- Optional
|
||||
}
|
||||
}
|
||||
|
||||
use { "dstein64/vim-startuptime", cmd = "StartupTime" }
|
||||
|
||||
-- EXPERIMENTAL: trying out different plugins
|
||||
use { 'skywind3000/asyncrun.vim' }
|
||||
|
||||
use { 'kevinhwang91/nvim-bqf', ft = 'qf' }
|
||||
use { 'kevinhwang91/nvim-pqf', ft = 'qf' }
|
||||
use { 'weilbith/vim-qfloc-edit', ft = 'qf' }
|
||||
|
||||
use({
|
||||
"stevearc/oil.nvim",
|
||||
config = function()
|
||||
require("oil").setup({
|
||||
-- skip_confirm_for_simple_edits = true,
|
||||
-- prompt_save_on_select_new_entry = true,
|
||||
default_file_explorer = true,
|
||||
|
||||
view_options = {
|
||||
-- Show files and directories that start with "."
|
||||
show_hidden = false,
|
||||
}
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
end)
|
||||
|
||||
require('plugins.lsp')
|
||||
require('plugins.cmp')
|
||||
require('plugins.comment')
|
||||
require('plugins.gitsigns')
|
||||
@@ -1,88 +0,0 @@
|
||||
local lsp_zero = require('lsp-zero')
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
lsp_zero.on_attach(function(client, bufnr)
|
||||
-- see :help lsp-zero-keybindings
|
||||
-- to learn the available actions
|
||||
lsp_zero.default_keymaps({buffer = bufnr})
|
||||
end)
|
||||
|
||||
require('mason').setup({})
|
||||
require('mason-lspconfig').setup({
|
||||
ensure_installed = { 'ruby_ls' },
|
||||
handlers = { lsp_zero.default_setup },
|
||||
})
|
||||
|
||||
-- lspconfig.solargraph.setup({
|
||||
-- -- there's a very weird problem with mason-provided solargraph
|
||||
-- -- so instead I'm using the one from asdf
|
||||
-- cmd = { os.getenv( "HOME" ) .. "/.asdf/shims/solargraph", 'stdio' },
|
||||
-- settings = {
|
||||
-- solargraph = {
|
||||
-- autoformat = true,
|
||||
-- completion = true,
|
||||
-- diagnostic = true,
|
||||
-- folding = true,
|
||||
-- references = true,
|
||||
-- rename = true,
|
||||
-- symbols = true
|
||||
-- }
|
||||
-- }
|
||||
-- })
|
||||
|
||||
lspconfig.lua_ls.setup(lsp_zero.nvim_lua_ls())
|
||||
|
||||
-- See https://github.com/Shopify/ruby-lsp/blob/main/EDITORS.md#neovim-lsp
|
||||
-- textDocument/diagnostic support until 0.10.0 is released
|
||||
-- IMPORTANT: look into how much resources ruby-lsp consumes
|
||||
local _timers = {}
|
||||
local function setup_diagnostics(client, buffer)
|
||||
if require("vim.lsp.diagnostic")._enable then
|
||||
return
|
||||
end
|
||||
|
||||
local diagnostic_handler = function()
|
||||
local params = vim.lsp.util.make_text_document_params(buffer)
|
||||
client.request("textDocument/diagnostic", { textDocument = params }, function(err, result)
|
||||
if err then
|
||||
local err_msg = string.format("diagnostics error - %s", vim.inspect(err))
|
||||
vim.lsp.log.error(err_msg)
|
||||
end
|
||||
if not result then
|
||||
return
|
||||
end
|
||||
vim.lsp.diagnostic.on_publish_diagnostics(
|
||||
nil,
|
||||
vim.tbl_extend("keep", params, { diagnostics = result.items }),
|
||||
{ client_id = client.id }
|
||||
)
|
||||
end)
|
||||
end
|
||||
|
||||
diagnostic_handler() -- to request diagnostics on buffer when first attaching
|
||||
|
||||
vim.api.nvim_buf_attach(buffer, false, {
|
||||
on_lines = function()
|
||||
if _timers[buffer] then
|
||||
vim.fn.timer_stop(_timers[buffer])
|
||||
end
|
||||
_timers[buffer] = vim.fn.timer_start(200, diagnostic_handler)
|
||||
end,
|
||||
on_detach = function()
|
||||
if _timers[buffer] then
|
||||
vim.fn.timer_stop(_timers[buffer])
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- trying out ruby-lsp from Shopify
|
||||
-- maybe will replace solargraph
|
||||
lspconfig.ruby_ls.setup({
|
||||
cmd = { os.getenv( "HOME" ) .. "/.asdf/shims/ruby-lsp", 'stdio' },
|
||||
on_attach = function(client, buffer)
|
||||
setup_diagnostics(client, buffer)
|
||||
end,
|
||||
})
|
||||
|
||||
lsp_zero.setup()
|
||||
@@ -1,57 +0,0 @@
|
||||
-- TODO: figure out how to simplify the snippets config
|
||||
-- TODO: figure out how to create custom snippets
|
||||
-- TODO: is it possible to use luasnip without nvim-cpm?
|
||||
|
||||
local function prequire(...)
|
||||
local status, lib = pcall(require, ...)
|
||||
if (status) then return lib end
|
||||
return nil
|
||||
end
|
||||
|
||||
local luasnip = prequire('luasnip')
|
||||
local cmp = prequire("cmp")
|
||||
|
||||
local t = function(str)
|
||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||
end
|
||||
|
||||
local check_back_space = function()
|
||||
local col = vim.fn.col('.') - 1
|
||||
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
_G.tab_complete = function()
|
||||
if cmp and cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip and luasnip.expand_or_jumpable() then
|
||||
return t("<Plug>luasnip-expand-or-jump")
|
||||
elseif check_back_space() then
|
||||
return t "<Tab>"
|
||||
else
|
||||
cmp.complete()
|
||||
end
|
||||
return ""
|
||||
end
|
||||
_G.s_tab_complete = function()
|
||||
if cmp and cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip and luasnip.jumpable(-1) then
|
||||
return t("<Plug>luasnip-jump-prev")
|
||||
else
|
||||
return t "<S-Tab>"
|
||||
end
|
||||
return ""
|
||||
end
|
||||
|
||||
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("i", "<C-E>", "<Plug>luasnip-next-choice", {})
|
||||
vim.api.nvim_set_keymap("s", "<C-E>", "<Plug>luasnip-next-choice", {})
|
||||
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
@@ -1,37 +0,0 @@
|
||||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
-- https://github.com/shaunsingh/nord.nvim#%EF%B8%8F-configuration
|
||||
|
||||
-- Make sidebars and popup menus like nvim-tree and telescope
|
||||
-- have a different background
|
||||
vim.g.nord_contrast = true
|
||||
|
||||
-- Enable the border between verticaly split windows visable
|
||||
vim.g.nord_borders = true
|
||||
|
||||
-- Disable the setting of background color so that NeoVim
|
||||
-- can use your terminal background
|
||||
vim.g.nord_disable_background = false
|
||||
|
||||
-- Set the cursorline transparent/visible
|
||||
vim.g.nord_cursorline_transparent = false
|
||||
|
||||
-- Re-enables the background of the sidebar if you disabled the background of everything
|
||||
vim.g.nord_enable_sidebar_background = false
|
||||
|
||||
-- Enables/disables italics
|
||||
vim.g.nord_italic = true
|
||||
|
||||
-- Enables/disables colorful backgrounds when used in diff mode
|
||||
vim.g.nord_uniform_diff_background = true
|
||||
|
||||
-- Enables/disables bold
|
||||
vim.g.nord_bold = false
|
||||
end
|
||||
|
||||
function M.config()
|
||||
require('nord').set()
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,20 +0,0 @@
|
||||
local M = {}
|
||||
|
||||
function M.config()
|
||||
require("nvim-tree").setup({
|
||||
sort_by = "case_sensitive",
|
||||
renderer = {
|
||||
icons = {
|
||||
show = {
|
||||
file = false,
|
||||
folder = false,
|
||||
folder_arrow = false,
|
||||
git = false,
|
||||
}
|
||||
},
|
||||
group_empty = true,
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,58 +0,0 @@
|
||||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
vim.keymap.set('n', '<leader>ff', function() require('telescope.builtin').find_files({ hidden = true }) end)
|
||||
vim.keymap.set('n', '<leader>fb', function() require('telescope.builtin').buffers({ hidden = true }) end)
|
||||
vim.keymap.set('n', '<leader>fo', function() require('telescope.builtin').find_files({ cwd = '~/Syncthing/Obsidian/Personal/', search_file = '*.md' }) end)
|
||||
vim.keymap.set('n', '<leader>fO', function() require('telescope.builtin').live_grep({ cwd = '~/Syncthing/Obsidian/Personal/', search_file = '*.md' }) end)
|
||||
vim.keymap.set('n', '<leader>fh', function() require('telescope.builtin').help_tags() end)
|
||||
vim.keymap.set('n', '<leader>fq', function() require('telescope.builtin').quickfix() end)
|
||||
-- require('telescope.builtin').find_files({ hidden = true })
|
||||
end
|
||||
|
||||
function M.config()
|
||||
local telescope = require('telescope')
|
||||
|
||||
telescope.setup {
|
||||
defaults = {
|
||||
layout_strategy = 'vertical',
|
||||
winblend = 7,
|
||||
set_env = { COLORTERM = 'truecolor' },
|
||||
color_devicons = true,
|
||||
scroll_strategy = 'limit',
|
||||
},
|
||||
pickers = {
|
||||
live_grep = {
|
||||
only_sort_text = true,
|
||||
path_display = { 'shorten' },
|
||||
layout_strategy = 'horizontal',
|
||||
layout_config = { preview_width = 0.4 },
|
||||
},
|
||||
git_files = {
|
||||
path_display = {},
|
||||
hidden = true,
|
||||
show_untracked = true,
|
||||
layout_strategy = 'horizontal',
|
||||
layout_config = { preview_width = 0.65 },
|
||||
},
|
||||
},
|
||||
extensions = {
|
||||
fzf = {
|
||||
override_generic_sorter = true,
|
||||
override_file_sorter = true,
|
||||
case_mode = 'smart_case',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- pcall(require('telescope').load_extension, 'fzf')
|
||||
-- Enable telescope fzf native, if installed
|
||||
telescope.load_extension('fzf')
|
||||
end
|
||||
|
||||
-- Telescope
|
||||
-- TODO: change to Telescope
|
||||
-- nmap('<leader>ft', ':Files ~/Tmp<CR>')
|
||||
-- nmap('<leader>fo', ":call fzf#run(fzf#wrap(fzf#vim#with_preview({ 'source': 'fd . --type f --extension=md --follow --exclude .git ~/Syncthing/Obsidian/Personal' })))<CR>", { silent = true })
|
||||
|
||||
return M
|
||||
@@ -1,60 +0,0 @@
|
||||
local M = {}
|
||||
|
||||
function M.config()
|
||||
require('nvim-treesitter.configs').setup {
|
||||
-- one of "all", "maintained" (parsers with maintainers), or a list of languages
|
||||
ensure_installed = { 'bash', 'c', 'cpp', 'c_sharp', 'clojure', 'cmake', 'comment', 'commonlisp',
|
||||
'css', 'dockerfile', 'elixir', 'erlang', 'fish', 'go', 'html', 'http', 'java',
|
||||
'javascript', 'json', 'kotlin', 'latex', 'lua', 'make', 'markdown', 'perl', 'php',
|
||||
'python', 'ruby', 'rust', 'scss', 'swift', 'toml', 'tsx', 'vim', 'vue', 'yaml' },
|
||||
-- ignore_install = { 'norg' },
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
context_commentstring = {
|
||||
enable = true,
|
||||
enable_autocmd = false,
|
||||
},
|
||||
rainbow = {
|
||||
enable = true,
|
||||
disable = { "html" },
|
||||
extended_mode = false,
|
||||
max_file_lines = nil,
|
||||
},
|
||||
indent = { enable = false },
|
||||
autopairs = { enable = true },
|
||||
autotag = { enable = true },
|
||||
incremental_selection = { enable = true },
|
||||
textobjects = { -- syntax-aware textobjects
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
|
||||
disable = {},
|
||||
keymaps = {
|
||||
-- You can use the capture groups defined in textobjects.scm
|
||||
['af'] = '@function.outer',
|
||||
['if'] = '@function.inner',
|
||||
['aC'] = '@class.outer',
|
||||
['iC'] = '@class.inner',
|
||||
['ac'] = '@conditional.outer',
|
||||
['ic'] = '@conditional.inner',
|
||||
['ab'] = '@block.outer',
|
||||
['ib'] = '@block.inner',
|
||||
['al'] = '@loop.outer',
|
||||
['il'] = '@loop.inner',
|
||||
['is'] = '@statement.inner',
|
||||
['as'] = '@statement.outer',
|
||||
['am'] = '@call.outer',
|
||||
['im'] = '@call.inner',
|
||||
['ad'] = '@comment.outer',
|
||||
['id'] = '@comment.inner',
|
||||
['aa'] = '@parameter.outer',
|
||||
['ia'] = '@parameter.inner',
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,419 +0,0 @@
|
||||
-- Automatically generated packer.nvim plugin loader code
|
||||
|
||||
if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then
|
||||
vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"')
|
||||
return
|
||||
end
|
||||
|
||||
vim.api.nvim_command('packadd packer.nvim')
|
||||
|
||||
local no_errors, error_msg = pcall(function()
|
||||
|
||||
_G._packer = _G._packer or {}
|
||||
_G._packer.inside_compile = true
|
||||
|
||||
local time
|
||||
local profile_info
|
||||
local should_profile = false
|
||||
if should_profile then
|
||||
local hrtime = vim.loop.hrtime
|
||||
profile_info = {}
|
||||
time = function(chunk, start)
|
||||
if start then
|
||||
profile_info[chunk] = hrtime()
|
||||
else
|
||||
profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
|
||||
end
|
||||
end
|
||||
else
|
||||
time = function(chunk, start) end
|
||||
end
|
||||
|
||||
local function save_profiles(threshold)
|
||||
local sorted_times = {}
|
||||
for chunk_name, time_taken in pairs(profile_info) do
|
||||
sorted_times[#sorted_times + 1] = {chunk_name, time_taken}
|
||||
end
|
||||
table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
|
||||
local results = {}
|
||||
for i, elem in ipairs(sorted_times) do
|
||||
if not threshold or threshold and elem[2] > threshold then
|
||||
results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
|
||||
end
|
||||
end
|
||||
if threshold then
|
||||
table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)')
|
||||
end
|
||||
|
||||
_G._packer.profile_output = results
|
||||
end
|
||||
|
||||
time([[Luarocks path setup]], true)
|
||||
local package_path_str = "/Users/madundead/.cache/nvim/packer_hererocks/2.1.1703358377/share/lua/5.1/?.lua;/Users/madundead/.cache/nvim/packer_hererocks/2.1.1703358377/share/lua/5.1/?/init.lua;/Users/madundead/.cache/nvim/packer_hererocks/2.1.1703358377/lib/luarocks/rocks-5.1/?.lua;/Users/madundead/.cache/nvim/packer_hererocks/2.1.1703358377/lib/luarocks/rocks-5.1/?/init.lua"
|
||||
local install_cpath_pattern = "/Users/madundead/.cache/nvim/packer_hererocks/2.1.1703358377/lib/lua/5.1/?.so"
|
||||
if not string.find(package.path, package_path_str, 1, true) then
|
||||
package.path = package.path .. ';' .. package_path_str
|
||||
end
|
||||
|
||||
if not string.find(package.cpath, install_cpath_pattern, 1, true) then
|
||||
package.cpath = package.cpath .. ';' .. install_cpath_pattern
|
||||
end
|
||||
|
||||
time([[Luarocks path setup]], false)
|
||||
time([[try_loadstring definition]], true)
|
||||
local function try_loadstring(s, component, name)
|
||||
local success, result = pcall(loadstring(s), name, _G.packer_plugins[name])
|
||||
if not success then
|
||||
vim.schedule(function()
|
||||
vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {})
|
||||
end)
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
time([[try_loadstring definition]], false)
|
||||
time([[Defining packer_plugins]], true)
|
||||
_G.packer_plugins = {
|
||||
LuaSnip = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/LuaSnip",
|
||||
url = "https://github.com/L3MON4D3/LuaSnip"
|
||||
},
|
||||
["asyncrun.vim"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/asyncrun.vim",
|
||||
url = "https://github.com/skywind3000/asyncrun.vim"
|
||||
},
|
||||
["cmp-buffer"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/cmp-buffer",
|
||||
url = "https://github.com/hrsh7th/cmp-buffer"
|
||||
},
|
||||
["cmp-nvim-lsp"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp",
|
||||
url = "https://github.com/hrsh7th/cmp-nvim-lsp"
|
||||
},
|
||||
["cmp-nvim-lua"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/cmp-nvim-lua",
|
||||
url = "https://github.com/hrsh7th/cmp-nvim-lua"
|
||||
},
|
||||
["cmp-path"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/cmp-path",
|
||||
url = "https://github.com/hrsh7th/cmp-path"
|
||||
},
|
||||
cmp_luasnip = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/cmp_luasnip",
|
||||
url = "https://github.com/saadparwaiz1/cmp_luasnip"
|
||||
},
|
||||
["comment.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/comment.nvim",
|
||||
url = "https://github.com/numtostr/comment.nvim"
|
||||
},
|
||||
["ctrlsf.vim"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/ctrlsf.vim",
|
||||
url = "https://github.com/dyng/ctrlsf.vim"
|
||||
},
|
||||
["friendly-snippets"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/friendly-snippets",
|
||||
url = "https://github.com/rafamadriz/friendly-snippets"
|
||||
},
|
||||
["gitsigns.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/gitsigns.nvim",
|
||||
url = "https://github.com/lewis6991/gitsigns.nvim"
|
||||
},
|
||||
["leap.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/leap.nvim",
|
||||
url = "https://github.com/ggandor/leap.nvim"
|
||||
},
|
||||
["lsp-zero.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/lsp-zero.nvim",
|
||||
url = "https://github.com/VonHeikemen/lsp-zero.nvim"
|
||||
},
|
||||
["mason-lspconfig.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim",
|
||||
url = "https://github.com/williamboman/mason-lspconfig.nvim"
|
||||
},
|
||||
["mason.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/mason.nvim",
|
||||
url = "https://github.com/williamboman/mason.nvim"
|
||||
},
|
||||
["nord.nvim"] = {
|
||||
config = { "\27LJ\2\n;\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\vconfig\17plugins.nord\frequire\0" },
|
||||
loaded = true,
|
||||
needs_bufread = false,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/nord.nvim",
|
||||
url = "https://github.com/shaunsingh/nord.nvim"
|
||||
},
|
||||
["nvim-bqf"] = {
|
||||
loaded = false,
|
||||
needs_bufread = true,
|
||||
only_cond = false,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/nvim-bqf",
|
||||
url = "https://github.com/kevinhwang91/nvim-bqf"
|
||||
},
|
||||
["nvim-cmp"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/nvim-cmp",
|
||||
url = "https://github.com/hrsh7th/nvim-cmp"
|
||||
},
|
||||
["nvim-lspconfig"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
|
||||
url = "https://github.com/neovim/nvim-lspconfig"
|
||||
},
|
||||
["nvim-pqf"] = {
|
||||
loaded = false,
|
||||
needs_bufread = false,
|
||||
only_cond = false,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/nvim-pqf",
|
||||
url = "https://github.com/kevinhwang91/nvim-pqf"
|
||||
},
|
||||
["nvim-tree.lua"] = {
|
||||
commands = { "NvimTreeToggle", "NvimTreeFindFile" },
|
||||
config = { "\27LJ\2\n@\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\vconfig\22plugins/nvim-tree\frequire\0" },
|
||||
loaded = false,
|
||||
needs_bufread = false,
|
||||
only_cond = false,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/nvim-tree.lua",
|
||||
url = "https://github.com/nvim-tree/nvim-tree.lua"
|
||||
},
|
||||
["nvim-treesitter"] = {
|
||||
after = { "nvim-treesitter-textobjects" },
|
||||
config = { "\27LJ\2\nA\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\vconfig\23plugins/treesitter\frequire\0" },
|
||||
loaded = false,
|
||||
needs_bufread = false,
|
||||
only_cond = false,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/nvim-treesitter",
|
||||
url = "https://github.com/nvim-treesitter/nvim-treesitter"
|
||||
},
|
||||
["nvim-treesitter-textobjects"] = {
|
||||
load_after = {
|
||||
["nvim-treesitter"] = true
|
||||
},
|
||||
loaded = false,
|
||||
needs_bufread = false,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/nvim-treesitter-textobjects",
|
||||
url = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects"
|
||||
},
|
||||
["oil.nvim"] = {
|
||||
config = { "\27LJ\2\n]\0\0\4\0\6\0\t6\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\4\0005\3\3\0=\3\5\2B\0\2\1K\0\1\0\17view_options\1\0\0\1\0\1\16show_hidden\1\nsetup\boil\frequire\0" },
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/oil.nvim",
|
||||
url = "https://github.com/stevearc/oil.nvim"
|
||||
},
|
||||
["packer.nvim"] = {
|
||||
loaded = false,
|
||||
needs_bufread = false,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/packer.nvim",
|
||||
url = "https://github.com/wbthomason/packer.nvim"
|
||||
},
|
||||
playground = {
|
||||
commands = { "TSPlaygroundToggle" },
|
||||
loaded = false,
|
||||
needs_bufread = true,
|
||||
only_cond = false,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/playground",
|
||||
url = "https://github.com/nvim-treesitter/playground"
|
||||
},
|
||||
["plenary.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/plenary.nvim",
|
||||
url = "https://github.com/nvim-lua/plenary.nvim"
|
||||
},
|
||||
["splitjoin.vim"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/splitjoin.vim",
|
||||
url = "https://github.com/andrewradev/splitjoin.vim"
|
||||
},
|
||||
["telescope-fzf-native.nvim"] = {
|
||||
cond = { true },
|
||||
loaded = false,
|
||||
needs_bufread = false,
|
||||
only_cond = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/telescope-fzf-native.nvim",
|
||||
url = "https://github.com/nvim-telescope/telescope-fzf-native.nvim"
|
||||
},
|
||||
["telescope.nvim"] = {
|
||||
config = { "\27LJ\2\n@\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\vconfig\22plugins/telescope\frequire\0" },
|
||||
loaded = false,
|
||||
needs_bufread = true,
|
||||
only_cond = false,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/telescope.nvim",
|
||||
url = "https://github.com/nvim-telescope/telescope.nvim"
|
||||
},
|
||||
["vim-easy-align"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/vim-easy-align",
|
||||
url = "https://github.com/junegunn/vim-easy-align"
|
||||
},
|
||||
["vim-fugitive"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/vim-fugitive",
|
||||
url = "https://github.com/tpope/vim-fugitive"
|
||||
},
|
||||
["vim-qfloc-edit"] = {
|
||||
loaded = false,
|
||||
needs_bufread = true,
|
||||
only_cond = false,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/vim-qfloc-edit",
|
||||
url = "https://github.com/weilbith/vim-qfloc-edit"
|
||||
},
|
||||
["vim-rails"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/vim-rails",
|
||||
url = "https://github.com/tpope/vim-rails"
|
||||
},
|
||||
["vim-repeat"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/vim-repeat",
|
||||
url = "https://github.com/tpope/vim-repeat"
|
||||
},
|
||||
["vim-rhubarb"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/vim-rhubarb",
|
||||
url = "https://github.com/tpope/vim-rhubarb"
|
||||
},
|
||||
["vim-startuptime"] = {
|
||||
commands = { "StartupTime" },
|
||||
loaded = false,
|
||||
needs_bufread = false,
|
||||
only_cond = false,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/opt/vim-startuptime",
|
||||
url = "https://github.com/dstein64/vim-startuptime"
|
||||
},
|
||||
["vim-surround"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/vim-surround",
|
||||
url = "https://github.com/tpope/vim-surround"
|
||||
},
|
||||
["vim-tmux-navigator"] = {
|
||||
loaded = true,
|
||||
path = "/Users/madundead/.local/share/nvim/site/pack/packer/start/vim-tmux-navigator",
|
||||
url = "https://github.com/christoomey/vim-tmux-navigator"
|
||||
}
|
||||
}
|
||||
|
||||
time([[Defining packer_plugins]], false)
|
||||
local module_lazy_loads = {
|
||||
["^telescope"] = "telescope.nvim"
|
||||
}
|
||||
local lazy_load_called = {['packer.load'] = true}
|
||||
local function lazy_load_module(module_name)
|
||||
local to_load = {}
|
||||
if lazy_load_called[module_name] then return nil end
|
||||
lazy_load_called[module_name] = true
|
||||
for module_pat, plugin_name in pairs(module_lazy_loads) do
|
||||
if not _G.packer_plugins[plugin_name].loaded and string.match(module_name, module_pat) then
|
||||
to_load[#to_load + 1] = plugin_name
|
||||
end
|
||||
end
|
||||
|
||||
if #to_load > 0 then
|
||||
require('packer.load')(to_load, {module = module_name}, _G.packer_plugins)
|
||||
local loaded_mod = package.loaded[module_name]
|
||||
if loaded_mod then
|
||||
return function(modname) return loaded_mod end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not vim.g.packer_custom_loader_enabled then
|
||||
table.insert(package.loaders, 1, lazy_load_module)
|
||||
vim.g.packer_custom_loader_enabled = true
|
||||
end
|
||||
|
||||
-- Setup for: nord.nvim
|
||||
time([[Setup for nord.nvim]], true)
|
||||
try_loadstring("\27LJ\2\n:\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\17plugins.nord\frequire\0", "setup", "nord.nvim")
|
||||
time([[Setup for nord.nvim]], false)
|
||||
time([[packadd for nord.nvim]], true)
|
||||
vim.cmd [[packadd nord.nvim]]
|
||||
time([[packadd for nord.nvim]], false)
|
||||
-- Setup for: telescope.nvim
|
||||
time([[Setup for telescope.nvim]], true)
|
||||
try_loadstring("\27LJ\2\n?\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\22plugins/telescope\frequire\0", "setup", "telescope.nvim")
|
||||
time([[Setup for telescope.nvim]], false)
|
||||
-- Config for: nord.nvim
|
||||
time([[Config for nord.nvim]], true)
|
||||
try_loadstring("\27LJ\2\n;\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\vconfig\17plugins.nord\frequire\0", "config", "nord.nvim")
|
||||
time([[Config for nord.nvim]], false)
|
||||
-- Config for: oil.nvim
|
||||
time([[Config for oil.nvim]], true)
|
||||
try_loadstring("\27LJ\2\n]\0\0\4\0\6\0\t6\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\4\0005\3\3\0=\3\5\2B\0\2\1K\0\1\0\17view_options\1\0\0\1\0\1\16show_hidden\1\nsetup\boil\frequire\0", "config", "oil.nvim")
|
||||
time([[Config for oil.nvim]], false)
|
||||
-- Conditional loads
|
||||
time([[Conditional loading of telescope-fzf-native.nvim]], true)
|
||||
require("packer.load")({"telescope-fzf-native.nvim"}, {}, _G.packer_plugins)
|
||||
time([[Conditional loading of telescope-fzf-native.nvim]], false)
|
||||
|
||||
-- Command lazy-loads
|
||||
time([[Defining lazy-load commands]], true)
|
||||
pcall(vim.api.nvim_create_user_command, 'TSPlaygroundToggle', function(cmdargs)
|
||||
require('packer.load')({'playground'}, { cmd = 'TSPlaygroundToggle', l1 = cmdargs.line1, l2 = cmdargs.line2, bang = cmdargs.bang, args = cmdargs.args, mods = cmdargs.mods }, _G.packer_plugins)
|
||||
end,
|
||||
{nargs = '*', range = true, bang = true, complete = function()
|
||||
require('packer.load')({'playground'}, {}, _G.packer_plugins)
|
||||
return vim.fn.getcompletion('TSPlaygroundToggle ', 'cmdline')
|
||||
end})
|
||||
pcall(vim.api.nvim_create_user_command, 'NvimTreeToggle', function(cmdargs)
|
||||
require('packer.load')({'nvim-tree.lua'}, { cmd = 'NvimTreeToggle', l1 = cmdargs.line1, l2 = cmdargs.line2, bang = cmdargs.bang, args = cmdargs.args, mods = cmdargs.mods }, _G.packer_plugins)
|
||||
end,
|
||||
{nargs = '*', range = true, bang = true, complete = function()
|
||||
require('packer.load')({'nvim-tree.lua'}, {}, _G.packer_plugins)
|
||||
return vim.fn.getcompletion('NvimTreeToggle ', 'cmdline')
|
||||
end})
|
||||
pcall(vim.api.nvim_create_user_command, 'NvimTreeFindFile', function(cmdargs)
|
||||
require('packer.load')({'nvim-tree.lua'}, { cmd = 'NvimTreeFindFile', l1 = cmdargs.line1, l2 = cmdargs.line2, bang = cmdargs.bang, args = cmdargs.args, mods = cmdargs.mods }, _G.packer_plugins)
|
||||
end,
|
||||
{nargs = '*', range = true, bang = true, complete = function()
|
||||
require('packer.load')({'nvim-tree.lua'}, {}, _G.packer_plugins)
|
||||
return vim.fn.getcompletion('NvimTreeFindFile ', 'cmdline')
|
||||
end})
|
||||
pcall(vim.api.nvim_create_user_command, 'StartupTime', function(cmdargs)
|
||||
require('packer.load')({'vim-startuptime'}, { cmd = 'StartupTime', l1 = cmdargs.line1, l2 = cmdargs.line2, bang = cmdargs.bang, args = cmdargs.args, mods = cmdargs.mods }, _G.packer_plugins)
|
||||
end,
|
||||
{nargs = '*', range = true, bang = true, complete = function()
|
||||
require('packer.load')({'vim-startuptime'}, {}, _G.packer_plugins)
|
||||
return vim.fn.getcompletion('StartupTime ', 'cmdline')
|
||||
end})
|
||||
time([[Defining lazy-load commands]], false)
|
||||
|
||||
vim.cmd [[augroup packer_load_aucmds]]
|
||||
vim.cmd [[au!]]
|
||||
-- Filetype lazy-loads
|
||||
time([[Defining lazy-load filetype autocommands]], true)
|
||||
vim.cmd [[au FileType qf ++once lua require("packer.load")({'nvim-pqf', 'nvim-bqf', 'vim-qfloc-edit'}, { ft = "qf" }, _G.packer_plugins)]]
|
||||
time([[Defining lazy-load filetype autocommands]], false)
|
||||
-- Event lazy-loads
|
||||
time([[Defining lazy-load event autocommands]], true)
|
||||
vim.cmd [[au BufNewFile * ++once lua require("packer.load")({'nvim-treesitter'}, { event = "BufNewFile *" }, _G.packer_plugins)]]
|
||||
vim.cmd [[au BufRead * ++once lua require("packer.load")({'nvim-treesitter'}, { event = "BufRead *" }, _G.packer_plugins)]]
|
||||
time([[Defining lazy-load event autocommands]], false)
|
||||
vim.cmd("augroup END")
|
||||
|
||||
_G._packer.inside_compile = false
|
||||
if _G._packer.needs_bufread == true then
|
||||
vim.cmd("doautocmd BufRead")
|
||||
end
|
||||
_G._packer.needs_bufread = false
|
||||
|
||||
if should_profile then save_profiles() end
|
||||
|
||||
end)
|
||||
|
||||
if not no_errors then
|
||||
error_msg = error_msg:gsub('"', '\\"')
|
||||
vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None')
|
||||
end
|
||||
592
vim/.vimrc
592
vim/.vimrc
@@ -1,592 +0,0 @@
|
||||
" Author: Konstantin Bukley <madundead@gmail.com>
|
||||
" License: WTFPL
|
||||
" Description: Personal vim configuration
|
||||
|
||||
|
||||
" ========================================================
|
||||
" -> General
|
||||
" ========================================================
|
||||
|
||||
nnoremap <Space> <Nop>
|
||||
let mapleader=' '
|
||||
|
||||
" ========================================================
|
||||
" -> Plugins
|
||||
" ========================================================
|
||||
"
|
||||
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
"
|
||||
|
||||
call plug#begin('~/.vim/plugged')
|
||||
|
||||
Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeToggle', 'NERDTreeFind'] }
|
||||
Plug 'junegunn/vim-easy-align', { 'on': ['<Plug>(EasyAlign)', 'EasyAlign'] }
|
||||
Plug 'gregsexton/MatchTag', { 'for': 'html' }
|
||||
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
|
||||
Plug 'junegunn/fzf.vim'
|
||||
Plug 'AndrewRadev/splitjoin.vim'
|
||||
Plug 'mattn/gist-vim' | Plug 'mattn/webapi-vim'
|
||||
Plug 'Raimondi/delimitMate'
|
||||
Plug 'nelstrom/vim-visual-star-search'
|
||||
Plug 'benmills/vimux'
|
||||
Plug 'vim-test/vim-test'
|
||||
Plug 'dyng/ctrlsf.vim'
|
||||
Plug 'terryma/vim-expand-region'
|
||||
Plug 'mg979/vim-visual-multi'
|
||||
Plug 'bogado/file-line'
|
||||
Plug 'vim-utils/vim-interruptless'
|
||||
Plug 'airblade/vim-gitgutter'
|
||||
Plug 'machakann/vim-highlightedyank'
|
||||
Plug 'arcticicestudio/nord-vim'
|
||||
Plug 'christoomey/vim-tmux-navigator'
|
||||
Plug 'tpope/vim-fugitive'
|
||||
Plug 'tpope/vim-rails', { 'for': 'ruby' }
|
||||
Plug 'tpope/vim-surround'
|
||||
Plug 'tpope/vim-commentary'
|
||||
Plug 'tpope/vim-repeat'
|
||||
Plug 'tpope/vim-git'
|
||||
Plug 'tpope/vim-vinegar'
|
||||
Plug 'tpope/vim-rhubarb'
|
||||
|
||||
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
|
||||
Plug 'L3MON4D3/LuaSnip' | Plug 'honza/vim-snippets'
|
||||
|
||||
" ======== Experimental =================================
|
||||
|
||||
" Plug 'nvim-lua/popup.nvim'
|
||||
" Plug 'nvim-lua/plenary.nvim'
|
||||
" Plug 'nvim-telescope/telescope.nvim'
|
||||
|
||||
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
||||
Plug 'neovim/nvim-lspconfig'
|
||||
|
||||
call plug#end()
|
||||
|
||||
|
||||
|
||||
" ========================================================
|
||||
" -> Functions
|
||||
" ========================================================
|
||||
|
||||
function! StripTrailingWhitespace()
|
||||
let _s=@/
|
||||
let l = line(".")
|
||||
let c = col(".")
|
||||
%s/\s\+$//e
|
||||
let @/=_s
|
||||
silent! call cursor(l, c)
|
||||
endfunction
|
||||
|
||||
function! Tabline()
|
||||
let s = ''
|
||||
for i in range(tabpagenr('$'))
|
||||
let tab = i + 1
|
||||
let winnr = tabpagewinnr(tab)
|
||||
let buflist = tabpagebuflist(tab)
|
||||
let bufnr = buflist[winnr - 1]
|
||||
let bufname = bufname(bufnr)
|
||||
let bufmodified = getbufvar(bufnr, "&mod")
|
||||
|
||||
let s .= (tab == tabpagenr() ? '%#TabLineSel#' : '%#TabLine#')
|
||||
|
||||
if bufname == ''
|
||||
let s .= ' empty'
|
||||
elseif bufname =~ 'NERD_tree'
|
||||
let s .= ' tree'
|
||||
elseif bufname =~ 'ControlP'
|
||||
let s .= ' ctrlp'
|
||||
elseif bufname =~ 'FZF'
|
||||
let s .= ' fzf'
|
||||
elseif bufname =~ '__CtrlSF__'
|
||||
let s .= ' ctrlsf'
|
||||
else
|
||||
let s .= ' ' . fnamemodify(bufname, ':t')
|
||||
endif
|
||||
|
||||
if bufmodified
|
||||
let s .= '(+)'
|
||||
endif
|
||||
endfor
|
||||
|
||||
let s .= '%#TabLineFill#'
|
||||
return s
|
||||
endfunction
|
||||
|
||||
function! CloseNERDTree()
|
||||
if exists("t:NERDTreeBufName")
|
||||
if bufwinnr(t:NERDTreeBufName) != -1
|
||||
if winnr("$") == 1
|
||||
q
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
" ========================================================
|
||||
" -> Plugin settings
|
||||
" ========================================================
|
||||
|
||||
" Enable matchit.vim
|
||||
runtime macros/matchit.vim
|
||||
|
||||
" --- Netrw
|
||||
|
||||
let g:netrw_banner = 0
|
||||
let g:netrw_list_hide = '^\.$'
|
||||
let g:netrw_liststyle = 4
|
||||
|
||||
" --- test
|
||||
|
||||
let test#strategy = "vimux"
|
||||
|
||||
" --- NERDTree
|
||||
|
||||
let NERDTreeWinPos = "right"
|
||||
let NERDTreeMinimalUI = 1
|
||||
let NERDTreeDirArrows = 1
|
||||
let NERDTreeAutoDeleteBuffer = 1
|
||||
let NERDTreeHijackNetrw = 1
|
||||
|
||||
" --- highlightedyank
|
||||
|
||||
let g:highlightedyank_highlight_duration = 400
|
||||
|
||||
" --- gitgutter
|
||||
|
||||
let g:gitgutter_sign_added = '│'
|
||||
let g:gitgutter_sign_modified = '│'
|
||||
let g:gitgutter_sign_removed = '│'
|
||||
let g:gitgutter_sign_modified_removed = '│'
|
||||
let g:gitgutter_sign_removed_first_line = '│'
|
||||
|
||||
" --- fzf
|
||||
|
||||
if has('nvim') || has('gui_running')
|
||||
let $FZF_DEFAULT_OPTS .= ' --no-info --color=gutter:#2E3440'
|
||||
endif
|
||||
|
||||
" Obsidian
|
||||
command! FO
|
||||
\ call fzf#run(fzf#wrap(fzf#vim#with_preview({
|
||||
\ 'source': 'fd . --type f --extension=md --follow --exclude .git ~/Syncthing/Obsidian/Personal'
|
||||
\ })))
|
||||
|
||||
let g:fzf_preview_window = ''
|
||||
let g:fzf_layout = { 'window': { 'width': 0.6, 'height': 0.6, 'border': 'sharp' } }
|
||||
let g:fzf_colors =
|
||||
\ { 'fg': ['fg', 'Normal'],
|
||||
\ 'bg': ['bg', 'Normal'],
|
||||
\ 'hl': ['fg', 'Comment'],
|
||||
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
|
||||
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
|
||||
\ 'hl+': ['fg', 'Statement'],
|
||||
\ 'info': ['fg', 'PreProc'],
|
||||
\ 'border': ['fg', 'Ignore'],
|
||||
\ 'prompt': ['fg', 'Conditional'],
|
||||
\ 'pointer': ['fg', 'Exception'],
|
||||
\ 'marker': ['fg', 'Keyword'],
|
||||
\ 'spinner': ['fg', 'Label'],
|
||||
\ 'header': ['fg', 'Comment'] }
|
||||
|
||||
" --- CtrlSF
|
||||
|
||||
let g:ctrlsf_ackprg = 'rg'
|
||||
let g:ctrlsf_regex_pattern = 1
|
||||
let g:ctrlsf_case_sensitive = 'smart'
|
||||
let g:ctrlsf_default_root = 'project'
|
||||
let g:ctrlsf_context = '-B 1 -A 1'
|
||||
let g:ctrlsf_position = 'bottom'
|
||||
let g:ctrlsf_winsize = '40%'
|
||||
let g:ctrlsf_mapping =
|
||||
\ {
|
||||
\ 'next': 'n',
|
||||
\ 'prev': 'N',
|
||||
\ }
|
||||
|
||||
" --- gist-vim
|
||||
|
||||
let g:gist_clip_command = 'pbcopy'
|
||||
let g:gist_detect_filetype = 1
|
||||
let g:gist_post_private = 1
|
||||
let g:gist_show_privates = 1
|
||||
|
||||
|
||||
" ========================================================
|
||||
" -> Autocommands
|
||||
" ========================================================
|
||||
|
||||
if has("autocmd")
|
||||
au filetype help nnoremap <buffer><CR> <c-]>
|
||||
au filetype help nnoremap <buffer><BS> <c-T>
|
||||
au filetype help set nonumber
|
||||
|
||||
au BufNewFile,BufRead *.docker setl ft=Dockerfile
|
||||
|
||||
au FileType xml setlocal equalprg=xmllint\ --format\ --recover\ -\ 2>/dev/null
|
||||
au FileType json setlocal equalprg=python\ -m\ json.tool
|
||||
|
||||
au FileType markdown setlocal wrap
|
||||
|
||||
" Hide statusline
|
||||
au! FileType fzf
|
||||
au FileType fzf set laststatus=0 noshowmode noruler
|
||||
\| autocmd BufLeave <buffer> set laststatus=2 showmode ruler
|
||||
|
||||
" Close tab if only NERDTree left
|
||||
au WinEnter * call CloseNERDTree()
|
||||
|
||||
" Resize when the host window resized
|
||||
au VimResized * wincmd =
|
||||
endif
|
||||
|
||||
|
||||
|
||||
" ========================================================
|
||||
" -> Colors & Fonts
|
||||
" ========================================================
|
||||
|
||||
colorscheme nord
|
||||
set background=dark
|
||||
|
||||
set guifont=Fira\ Code\ Medium:h18
|
||||
if has('gui_running')
|
||||
set guioptions-=T " Remove toolbar
|
||||
set guioptions-=m " Remove menubar
|
||||
set guioptions+=LlRrb " Remove
|
||||
set guioptions-=LlRrb " Scrollbars
|
||||
set t_Co=256
|
||||
else
|
||||
" Disable Background Color Erase (BCE) so that color schemes
|
||||
" work properly when Vim is used inside tmux and GNU screen.
|
||||
" See also http://snk.tuxfamily.org/log/vim-256color-bce.html
|
||||
set t_ut=
|
||||
set t_Co=16
|
||||
endif
|
||||
|
||||
|
||||
|
||||
" ========================================================
|
||||
" -> User Interface
|
||||
" ========================================================
|
||||
|
||||
" Nicer separators
|
||||
set fillchars=diff:⣿,vert:│
|
||||
" Don't try to highlight lines longer than 800 characters.
|
||||
set synmaxcol=200
|
||||
" Do not redraw while running macros
|
||||
set lazyredraw
|
||||
" Tab label - requires vim-madundead
|
||||
set tabline=%!Tabline()
|
||||
" Number rows
|
||||
set number
|
||||
" Disable welcome message
|
||||
set shortmess+=I
|
||||
" Show matching braces
|
||||
set showmatch
|
||||
" Shows when you are in insert mode
|
||||
set showmode
|
||||
" Show title in console status bar
|
||||
set title
|
||||
" Dont wrap lines
|
||||
set nowrap
|
||||
" When I scroll up or down, there are 2 lines between the line I'm on and the bottom or top of the screen.
|
||||
set scrolloff=5
|
||||
" How many tenths of a second to blink on matching brackets
|
||||
set mat=2
|
||||
" Disable cursor blink
|
||||
set gcr=a:blinkon0
|
||||
" Hide the mouse pointer while typing
|
||||
set mousehide
|
||||
" Conceal mostly for markdown
|
||||
set conceallevel=2
|
||||
" Highlight VCS conflict markers
|
||||
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
|
||||
" Statusline
|
||||
set statusline=%<%f
|
||||
|
||||
" ========================================================
|
||||
" -> Behavior & Different Tricks
|
||||
" ========================================================
|
||||
|
||||
" Shamelessly taken from YADR dotfile repo https://github.com/skwp/dotfiles
|
||||
" Stuff to ignore whent tab completing
|
||||
set wildignore=*.o,*.obj,*~
|
||||
set wildignore+=*vim/backups*
|
||||
set wildignore+=*sass-cache*
|
||||
set wildignore+=*DS_Store*
|
||||
set wildignore+=vendor/rails/**
|
||||
set wildignore+=vendor/cache/**
|
||||
set wildignore+=*.gem
|
||||
set wildignore+=log/**
|
||||
set wildignore+=tmp/**
|
||||
set wildignore+=*.png,*.jpg,*.gif
|
||||
" Russian keymap support
|
||||
set langmap=ФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯЖ;ABCDEFGHIJKLMNOPQRSTUVWXYZ:,фисвуапршолдьтщзйкыегмцчня;abcdefghijklmnopqrstuvwxyz
|
||||
" W invokes sudo
|
||||
command! W w !sudo tee % > /dev/null
|
||||
" Use the OS clipboard by default (requires `+clipboard`)
|
||||
set clipboard=unnamed
|
||||
" Tenths of a second to show the matching paren
|
||||
set matchtime=2
|
||||
" Turn off visualbell
|
||||
set novisualbell
|
||||
" Fuck backups
|
||||
set nobackup
|
||||
set nowb
|
||||
set noswapfile
|
||||
" Doesn't select lines number in vim
|
||||
set mouse=a
|
||||
" Fancy whitespace characters
|
||||
set list listchars=tab:→\ ,trail:·
|
||||
" Abbrev. of messages (avoids 'hit enter')
|
||||
set shortmess+=filmnrxoOtT
|
||||
" Start scrolling when we're 8 lines away from margins
|
||||
set scrolloff=8
|
||||
" The minimal number of screen columns to keep to the left and to the
|
||||
" right of the cursor if 'nowrap' is set.
|
||||
set sidescrolloff=15
|
||||
" Vertical splits in diff mode
|
||||
set diffopt+=vertical
|
||||
" Reduce delay between modes
|
||||
set timeoutlen=1000 ttimeoutlen=0
|
||||
" Use ripgrep if possible
|
||||
if executable('rg')
|
||||
set grepprg=rg\ -i\ --vimgrep
|
||||
endif
|
||||
" Enables aliases from .bashrc in :! commands
|
||||
set shellcmdflag=-ic
|
||||
|
||||
|
||||
|
||||
" ========================================================
|
||||
" -> Indentations
|
||||
" ========================================================
|
||||
|
||||
" Automatically inserts one extra level of indentation in some cases
|
||||
set smartindent
|
||||
" Tab counts as 2 columns
|
||||
set tabstop=2
|
||||
" Numbers of spaces to (auto)indent
|
||||
set shiftwidth=2
|
||||
" Spaces
|
||||
set expandtab
|
||||
|
||||
|
||||
|
||||
" ========================================================
|
||||
" -> Hotkeys & Bindings
|
||||
" ========================================================
|
||||
|
||||
nnoremap ; :
|
||||
|
||||
nnoremap <silent> Q :q!<CR>
|
||||
|
||||
nnoremap <C-h> <C-w>h
|
||||
nnoremap <C-j> <C-w>j
|
||||
nnoremap <C-k> <C-w>k
|
||||
nnoremap <C-l> <C-w>l
|
||||
|
||||
nnoremap ,, <C-^>
|
||||
|
||||
nnoremap <silent><expr><leader>ff (expand('%') =~ 'NERD_tree' ? "\<C-w>\<C-w>" : '').":Files\<CR>"
|
||||
nnoremap <silent><expr><leader>b (expand('%') =~ 'NERD_tree' ? "\<C-w>\<C-w>" : '').":Buffers\<CR>"
|
||||
nnoremap <silent><expr><leader>gl (expand('%') =~ 'NERD_tree' ? "\<C-w>\<C-w>" : '').":Commits\<CR>"
|
||||
|
||||
nnoremap <silent><leader>a :A<CR>
|
||||
nnoremap <silent><leader>x <nop>
|
||||
nnoremap <silent><leader>n :NERDTreeToggle<CR>
|
||||
nnoremap <silent><leader>N :NERDTreeFind<CR>
|
||||
nnoremap <silent><leader>c <ESC>/\v^[<=>]{7}( .*\|$)<CR>
|
||||
nnoremap <silent><leader>t :tabnew<CR>
|
||||
nnoremap <silent><leader>d orequire 'pry'; binding.pry<ESC>
|
||||
nnoremap <silent><leader>D oit { require 'pry'; binding.pry }<ESC>
|
||||
nnoremap <silent><leader>r :TestFile<CR>
|
||||
nnoremap <silent><leader>R :TestSuite<CR>
|
||||
nnoremap <silent><leader>J :%!python -m json.tool<CR>
|
||||
nnoremap <silent><leader>w :w<CR>
|
||||
nnoremap <silent><leader>q :q!<CR>
|
||||
nnoremap <silent><leader>e :e!<CR>
|
||||
nnoremap <silent><leader>= <C-w>=
|
||||
nnoremap <silent><leader><space> :nohlsearch<CR>
|
||||
|
||||
nnoremap <silent><leader>ga :Gwrite<CR>
|
||||
nnoremap <silent><leader>gs :Git<CR>
|
||||
nnoremap <silent><leader>gb :Git blame<CR>
|
||||
|
||||
nnoremap <silent><leader>t :tabnew<CR>
|
||||
nnoremap <silent><Tab> :tabnext<CR>
|
||||
nnoremap <silent><S-Tab> :tabprevious<CR>
|
||||
|
||||
" nnoremap <silent>vv <c-w>v
|
||||
nnoremap <silent>vv :sp <CR>
|
||||
nnoremap <silent><C-w> :call StripTrailingWhitespace()<CR>
|
||||
|
||||
nnoremap <leader>S :%s/\<<c-r><c-w>\>//g<left><left>
|
||||
|
||||
nnoremap yy Y
|
||||
nnoremap Y y$
|
||||
nnoremap N Nzz
|
||||
nnoremap n nzz
|
||||
nnoremap j gj
|
||||
nnoremap k gk
|
||||
nnoremap H ^
|
||||
nnoremap L $
|
||||
nnoremap J mzJ`z
|
||||
nnoremap K <Nop>
|
||||
nnoremap gQ <Nop>
|
||||
|
||||
vnoremap . :normal .<CR>
|
||||
vnoremap J :m '>+1<CR>gv=gv
|
||||
vnoremap K :m '<-2<CR>gv=gv
|
||||
vnoremap < <gv
|
||||
vnoremap > >gv
|
||||
|
||||
inoremap <C-e> <End>
|
||||
vnoremap <C-e> <End>
|
||||
cnoremap <C-e> <End>
|
||||
inoremap <C-a> <Home>
|
||||
vnoremap <C-a> <Home>
|
||||
cnoremap <C-a> <Home>
|
||||
|
||||
nmap <C-f> <Plug>CtrlSFPrompt
|
||||
vmap <C-f> <Plug>CtrlSFVwordPath
|
||||
vmap <Enter> <Plug>(EasyAlign)
|
||||
xmap ga <Plug>(EasyAlign)
|
||||
nmap ga <Plug>(EasyAlign)
|
||||
|
||||
|
||||
nnoremap <silent><expr><leader>ft (expand('%') =~ 'NERD_tree' ? "\<C-w>\<C-w>" : '').":Files ~/Tmp\<CR>"
|
||||
nnoremap <leader>T :e ~/Tmp/
|
||||
|
||||
nnoremap <silent><expr><leader>fo (expand('%') =~ 'NERD_tree' ? "\<C-w>\<C-w>" : '').":FO<CR>"
|
||||
nnoremap <leader>O :e ~/ownCloud/Obsidian/Personal
|
||||
|
||||
" undo break points
|
||||
inoremap , ,<c-g>u
|
||||
inoremap . .<c-g>u
|
||||
inoremap ! !<c-g>u
|
||||
inoremap ? ?<c-g>u
|
||||
|
||||
" Fix gx https://github.com/vim/vim/issues/4738#issuecomment-856925080
|
||||
nnoremap <silent> gx :execute 'silent! !open ' . shellescape(expand('<cWORD>'), 1)<cr>
|
||||
|
||||
lua <<EOF
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
|
||||
ignore_install = { "norg" },
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
autopairs = { enable = true },
|
||||
}
|
||||
EOF
|
||||
|
||||
lua << EOF
|
||||
require'lspconfig'.solargraph.setup{}
|
||||
local nvim_lsp = require('lspconfig')
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
local on_attach = function(client, bufnr)
|
||||
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
||||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- Mappings.
|
||||
local opts = { noremap=true, silent=true }
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||
|
||||
end
|
||||
|
||||
-- Use a loop to conveniently call 'setup' on multiple servers and
|
||||
-- map buffer local keybindings when the language server attaches
|
||||
local servers = { 'solargraph' }
|
||||
for _, lsp in ipairs(servers) do
|
||||
nvim_lsp[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
require("luasnip.loaders.from_snipmate").load()
|
||||
|
||||
local function prequire(...)
|
||||
local status, lib = pcall(require, ...)
|
||||
if (status) then return lib end
|
||||
return nil
|
||||
end
|
||||
|
||||
local luasnip = prequire('luasnip')
|
||||
local cmp = prequire("cmp")
|
||||
|
||||
local t = function(str)
|
||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||
end
|
||||
|
||||
local check_back_space = function()
|
||||
local col = vim.fn.col('.') - 1
|
||||
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
_G.tab_complete = function()
|
||||
if cmp and cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip and luasnip.expand_or_jumpable() then
|
||||
return t("<Plug>luasnip-expand-or-jump")
|
||||
elseif check_back_space() then
|
||||
return t "<Tab>"
|
||||
else
|
||||
cmp.complete()
|
||||
end
|
||||
return ""
|
||||
end
|
||||
_G.s_tab_complete = function()
|
||||
if cmp and cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip and luasnip.jumpable(-1) then
|
||||
return t("<Plug>luasnip-jump-prev")
|
||||
else
|
||||
return t "<S-Tab>"
|
||||
end
|
||||
return ""
|
||||
end
|
||||
|
||||
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
||||
vim.api.nvim_set_keymap("i", "<C-E>", "<Plug>luasnip-next-choice", {})
|
||||
vim.api.nvim_set_keymap("s", "<C-E>", "<Plug>luasnip-next-choice", {})
|
||||
EOF
|
||||
Reference in New Issue
Block a user