- color scheme
- dracula - https://draculatheme.com/
- tmux
- terminal
- vim
- using plug (vim), tpm (tmux), and a json file for windows terminal
- dracula - https://draculatheme.com/
- terminal
- i use bash, you can use zsh, its all mostly applicable
- fuzzy learning cd: https://github.com/rupa/z
- z proj, takes you to /some/deep/directory/project
- tmux
- not required if you prefer using your terminals built-in windowing scheme
- i use it to have consistent keybinds for switching between windows and tabs
- detach/attach are nice for saving sessions
- vim
- basic set of motions
- useful motions
- h, j, k, l
- ciw, ci(, ci{
- viw, shift-v, ctrl-v, =
- f{c}, F{c}
- :line-number
- G, gg
- ctrl-d, ctrl-u
- /search
- I, i, o, O, A
- :w, :q
- fuzzy file open for vim: https://github.com/kien/ctrlp.vim
- :Make and :Dispatch (build & run) https://github.com/tpope/vim-dispatch
- try built in :make (lower case) to see what the differences are
- vim quickfix window via :Make
- ctrl-w ctrl-w toggles between windows
- enter or :cc takes you to error
- :cn goes to next error, :cp goes to prev
- or just hjkl in the quickfix window and hit enter
- optional but nice
- vim plugin manager: https://github.com/junegunn/vim-plug
- debugger
- gdb over lldb for me for now due to default "visual" support
- lldb equivalent to gdb tui can be whipped together with https://github.com/snare/voltron
- lldb built-in tui is not that easy to use and feels wonky to me
- gdb tui (text user interface) mode (tui enable, layout src/asm/regs)
- mvp gdb commands
- tui enable
- layout src
- layout asm
- layout reg
- b {func/source:line} - breakpoint
- delete breakpoints
- n - step over
- s - step in, si - step instruction for asm
- p {var}, ptype {var} - print variable or variable type info
- display {var} - show variable on every step
- r - restart/run
- build
- for smaller or scratch project: g++/clang++ directly
- for larger project: cmake or bazel
- cmake (and im sure bazel) works great with :Make and vim quickfix
- advanced & extra
- clang formatter - stop arguing about code formatting rules
- google test - https://github.com/google/googletest - unit testing for c++
- google benchmark - https://github.com/google/benchmark - a micro benchmarking library
- clang sanitizers
- example: https://clang.llvm.org/docs/MemorySanitizer.html
- need to build libc++ and clang from source https://github.com/llvm/llvm-project
- they have a nice CMake build, its not that bad
- need to link to libc++ as std library, load appropriate headers for std library
- more instructions here: https://github.com/google/sanitizers/wiki/MemorySanitizerLibcxxHowTo1
- DONT RUN SCRIPTS FROM HERE, but you can examine! https://github.com/jmoyers/dotfiles
Last active
June 23, 2023 17:00
-
-
Save jmoyers/de19d4a6050dcfe67d110782346496ce to your computer and use it in GitHub Desktop.
Get up and running with a terminal, vim, and c++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" be iMproved, required | |
set nocompatible | |
" you want emojis and crap like that, right? | |
set encoding=utf-8 | |
" linux yank to clipboard, paste from clipboard | |
" its different per platform :-( | |
set clipboard=unnamedplus | |
" Allows you to :e file automplete in subdirectories | |
set path+=** | |
set wildmenu | |
" Stops ctrlp from going into git and node_moduls folders | |
let g:ctrlp_custom_ignore = '\.git\|node_modules' | |
" Allows directory/project specific vimrc | |
set exrc | |
set secure | |
call plug#begin() | |
Plug 'ctrlpvim/ctrlp.vim' | |
Plug 'rhysd/vim-clang-format' | |
Plug 'tpope/vim-dispatch' | |
Plug 'dracula/vim', {'as': 'dracula'} | |
call plug#end() | |
colorscheme dracula |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" clang | |
" set makeprg=clang++\ \-Wall\ -Werror\ -Wpedantic\ \-fstandalone-debug\ -std=c++17\ -D_GLIBCXX_DEBUG\ -g\ -o\ build/%<\ % | |
" CMake | |
" let &makeprg = "cd build/debug && make -j 16" | |
" note 16 is hardware concurrency for build | |
" make does an "out of tree build," thats why we cd into a diff directory | |
" this assumes you've run cmake ../.. inside build/debug ahead of time to generate the makefile | |
" gcc | |
set makeprg=g++\ \-Wall\ -Werror\ -Wpedantic\ -std=c++17\ -g\ -o\ build/%<\ % |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set disassembly-flavor intel | |
set print pretty on | |
tui enable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unbind C-b | |
set-option -g prefix C-a | |
bind-key C-a send-prefix | |
set -g mouse on | |
bind h select-pane -L | |
bind j select-pane -D | |
bind k select-pane -U | |
bind l select-pane -R | |
# magic vodoo for true color vim inside tmux | |
set -g default-terminal 'xterm-256color' | |
# List of plugins | |
set -g @plugin 'tmux-plugins/tpm' | |
set -g @plugin 'tmux-plugins/tmux-sensible' | |
set -g @plugin 'dracula/tmux' | |
# Other examples: | |
# set -g @plugin 'github_username/plugin_name' | |
# set -g @plugin '[email protected]:user/plugin' | |
# set -g @plugin '[email protected]:user/plugin' | |
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) | |
run '~/.tmux/plugins/tpm/tpm' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# here be an example medium sized CMakeLists.txt (the backbone of a CMake project) | |
# this is for a node addon/electron project I was working on, so there are some bits specific to that | |
# specify minimum version of cmake required | |
cmake_minimum_required(VERSION 3.5) | |
# name the project, semver version | |
project(combat VERSION 0.0.1) | |
# any -D flags you pass to your compiler for #define #ifdef type code | |
# this particular line not required for something that isn't a node c++ addon | |
add_definitions(-DNAPI_VERSION=3) | |
# link to libc++ | |
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++") | |
# we want c++17, libc++, to use clang memory sanitizer and to track the origin of the memory issues | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -stdlib=libc++ -fsanitize=memory -fsanitize-memory-track-origins") | |
# header include directories, linking against custom build of libc++ and node-addon-api | |
include_directories( | |
${PROJECT_SOURCE_DIR}/include | |
${PROJECT_SOURCE_DIR}/node_modules/node-addon-api | |
/usr/include/nodejs/src | |
/home/jmoyers/dev/llvm-project/build/include | |
) | |
# library search directory | |
link_directories( | |
/home/jmoyers/dev/llvm-project/build/lib | |
) | |
# link against pthread for c++ standard library thread classes on linux and c++abi for libc++ | |
link_libraries(pthread c++abi) | |
# create a shared library target from the source list, cmakejs is a tool for using cmake with | |
# node addons, safe to ignore. it adds a source list that lets you skip using gyp tool | |
add_library(combat_addon SHARED src/main.cpp ${CMAKE_JS_SRC}) | |
# add a static library with these source files | |
add_library(combat_lib | |
include/logs.hpp | |
include/pool.hpp | |
) | |
# set target specific build properties. these things generally | |
# change compiler flags, sometimes do other target specific things | |
# CXX_STANDARD is the modern CMake way to set -std=c++17 etc | |
# PREFIX/SUFFIX stuff is node specific, they want their addon libraries to | |
# end in .node | |
set_target_properties(combat_addon PROPERTIES | |
PREFIX "" | |
SUFFIX ".node" | |
CXX_STANDARD 17 | |
LINKER_LANGUAGE CXX | |
) | |
set_target_properties(combat_lib PROPERTIES | |
CXX_STANDARD 17 | |
LINKER_LANGUAGE CXX | |
) | |
# add subdirectories, which INCLUDE child CMakeLists.txt | |
add_subdirectory(test) | |
add_subdirectory(benchmarks) | |
# these are literally cloned versions of google test and google benchmark. we link | |
# against them inside the tests/ and benchmarks/ subprojects | |
add_subdirectory(vendor/googletest) | |
add_subdirectory(vendor/benchmark) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment