nvim: update

This commit is contained in:
2023-10-11 11:29:46 +03:00
parent 79eeb16be7
commit 1d791dee9b
5 changed files with 137 additions and 99 deletions

View File

@@ -49,6 +49,10 @@ export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS
--bind=ctrl-d:preview-page-down --bind=ctrl-d:preview-page-down
--bind=ctrl-u:preview-page-up" --bind=ctrl-u:preview-page-up"
# Fix for the following error in some Ruby version
# objc[12590]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
alias ~='cd ~' alias ~='cd ~'
alias l='exa' alias l='exa'
alias ls='exa' alias ls='exa'

View File

@@ -69,8 +69,8 @@ nmap('<leader>gb',':Git blame<CR>')
nmap('<leader>a', ':A<CR>') nmap('<leader>a', ':A<CR>')
-- test -- test
nmap('<leader>r', function() os.execute("tmux send-keys -t '{down-of}' 'bundle exec rspec '" .. vim.fn.expand("%") .. " Enter") end) 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}' 'bundle exec rspec .' Enter") end) nmap('<leader>R', function() os.execute("tmux send-keys -t '{down-of}' './bin/rspec .' Enter") end)
-- CtrlSF -- CtrlSF
nmap('<C-f>', '<Plug>CtrlSFPrompt') nmap('<C-f>', '<Plug>CtrlSFPrompt')

View File

@@ -9,27 +9,80 @@ end)
require('mason').setup({}) require('mason').setup({})
require('mason-lspconfig').setup({ require('mason-lspconfig').setup({
ensure_installed = {}, ensure_installed = { 'ruby_ls' },
handlers = { lsp_zero.default_setup }, handlers = { lsp_zero.default_setup },
}) })
lspconfig.solargraph.setup({ -- lspconfig.solargraph.setup({
-- there's a very weird problem with mason-provided solargraph -- -- there's a very weird problem with mason-provided solargraph
-- so instead I'm using the one from asdf -- -- so instead I'm using the one from asdf
cmd = { os.getenv( "HOME" ) .. "/.asdf/shims/solargraph", 'stdio' }, -- cmd = { os.getenv( "HOME" ) .. "/.asdf/shims/solargraph", 'stdio' },
settings = { -- settings = {
solargraph = { -- solargraph = {
autoformat = true, -- autoformat = true,
completion = true, -- completion = true,
diagnostic = true, -- diagnostic = true,
folding = true, -- folding = true,
references = true, -- references = true,
rename = true, -- rename = true,
symbols = true -- symbols = true
} -- }
} -- }
}) -- })
lspconfig.lua_ls.setup(lsp_zero.nvim_lua_ls()) 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() lsp_zero.setup()

View File

@@ -8,43 +8,43 @@ function M.setup()
end end
function M.config() function M.config()
local telescope = require 'telescope' local telescope = require('telescope')
telescope.setup { telescope.setup {
defaults = { defaults = {
layout_strategy = 'vertical', layout_strategy = 'vertical',
winblend = 7, winblend = 7,
set_env = { COLORTERM = 'truecolor' }, set_env = { COLORTERM = 'truecolor' },
color_devicons = true, color_devicons = true,
scroll_strategy = 'limit', scroll_strategy = 'limit',
}, },
pickers = { pickers = {
live_grep = { live_grep = {
only_sort_text = true, only_sort_text = true,
path_display = { 'shorten' }, path_display = { 'shorten' },
layout_strategy = 'horizontal', layout_strategy = 'horizontal',
layout_config = { preview_width = 0.4 }, layout_config = { preview_width = 0.4 },
}, },
git_files = { git_files = {
path_display = {}, path_display = {},
hidden = true, hidden = true,
show_untracked = true, show_untracked = true,
layout_strategy = 'horizontal', layout_strategy = 'horizontal',
layout_config = { preview_width = 0.65 }, layout_config = { preview_width = 0.65 },
}, },
}, },
extensions = { extensions = {
fzf = { fzf = {
override_generic_sorter = true, override_generic_sorter = true,
override_file_sorter = true, override_file_sorter = true,
case_mode = 'smart_case', case_mode = 'smart_case',
}, },
}, },
} }
-- pcall(require('telescope').load_extension, 'fzf') -- pcall(require('telescope').load_extension, 'fzf')
-- Enable telescope fzf native, if installed -- Enable telescope fzf native, if installed
telescope.load_extension('fzf') telescope.load_extension('fzf')
end end
-- Telescope -- Telescope

View File

@@ -1,10 +1,7 @@
local cmd, fn, opt, g = vim.cmd, vim.fn, vim.opt, vim.g local cmd, opt, g = vim.cmd, vim.opt, vim.g
local command = vim.api.nvim_create_user_command
cmd('au TextYankPost * lua vim.highlight.on_yank { timeout = 250 }') cmd('au TextYankPost * lua vim.highlight.on_yank { timeout = 250 }')
g.ruby_host_prog = 'asdf exec neovim-ruby-host'
opt.smartindent = true -- Autoindenting when starting a new line 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.tabstop = 2 -- Tab counts as 2 columns
@@ -12,38 +9,6 @@ opt.shiftwidth = 2 -- Numbers of spaces to (auto)indent
opt.expandtab = true -- Tabs to spaces opt.expandtab = true -- Tabs to spaces
opt.clipboard = 'unnamedplus' -- Share clipboard with the OS opt.clipboard = 'unnamedplus' -- Share clipboard with the OS
opt.number = true -- Display line numbers opt.number = true -- Display line numbers
-- opt.fillchars = {
-- vert = '▕', -- alternatives │
-- eob = ' ', -- suppress ~ at EndOfBuffer
-- msgsep = '‾',
-- diff = '⣿',
-- fold = ' ',
-- foldopen = '▾',
-- foldsep = '│',
-- foldclose = '▸',
-- }
--
opt.listchars = {
nbsp = '', -- CIRCLED REVERSE SOLIDUS (U+29B8, UTF-8: E2 A6 B8)
extends = '»', -- RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00BB, UTF-8: C2 BB)
precedes = '«', -- LEFT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00AB, UTF-8: C2 AB)
-- tab = ' ', -- '▷─' WHITE RIGHT-POINTING TRIANGLE (U+25B7, UTF-8: E2 96 B7) + BOX DRAWINGS HEAVY TRIPLE DASH HORIZONTAL (U+2505, UTF-8: E2 94 85)
trail = '', -- BULLET (U+2022, UTF-8: E2 80 A2)
space = ' ',
}
opt.fillchars = {
diff = '',
eob = ' ', -- NO-BREAK SPACE (U+00A0, UTF-8: C2 A0) to suppress ~ at EndOfBuffer
vert = '', -- window border when window splits vertically ─ ┴ ┬ ┤ ├ ┼
msgsep = '',
fold = '·', -- MIDDLE DOT (U+00B7, UTF-8: C2 B7)
foldopen = '',
foldsep = '',
foldclose = ''
}
opt.synmaxcol = 500 -- Do not try to highlight lines longer than 500 characters opt.synmaxcol = 500 -- Do not try to highlight lines longer than 500 characters
opt.lazyredraw = true -- Do not redraw while running macros opt.lazyredraw = true -- Do not redraw while running macros
opt.showmatch = true -- Show matching braces opt.showmatch = true -- Show matching braces
@@ -60,17 +25,30 @@ opt.writebackup = false -- No backups
opt.swapfile = false -- No backups opt.swapfile = false -- No backups
opt.mouse = 'a' -- Support mouse (for proper mouse highlight) opt.mouse = 'a' -- Support mouse (for proper mouse highlight)
opt.list = true -- List mode opt.list = true -- List mode
opt.listchars = { trail = '·', tab = '->' }
opt.timeoutlen = 1000 -- Delay for mappings opt.timeoutlen = 1000 -- Delay for mappings
opt.ttimeoutlen = 0 -- Delay between modes opt.ttimeoutlen = 0 -- Delay between modes
-- TODO: leads to "bash: no job control in this shell"
-- opt.shellcmdflag = '-ilc' -- Enables aliases from .bashrc in :! commands
opt.termguicolors = true -- 24-bit RGB color opt.termguicolors = true -- 24-bit RGB color
opt.listchars = {
nbsp = '', -- CIRCLED REVERSE SOLIDUS (U+29B8, UTF-8: E2 A6 B8)
extends = '»', -- RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00BB, UTF-8: C2 BB)
precedes = '«', -- LEFT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00AB, UTF-8: C2 AB)
-- tab = ' ', -- '▷─' WHITE RIGHT-POINTING TRIANGLE (U+25B7, UTF-8: E2 96 B7) + BOX DRAWINGS HEAVY TRIPLE DASH HORIZONTAL (U+2505, UTF-8: E2 94 85)
trail = '', -- BULLET (U+2022, UTF-8: E2 80 A2)
space = ' ',
tab = '<->'
}
if vim.fn.executable('rg') > 0 then opt.fillchars = {
vim.o.grepprg = [[rg --glob "!.git" --no-heading --vimgrep --follow $*]] diff = '',
end eob = ' ', -- NO-BREAK SPACE (U+00A0, UTF-8: C2 A0) to suppress ~ at EndOfBuffer
vert = '', -- window border when window splits vertically ─ ┴ ┬ ┤ ├ ┼
msgsep = '',
fold = '·', -- MIDDLE DOT (U+00B7, UTF-8: C2 B7)
foldopen = '',
foldsep = '',
foldclose = ''
}
-- Use in vertical diff mode, blank lines to keep sides aligned, Ignore whitespace changes -- Use in vertical diff mode, blank lines to keep sides aligned, Ignore whitespace changes
opt.diffopt = vim.opt.diffopt opt.diffopt = vim.opt.diffopt
@@ -99,6 +77,10 @@ opt.shortmess = {
W = true, -- Don't show [w] or written when writing W = true, -- Don't show [w] or written when writing
} }
if vim.fn.executable('rg') > 0 then
vim.o.grepprg = [[rg --glob "!.git" --no-heading --vimgrep --follow $*]]
end
-- ignore when autocompleting -- ignore when autocompleting
opt.wildignore = { opt.wildignore = {
'*.aux', '*.out', '*.toc', '*.o', '*.obj', '*.aux', '*.out', '*.toc', '*.o', '*.obj',
@@ -108,9 +90,6 @@ opt.wildignore = {
'.lock', '.DS_Store', 'tags.lock' '.lock', '.DS_Store', 'tags.lock'
} }
-- vim-test
g['test#strategy'] = 'asyncrun_background'
-- CtrlSF -- CtrlSF
g.ctrlsf_ackprg = 'rg' g.ctrlsf_ackprg = 'rg'
g.ctrlsf_regex_pattern = 1 g.ctrlsf_regex_pattern = 1
@@ -123,3 +102,5 @@ g.ctrlsf_mapping = {
next = 'n', next = 'n',
prev = 'N', prev = 'N',
} }
g.ruby_host_prog = 'asdf exec neovim-ruby-host'