parent
30d476768f
commit
c6c489fc71
@ -1,7 +1,10 @@
|
|||||||
if !has('nvim')
|
" f5 runs the current project
|
||||||
nnoremap <buffer> <C-]> :ALEGoToDefinition<CR>
|
nmap <F5> :!clear<CR>:!cargo run -q<CR>
|
||||||
endif
|
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
|
# items in the [home] section are copied into the home directory with the same
|
||||||
# relative location as they appear in the dotfiles repo
|
# relative location as they appear in the dotfiles repo
|
||||||
[home]
|
[home]
|
||||||
files=
|
files:
|
||||||
# sync vim plugin directories but not all of .vim
|
# sync vim plugin directories but not all of .vim
|
||||||
.vim/ftplugin
|
.vim/ftplugin
|
||||||
.vim/pack
|
.vim/pack
|
||||||
|
|
||||||
# individual files to sync
|
# individual files to sync
|
||||||
.bash_profile
|
.bash_profile
|
||||||
.bashrc
|
.bashrc
|
||||||
.screenrc
|
.vimrc
|
||||||
.tmux.conf
|
|
||||||
.vimrc
|
cargo-config.toml > .cargo/config.toml
|
||||||
.config/htop/htoprc
|
|
||||||
.config/lazydocker/config.yml
|
[home posix]
|
||||||
|
when: not host.is_windows
|
||||||
# items in map.posix define a place where config files will be placed on posix
|
|
||||||
# systems relative to the user's home directory
|
files:
|
||||||
[map.posix]
|
.screenrc
|
||||||
nvim/init.vim=.config/nvim/init.vim
|
.tmux.conf
|
||||||
scripts/winmode=bin/winmode
|
.config/lazydocker/config.yml
|
||||||
|
.config/htop/htoprc
|
||||||
# items in the map.windows section defines a place where config files will be
|
|
||||||
# placed on windows, relative to the user's home directory
|
nvim/init.vim > .config/nvim/init.vim
|
||||||
[map.windows]
|
|
||||||
.vimrc=AppData/Local/nvim/init.vim
|
[home wsl]
|
||||||
Vundle.vim=AppData/Local/nvim/bundle/Vundle.vim
|
when: host.is_wsl
|
||||||
.vim/ftplugin=AppData/Local/nvim/ftplugin
|
|
||||||
packer.nvim=AppData/Local/nvim-data/site/pack/packer/start/packer.nvim
|
files:
|
||||||
nvim/lua=AppData/Local/nvim/lua
|
scripts/winmode > bin/winmode
|
||||||
cargo-config.toml=.cargo/config.toml
|
|
||||||
|
[link-files AppData]
|
||||||
[cargo:gitui]
|
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:
|
from . import host
|
||||||
def __init__(self, label = None):
|
from .linker import Linker
|
||||||
self.label = label
|
|
||||||
|
|
||||||
@classmethod
|
class Home:
|
||||||
def from_name(cls, name):
|
resource_name = 'home'
|
||||||
"""
|
|
||||||
Builds a Home struct from a given name
|
|
||||||
"""
|
|
||||||
if name.startswith('home'):
|
|
||||||
label = name.removeprefix('home').strip()
|
|
||||||
return cls(label)
|
|
||||||
return None
|
|
||||||
|
|
||||||
def parse_section(self, section):
|
def __init__(self, label, section):
|
||||||
mapping = {
|
self.label = label or None
|
||||||
'files': self.parse_files
|
self.parse_files(section.get('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 parse_files(self, text):
|
def parse_files(self, text):
|
||||||
|
self.files = []
|
||||||
lines = [s for s in text.splitlines() if s]
|
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):
|
def __repr__(self):
|
||||||
if self.label:
|
if self.label:
|
||||||
return f'<Home: {self.label}>'
|
return f'<Home: {self.label}>'
|
||||||
return '<Home>'
|
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