Skip to content

Instantly share code, notes, and snippets.

View ChHaeni's full-sized avatar

Christoph Häni ChHaeni

View GitHub Profile
@ChHaeni
ChHaeni / r-spaces.md
Last active April 19, 2024 14:04
Vim mapping to fix missing spaces in R code

Add the function shown in the r-spaces.vim file to your .vimrc file.

A possible mapping could be:

" mapping to fix code in normal mode (with motion: e.g. <leader>ip)
nmap <silent> <leader>x :set opfunc=FixFormatting<CR>g@
" mapping to fix a line of code in normal mode
nnoremap <silent> <leader>xx :normal <leader>x_<CR>
" mapping to fix code in visual selection
@ChHaeni
ChHaeni / git-diff-rdata.md
Last active March 23, 2023 13:16
git diff R data

Introduction

This gist describes a possible way to show diffs of R data files (files with extension e.g. .rds, .RData, .rda, ...) by reading the data into a temporary R session and converting the R object(s) in a "diffable" way to text output.

The following is required:

  • Rscript executable can be found in the $PATH

Integrating git status in lualine

Introduction

This gist shows a possible way how to integrate the status of the buffer related repository into the neovim plugin lualine.

The git status is indicated in the lower left corner of the screenshot, indicating (1 commit ahead, 1 staged, 1 modified and 1 untracked file):

I just started using lua, so the way how the code below works can certainly be improved.

@ChHaeni
ChHaeni / .Rprofile
Last active July 10, 2024 11:21
My Rprofile tweaks
## vim: ft=r
if (interactive()) {
## rprofile environment ----------------------------------------
# to be attached to search path
rprofile_env <- environment()
# # get attached packages for "restart"