parent
30d476768f
commit
c6c489fc71
@ -1,7 +1,10 @@
|
||||
if !has('nvim')
|
||||
nnoremap <buffer> <C-]> :ALEGoToDefinition<CR>
|
||||
endif
|
||||
" f5 runs the current project
|
||||
nmap <F5> :!clear<CR>:!cargo run -q<CR>
|
||||
nmap <S-F5> :!clear<CR>:!cargo run<CR>
|
||||
|
||||
nnoremap <F5> :Cargo run<CR>
|
||||
" ctrl-f5 lets you run the current program but prompts you for the cli args
|
||||
nmap <C-F5> :!clear<CR>:!cargo run --
|
||||
|
||||
let g:rustfmt_autosave = 1
|
||||
nmap <F6> :!clear<CR>:!cargo run<CR>
|
||||
nmap <F7> :!clear<CR>:!cargo check<CR>
|
||||
nmap <F8> :!clear<CR>:!cargo test<CR>
|
||||
|
@ -1,34 +1,46 @@
|
||||
# items in the [home] section are copied into the home directory with the same
|
||||
# relative location as they appear in the dotfiles repo
|
||||
[home]
|
||||
files=
|
||||
# sync vim plugin directories but not all of .vim
|
||||
.vim/ftplugin
|
||||
.vim/pack
|
||||
|
||||
# individual files to sync
|
||||
.bash_profile
|
||||
.bashrc
|
||||
.screenrc
|
||||
.tmux.conf
|
||||
.vimrc
|
||||
.config/htop/htoprc
|
||||
.config/lazydocker/config.yml
|
||||
|
||||
# items in map.posix define a place where config files will be placed on posix
|
||||
# systems relative to the user's home directory
|
||||
[map.posix]
|
||||
nvim/init.vim=.config/nvim/init.vim
|
||||
scripts/winmode=bin/winmode
|
||||
|
||||
# items in the map.windows section defines a place where config files will be
|
||||
# placed on windows, relative to the user's home directory
|
||||
[map.windows]
|
||||
.vimrc=AppData/Local/nvim/init.vim
|
||||
Vundle.vim=AppData/Local/nvim/bundle/Vundle.vim
|
||||
.vim/ftplugin=AppData/Local/nvim/ftplugin
|
||||
packer.nvim=AppData/Local/nvim-data/site/pack/packer/start/packer.nvim
|
||||
nvim/lua=AppData/Local/nvim/lua
|
||||
cargo-config.toml=.cargo/config.toml
|
||||
|
||||
[cargo:gitui]
|
||||
files:
|
||||
# sync vim plugin directories but not all of .vim
|
||||
.vim/ftplugin
|
||||
.vim/pack
|
||||
|
||||
# individual files to sync
|
||||
.bash_profile
|
||||
.bashrc
|
||||
.vimrc
|
||||
|
||||
cargo-config.toml > .cargo/config.toml
|
||||
|
||||
[home posix]
|
||||
when: not host.is_windows
|
||||
|
||||
files:
|
||||
.screenrc
|
||||
.tmux.conf
|
||||
.config/lazydocker/config.yml
|
||||
.config/htop/htoprc
|
||||
|
||||
nvim/init.vim > .config/nvim/init.vim
|
||||
|
||||
[home wsl]
|
||||
when: host.is_wsl
|
||||
|
||||
files:
|
||||
scripts/winmode > bin/winmode
|
||||
|
||||
[link-files AppData]
|
||||
when: host.is_windows
|
||||
|
||||
target_root: ~/AppData/Local
|
||||
|
||||
files:
|
||||
nvim/lua
|
||||
|
||||
.vimrc > nvim/init.vim
|
||||
Vundle.vim > nvim/bundle/Vundle.vim
|
||||
.vim/ftplugin > nvim/ftplugin
|
||||
packer.nvim > nvim-data/site/pack/packer/start/packer.nvim
|
||||
|
||||
# [cargo:gitui]
|
||||
|
@ -1,5 +0,0 @@
|
||||
"""
|
||||
prefs is a preferences manager
|
||||
"""
|
||||
|
||||
from .installer import Installer
|
@ -1,33 +1,32 @@
|
||||
class Home:
|
||||
def __init__(self, label = None):
|
||||
self.label = label
|
||||
from . import host
|
||||
from .linker import Linker
|
||||
|
||||
@classmethod
|
||||
def from_name(cls, name):
|
||||
"""
|
||||
Builds a Home struct from a given name
|
||||
"""
|
||||
if name.startswith('home'):
|
||||
label = name.removeprefix('home').strip()
|
||||
return cls(label)
|
||||
return None
|
||||
class Home:
|
||||
resource_name = 'home'
|
||||
|
||||
def parse_section(self, section):
|
||||
mapping = {
|
||||
'files': self.parse_files
|
||||
}
|
||||
for key in section:
|
||||
if fn := mapping.get(key):
|
||||
val = section[key]
|
||||
fn(val)
|
||||
else:
|
||||
raise KeyError(f"Home has no such config key: {key}")
|
||||
def __init__(self, label, section):
|
||||
self.label = label or None
|
||||
self.parse_files(section.get('files', ''))
|
||||
|
||||
def parse_files(self, text):
|
||||
self.files = []
|
||||
lines = [s for s in text.splitlines() if s]
|
||||
print(f" parse_files: {lines}")
|
||||
for line in lines:
|
||||
parts = line.split(">", 2)
|
||||
if len(parts) == 1:
|
||||
pair = (parts[0].strip(), parts[0].strip())
|
||||
else:
|
||||
pair = (parts[0].strip(), parts[1].strip())
|
||||
self.files.append(pair)
|
||||
|
||||
def __repr__(self):
|
||||
if self.label:
|
||||
return f'<Home: {self.label}>'
|
||||
return '<Home>'
|
||||
|
||||
def run(self):
|
||||
linker = Linker(host.dotfiles_root, host.home)
|
||||
for pair in self.files:
|
||||
source_path = host.dotfiles_root / pair[0]
|
||||
target_path = host.home / pair[1]
|
||||
linker.link(source_path, target_path)
|
||||
|
@ -0,0 +1,56 @@
|
||||
import pathlib
|
||||
|
||||
from . import host
|
||||
|
||||
class Linker:
|
||||
"""
|
||||
Linker links files from soome source to some target
|
||||
"""
|
||||
def __init__(self, source_root, target_root):
|
||||
self.source_root = source_root
|
||||
self.target_root = target_root
|
||||
|
||||
def link(self, source_path, target_path):
|
||||
if not source_path.is_absolute():
|
||||
source_path = self.source_root / source_path
|
||||
if not target_path.is_absolute():
|
||||
target_path = self.target_root / target_path
|
||||
|
||||
if not target_path.parent.exists():
|
||||
print("creating missing parent directories for target")
|
||||
parent_dir = target_path.parent
|
||||
parent_dir.mkdir(parents=True)
|
||||
|
||||
print(f"{source_path} -> {target_path}")
|
||||
|
||||
class LinkFiles:
|
||||
resource_name = 'link-files'
|
||||
|
||||
def __init__(self, label, section):
|
||||
self.label = label
|
||||
self.target_root = pathlib.Path(section['target_root']).expanduser()
|
||||
self.source_root = host.dotfiles_root
|
||||
self.parse_files(section.get('files', ''))
|
||||
|
||||
def parse_files(self, text):
|
||||
self.files = []
|
||||
lines = [s for s in text.splitlines() if s]
|
||||
for line in lines:
|
||||
parts = line.split(">", 2)
|
||||
if len(parts) == 1:
|
||||
pair = (parts[0].strip(), parts[0].strip())
|
||||
else:
|
||||
pair = (parts[0].strip(), parts[1].strip())
|
||||
self.files.append(pair)
|
||||
|
||||
def __repr__(self):
|
||||
if self.label:
|
||||
return f'<LinkFiles: {self.label}>'
|
||||
return '<LinkFiles>'
|
||||
|
||||
def run(self):
|
||||
linker = Linker(host.dotfiles_root, self.target_root)
|
||||
for pair in self.files:
|
||||
source_path = pathlib.Path(pair[0])
|
||||
target_path = pathlib.Path(pair[1])
|
||||
linker.link(source_path, target_path)
|
Loading…
Reference in New Issue