Nvim-R recognizes ft automatically, do not need to adjust

This commit is contained in:
jimrothstein 2023-12-04 12:46:56 -08:00
parent 1ec250ecda
commit 3841a30877
4 changed files with 29 additions and 30 deletions

View File

@ -1,32 +1,35 @@
-- [[ Nvim-R ]]
-- NOTES
-- - Nvim-R will detect *.R, *.Rmd, *.qmd files on its own
-- These are 3 distinct file types
-- REF: https://github.com/jalvesaq/Nvim-R/issues/724
-- - "The pattern to recognize chunks of R code in Rmd files is hardcoded in Nvim-R/ftplugin/rmd_nvimr.vim, Nvim-R/R/start_r.vim, R-Vim-runtime/syntax/rmd.vim, and R-Vim-runtime/indent/rmd.vim"
-- - ~/.local/share/nvim/lazy/Nvim-R/
--
vim.cmd([[ let R_args= ['--no-save', '--quiet'] ]]) -- minimize startup
vim.cmd([[ let R_assign=2 ]]) -- underline becomes left arrow
vim.cmd([[ let R_enable_comment=1 ]]) -- toggle comments with xx
-- seems to work
-- vim.cmd([[ let R_filetypes = ['r', 'rmd', 'rrst', 'rnoweb', 'quarto', 'rhelp'] ]])
vim.cmd([[let g:LanguageClient_serverCommands = {
\ 'r': ['R', '--slave', '-e', 'languageserver::run()'],
\ }
]])
vim.cmd([[
" autocmd FileType r x :RStop<CR>
]])
vim.cmd([[
" autocmd BufRead, BufNewFile *.r *.qmd *.rmd setlocal filetype = r
\ 'r': ['R', '--slave', '-e', 'languageserver::run()'],
\ }
]])
vim.cmd([[
function! s:customNvimRMappings()
nmap <buffer> <Leader>sr <Plug>RStart
" imap <buffer> <Leader>sr <Plug>RStart
" vmap <buffer> <Leader>sr <Plug>RStart
" nnoremap <Leader>xxx ":call SendRmdChunkToR('echo', 'down')"
nmap <buffer> <Leader>wwww ":echo 'hi'<CR>"
endfunction
augroup myNvimR
au!
autocmd filetype r call s:customNvimRMappings()
augroup end
]])
" autocmd FileType r x :RStop<CR>
]])
vim.cmd([[
function! s:customNvimRMappings()
nmap <buffer> <Leader>sr <Plug>RStart
" imap <buffer> <Leader>sr <Plug>RStart
" vmap <buffer> <Leader>sr <Plug>RStart
" nnoremap <Leader>xxx ":call SendRmdChunkToR('echo', 'down')"
nmap <buffer> <Leader>wwww ":echo 'hi'<CR>"
endfunction
augroup myNvimR
au!
autocmd filetype r call s:customNvimRMappings()
augroup end
]])

View File

@ -107,8 +107,6 @@ require('lazy').setup({
on_attach = function(bufnr)
vim.keymap.set('n', '<leader>gp', require('gitsigns').prev_hunk,
{ buffer = bufnr, desc = '[G]o to [P]revious Hunk' })
-- jr: next line overrides Nvim-R g next chunk; how to change?
-- vim.keymap.set('n', '<leader>gn', require('gitsigns').next_hunk, { buffer = bufnr, desc = '[G]o to [N]ext Hunk' })
vim.keymap.set('n', '<leader>ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' })
end,
},

View File

@ -137,10 +137,8 @@ local mappings = {
z2 = { '<C-W>pAjunk<esc>', 'other window junk' },
rk = { ':RKill<CR>', 'RKill , but not guaranteed to close terminal' },
-- can not find function
-- rcd = { ':call SendRmdChunktoR("echo", "down")<CR>', 'Chunk Down' },
ck = { ':e ~/.config/kickstart/init.lua<cr>', '[ck] Edit KICKSTART config' },
cs = { ':e ~/.config/kickstart/lua/jim/keymaps.lua<cr>', '[ck] Edit KICKSTART keymaps' },
cr = { ':e ~/.config/kickstart/lua/jim/Nvim-R.lua<cr>', '[cr] Edit Nvim-R config' },
}

View File

@ -36,7 +36,7 @@ vim.o.mouse = 'a'
vim.o.clipboard = 'unnamedplus'
-- Enable break indent (windows)
vim.w.breakindent = true
vim.wo.breakindent = true
-- Hitting <TAB> (experimnetal)
--