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-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 l='exa'
alias ls='exa'

View File

@@ -69,8 +69,8 @@ nmap('<leader>gb',':Git blame<CR>')
nmap('<leader>a', ':A<CR>')
-- 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}' 'bundle exec rspec .' 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}' './bin/rspec .' Enter") end)
-- CtrlSF
nmap('<C-f>', '<Plug>CtrlSFPrompt')

View File

@@ -9,27 +9,80 @@ end)
require('mason').setup({})
require('mason-lspconfig').setup({
ensure_installed = {},
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.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()

View File

@@ -8,7 +8,7 @@ function M.setup()
end
function M.config()
local telescope = require 'telescope'
local telescope = require('telescope')
telescope.setup {
defaults = {

View File

@@ -1,10 +1,7 @@
local cmd, fn, opt, g = vim.cmd, vim.fn, vim.opt, vim.g
local command = vim.api.nvim_create_user_command
local cmd, opt, g = vim.cmd, vim.opt, vim.g
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.completeopt = {'menu', 'menuone', 'noselect'}
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.clipboard = 'unnamedplus' -- Share clipboard with the OS
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.lazyredraw = true -- Do not redraw while running macros
opt.showmatch = true -- Show matching braces
@@ -60,17 +25,30 @@ opt.writebackup = false -- No backups
opt.swapfile = false -- No backups
opt.mouse = 'a' -- Support mouse (for proper mouse highlight)
opt.list = true -- List mode
opt.listchars = { trail = '·', tab = '->' }
opt.timeoutlen = 1000 -- Delay for mappings
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.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
vim.o.grepprg = [[rg --glob "!.git" --no-heading --vimgrep --follow $*]]
end
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 = ''
}
-- Use in vertical diff mode, blank lines to keep sides aligned, Ignore whitespace changes
opt.diffopt = vim.opt.diffopt
@@ -99,6 +77,10 @@ opt.shortmess = {
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
opt.wildignore = {
'*.aux', '*.out', '*.toc', '*.o', '*.obj',
@@ -108,9 +90,6 @@ opt.wildignore = {
'.lock', '.DS_Store', 'tags.lock'
}
-- vim-test
g['test#strategy'] = 'asyncrun_background'
-- CtrlSF
g.ctrlsf_ackprg = 'rg'
g.ctrlsf_regex_pattern = 1
@@ -123,3 +102,5 @@ g.ctrlsf_mapping = {
next = 'n',
prev = 'N',
}
g.ruby_host_prog = 'asdf exec neovim-ruby-host'