diff --git a/bash/.bashrc b/bash/.bashrc index c39fd23..acd6468 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -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' diff --git a/vim/.config/nvim/lua/mappings.lua b/vim/.config/nvim/lua/mappings.lua index 2382bbf..75ae419 100644 --- a/vim/.config/nvim/lua/mappings.lua +++ b/vim/.config/nvim/lua/mappings.lua @@ -69,8 +69,8 @@ nmap('gb',':Git blame') nmap('a', ':A') -- test -nmap('r', function() os.execute("tmux send-keys -t '{down-of}' 'bundle exec rspec '" .. vim.fn.expand("%") .. " Enter") end) -nmap('R', function() os.execute("tmux send-keys -t '{down-of}' 'bundle exec rspec .' Enter") end) +nmap('r', function() os.execute("tmux send-keys -t '{down-of}' './bin/rspec '" .. vim.fn.expand("%") .. " Enter") end) +nmap('R', function() os.execute("tmux send-keys -t '{down-of}' './bin/rspec .' Enter") end) -- CtrlSF nmap('', 'CtrlSFPrompt') diff --git a/vim/.config/nvim/lua/plugins/lsp.lua b/vim/.config/nvim/lua/plugins/lsp.lua index 50e0cf4..c722d15 100644 --- a/vim/.config/nvim/lua/plugins/lsp.lua +++ b/vim/.config/nvim/lua/plugins/lsp.lua @@ -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() diff --git a/vim/.config/nvim/lua/plugins/telescope.lua b/vim/.config/nvim/lua/plugins/telescope.lua index ded14ad..53fa990 100644 --- a/vim/.config/nvim/lua/plugins/telescope.lua +++ b/vim/.config/nvim/lua/plugins/telescope.lua @@ -8,43 +8,43 @@ function M.setup() end function M.config() - local telescope = require 'telescope' + 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', - }, - }, - } + 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') + -- pcall(require('telescope').load_extension, 'fzf') + -- Enable telescope fzf native, if installed + telescope.load_extension('fzf') end -- Telescope diff --git a/vim/.config/nvim/lua/settings.lua b/vim/.config/nvim/lua/settings.lua index 2f761aa..3854c7c 100644 --- a/vim/.config/nvim/lua/settings.lua +++ b/vim/.config/nvim/lua/settings.lua @@ -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'