shubham-cpp / dotfiles Goto Github PK
View Code? Open in Web Editor NEWConfigs for Programs I use on daily basis
License: GNU General Public License v3.0
Configs for Programs I use on daily basis
License: GNU General Public License v3.0
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
nix = {
extraOptions = ''
experimental-features = nix-command flakes
'';
};
# Bootloader.
boot={
kernelPackages = pkgs.linuxPackages_xanmod_latest;
loader={
systemd-boot.enable = true;
efi={
canTouchEfiVariables = true;
efiSysMountPoint = "/boot/efi";
};
};
};
networking={
hostName = "nixos"; # Define your hostname.
networkmanager.enable = true;
# wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary
# proxy.default = "http://user:password@proxy:port/";
# proxy.noProxy = "127.0.0.1,localhost,internal.domain";
};
# Set your time zone.
time.timeZone = "Asia/Kolkata";
# Select internationalisation properties.
i18n.defaultLocale = "en_IN.utf8";
# Enable the X11 windowing system.
services={
xserver={
enable = true;
# Enable the XFCE Desktop Environment.
displayManager.lightdm.enable = true;
desktopManager.xfce.enable = true;
# Configure keymap in X11
layout = "us";
xkbVariant = "";
};
printing.enable = true;
pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
wireplumber.enable = true;
# If you want to use JACK applications, uncomment this
#jack.enable = true;
# use the example session manager (no others are packaged yet so this is enabled by default,
# no need to redefine it in your config for now)
#media-session.enable = true;
};
};
# Enable sound with pipewire.
sound.enable = true;
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.sp = {
isNormalUser = true;
description = "Shubham Pawar";
extraGroups = [ "networkmanager" "wheel" ];
};
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# List packages installed in system profile. To search, run:
# $ nix search wget
environment={
variables = {
EDITOR = "nvim";
VISUAL = "nvim";
};
systemPackages = with pkgs; [
vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
wget curl
firefox
];
};
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# List services that you want to enable:
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It‘s perfectly fine and recommended to leavecatenate(variables, "bootdev", bootdev)
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.05"; # Did you read the comment?
}
{
config,
pkgs,
...
}: {
# Home Manager needs a bit of information about you and the
# paths it should manage.
home = {
username = "sp";
homeDirectory = "/home/sp";
stateVersion = "22.05";
sessionVariables = {
BROWSER = "firefox";
TERMINAL = "alacritty";
EDITOR = "nvim";
};
};
home.packages = with pkgs; [
btop
alacritty
nixfmt
rnix-lsp
alejandra
ksuperkey
xfce.xfce4-whiskermenu-plugin
rofi
rofi-emoji
neovim
gnome.file-roller
exa
fd
ripgrep
fzf
bat
vifm-full
lf
ranger
xclip
];
programs.vscode = {
enable = true;
package = pkgs.vscodium;
extensions = with pkgs.vscode-extensions; [
vscodevim.vim
streetsidesoftware.code-spell-checker
pkief.material-icon-theme
naumovs.color-highlight
mskelton.one-dark-theme
jnoortheen.nix-ide
tabnine.tabnine-vscode
kamadorueda.alejandra
];
};
gtk = {
cursorTheme.package = pkgs.nordzy-cursor-theme;
iconTheme.package = pkgs.vimix-icon-theme; #qogir-icon-theme;
theme.package = pkgs.qogir-theme;
};
qt = {
enable = true;
platformTheme = "gtk";
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}
use({
"iamcco/markdown-preview.nvim",
run = "cd app && yarn install",
ft = { "markdown" },
setup = function()
vim.g.mkdp_refresh_slow = 1
end,
})
use({
"mzlogin/vim-markdown-toc",
after = "markdown-preview.nvim",
})
use({
"danymat/neogen",
config = function()
require("neogen").setup({})
end,
cmd = { "Neogen" },
})
use({
"EdenEast/nightfox.nvim",
event = "VimEnter",
disable = false,
config = function()
-- Options: deep | dark | darker | warm | warmer
require("nightfox").setup({
options = {
transparent = true,
styles = {
comments = "italic",
keywords = "italic",
functions = "none",
strings = "none",
variables = "none",
},
},
groups = {
QuickScopePrimary = { fg = "pallet.orange", fmt = "underline,italic" },
QuickScopeSecondary = { fg = "pallet.cyan", fmt = "underline,italic" },
},
})
vim.cmd("colorscheme duskfox")
end,
})
Though look for fmt, that doesn't work.
(use-package modus-themes
:init
(setq modus-themes-italic-constructs t
modus-themes-bold-constructs nil
modus-themes-region '(bg-only no-extend)
modus-themes-links '(italic bold background)
modus-themes-hl-line '(accented intense))
(modus-themes-load-themes)
:config
(modus-themes-load-vivendi))
(use-package dashboard
:preface
(defun my/dashboard-banner ()
"Set a dashboard banner including information on package initialization
time and garbage collections."""
(setq dashboard-banner-logo-title
(format "Emacs ready in %.2f seconds with %d garbage collections."
(float-time (time-subtract after-init-time before-init-time)) gcs-done)))
:custom
(dashboard-startup-banner 'logo)
(dashboard-items '((recents . 5)
(bookmarks . 5)
(projects . 5)
(agenda . 5)
(registers . 5)))
;; (dashboard-projects-backend 'project-el)
;; (dashboard-projects-switch-function 'project-switch-project)
(dashboard-set-heading-icons t)
(dashboard-set-file-icons t)
:config
(dashboard-setup-startup-hook)
:hook ((doom-modeline-mode . dashboard-refresh-buffer)
(dashboard-mode . my/dashboard-banner)))
Vscode or Neovim, why not both
{
// "workbench.colorTheme": "One Dark Pro",
// "workbench.iconTheme": "material-icon-theme",
"tabnine.experimentalAutoImports": true,
"files.trimTrailingWhitespace": true,
"editor.bracketPairColorization.independentColorPoolPerBracketType": true,
"editor.guides.bracketPairs": "active",
"editor.quickSuggestions": {
"other": true,
"comments": true,
"strings": true
},
"workbench.colorCustomizations": {
"editorCursor.foreground": "#e75c34", // "#d470cb",
"editorCursor.background": "#fff0cb",
"statusBar.background": "#3c3c3c"
},
"editor.suggest.localityBonus": true,
"editor.suggestSelection": "recentlyUsedByPrefix",
"editor.wordBasedSuggestionsMode": "allDocuments",
"editor.fontSize": 14,
"editor.fontFamily": "'FiraCode NFM','JetBrainsMono NFM','Hack NFM',MonoLisa,'Cascadia Code', Consolas, 'Courier New', monospace",
"vim.useSystemClipboard": true,
"editor.wordWrap": "on",
"editor.fontLigatures": true,
"extensions.experimental.affinity": {
//makes neovim faster, apparently
"asvetliakov.vscode-neovim": 1
},
"vim.foldfix": true,
"vim.highlightedyank.enable": true,
"vim.changeWordIncludesWhitespace": true,
"vim.easymotion": true,
"vim.gdefault": true,
"vim.leader": "<space>",
"vim.replaceWithRegister": true,
"vim.smartRelativeLine": true,
// "vim.sneak": true,
// "vim.sneakReplacesF": true,
"vim.visualstar": true,
"vim.whichwrap": "b,s,[,],<,>",
"vim.operatorPendingModeKeyBindingsNonRecursive": [
{
"before": ["("],
"after": ["i("]
}
],
"vim.visualModeKeyBindingsNonRecursive": [
{
"before": ["p"],
"after": ["p", "g", "v", "y"]
},
{
"before": ["c"],
"after": ["\"", "_", "c"]
},
{
"before": ["K"],
"commands": ["editor.action.moveLinesUpAction"]
},
{
"before": ["J"],
"commands": ["editor.action.moveLinesDownAction"]
}
],
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["s"],
"after": ["leader", "leader", "2", "s"]
},
{
"before": ["S"],
"after": ["leader", "leader", "leader", "b", "d", "w"]
},
{
"before": ["Y"],
"after": ["y", "$"]
},
{
"before": ["d", "l"],
"after": ["\"", "_", "d", "l"]
},
{
"before": ["c"],
"after": ["\"", "_", "c"]
},
{
"before": ["C"],
"after": ["\"", "_", "C"]
},
{
"before": ["g", "s"],
"commands": ["code-runner.run"]
},
{
"before": [",", "W"],
"commands": ["workbench.action.files.saveWithoutFormatting"]
},
{
"before": [",", "w"],
"commands": ["workbench.action.files.save"]
},
{
"before": ["]", "g"],
"commands": ["editor.action.marker.next"]
},
{
"before": ["[", "g"],
"commands": ["editor.action.marker.prev"]
},
{
"before": ["]", "z"],
"commands": ["cSpell.goToNextSpellingIssue"]
},
{
"before": ["]", "Z"],
"commands": ["cSpell.goToNextSpellingIssueAndSuggest"]
},
{
"before": [0],
"after": ["^"]
},
{
"before": ["C-n"],
"commands": ["extension.advancedNewFile"]
},
{
"before": ["C-b"],
"commands": ["workbench.action.toggleSidebarVisibility"]
},
{
"before": ["C-j"],
"commands": ["workbench.action.terminal.toggleTerminal"]
},
{
"before": ["C-l"],
"after": ["<C-w>", "l"]
},
{
"before": ["C-h"],
"after": ["<C-w>", "h"]
},
{
"before": ["i"],
"after": ["z", "z", "i"]
},
{
"before": ["I"],
"after": ["z", "z", "I"]
},
{
"before": ["a"],
"after": ["z", "z", "a"]
},
{
"before": ["A"],
"after": ["z", "z", "A"]
},
{
"before": ["K"],
"after": ["g", "h"]
},
{
"before": ["C-w", "O"],
"commands": ["workbench.action.closeOtherEditors"]
}
],
"vim.visualModeKeyBindings": [
{
"before": [">"],
"commands": ["editor.action.indentLines"]
},
{
"before": ["<"],
"commands": ["editor.action.outdentLines"]
}
],
"terminal.integrated.copyOnSelection": true,
"terminal.integrated.cursorBlinking": true,
"terminal.integrated.fontSize": 16,
"editor.cursorSurroundingLines": 8,
"eslint.format.enable": true,
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "vscode.css-language-features"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[vue]": {
"editor.defaultFormatter": "Vue.volar",
"editor.tabSize": 2
},
"[javascriptreact]": {
"editor.tabSize": 2
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2
},
"[scss]": {
"editor.defaultFormatter": "vscode.css-language-features"
},
"volar.autoCompleteRefs": true,
"volar.codeLens.scriptSetupTools": true,
"volar.vueserver.useSecondServer": true,
// "editor.stickyScroll.enabled": true,
"terminal.integrated.smoothScrolling": true,
"editor.wordSeparators": "`~!@#$%^&*()=+[{]}\\|;:'\",.<>/?",
"path-intellisense.autoTriggerNextSuggestion": true,
"editor.inlayHints.padding": true,
// "editor.codeActionsOnSave": {
// "source.fixAll": true,
// "source.organizeImports": true
// },
"files.eol": "\n",
"workbench.iconTheme": "material-icon-theme",
"[typescriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"todo-tree.general.tags": [
"BUG",
"HACK",
"FIXME",
"TODO",
"XXX",
"[ ]",
"[x]",
"DOUBT",
"REFACTOR",
],
"todo-tree.general.tagGroups": {
"FIXME": ["FIXME", "FIXIT", "FIX"],
"DOUBT": ["DOUBT", "ASK", "QUESTION", "REF"]
},
"todo-tree.highlights.customHighlight": {
"DOUBT": {
"foreground": "#ffeee1",
"background": "#a65288",
"type": "tag-and-comment"
}
},
"todo-tree.highlights.useColourScheme": true,
"code-runner.clearPreviousOutput": true,
// "code-runner.runInTerminal": true,
"code-runner.saveFileBeforeRun": true,
"editor.minimap.autohide": true,
"editor.minimap.scale": 2,
"workbench.sideBar.location": "right",
"workbench.editor.wrapTabs": true,
"window.menuBarVisibility": "compact",
"vim.enableNeovim": true,
"editor.lineNumbers": "relative"
}
" Basic settings
set relativenumber
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
set autoindent
set smartindent
set mouse=a
set nocompatible
set ignorecase
set smartcase
set path+=**
set clipboard+=unnamedplus
set iskeyword+=-
set wildmenu
syntax enable
let g:mapleader = " "
" Trigger a highlight in the appropriate direction when pressing these keys:
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
" let g:qs_lazy_highlight = 1
function! Cond(Cond, ...)
let opts = get(a:000, 0, {})
return a:Cond ? opts : extend(opts, { 'on': [], 'for': [] })
endfunction
" Plugging plugins
call plug#begin()
Plug 'kana/vim-textobj-user'
Plug 'kana/vim-textobj-entire'
Plug 'kana/vim-textobj-line'
" Plug 'michaeljsmith/vim-indent-object'
" Plug 'christoomey/vim-titlecase'
Plug 'tpope/vim-repeat'
Plug 'sheerun/vim-polyglot'
Plug 'sainnhe/everforest'
Plug 'tpope/vim-surround'
Plug 'junegunn/vim-easy-align'
Plug 'tpope/vim-commentary'
Plug 'wellle/targets.vim'
Plug 'unblevable/quick-scope'
Plug 'svermeulen/vim-subversive'
Plug 'Darazaki/indent-o-matic'
Plug 'monaqa/dial.nvim'
call plug#end()
" let g:sandwich#recipes = deepcopy(g:sandwich#default_recipes)
" Color theme configuration
if has('termguicolors')
set termguicolors
endif
set background=dark
let g:everforest_background = 'hard'
let g:everforest_better_performance = 1
colorscheme everforest
if exists('g:vscode')
" VsCode Any
map zh <Cmd>call VSCodeNotify('yo1dog.cursor-trim.lTrimCursor')<CR>
map zl <Cmd>call VSCodeNotify('yo1dog.cursor-trim.rTrimCursor')<CR>
map zi <Cmd>call VSCodeNotify('yo1dog.cursor-trim.trimCursor')<CR>
map ze <Cmd>call VSCodeNotify('scrollLineDown')<CR>
map zy <Cmd>call VSCodeNotify('scrollLineUp')<CR>
map [f <Cmd>call VSCodeNotify('workbench.view.search.focus')<CR>
map ]f <Cmd>call VSCodeNotify('workbench.action.replaceInFiles')<CR>
map gD <Cmd>call VSCodeNotify('editor.action.revealDefinitionAside')<CR>
map gr <Cmd>call VSCodeNotify('editor.action.goToReferences')<CR>
map [s <Cmd>call VSCodeNotify('editor.action.toggleStickyScroll')<CR>
map =< <Cmd>call VSCodeNotify('editor.action.trimTrailingWhitespace')<CR>
map gl <Cmd>call VSCodeNotify('editor.action.openLink')<CR>
xmap gc <Plug>VSCodeCommentary
nmap gc <Plug>VSCodeCommentary
omap gc <Plug>VSCodeCommentary
nmap gcc <Plug>VSCodeCommentaryLine
map <C-d> 15jzz
map <C-u> 15kzz
vnoremap <leader>f <Cmd>call VSCodeNotifyRangePos('editor.action.formatSelection', line("v"), line("."), col("v"), col("."), 1)<CR>
nmap gb <Cmd>call VSCodeNotify('editor.action.addSelectionToNextFindMatch')<cr>
nnoremap <C-Up> <Cmd>call VSCodeNotify('editor.action.insertCursorAbove')<cr>
nnoremap <C-Down> <Cmd>call VSCodeNotify('editor.action.insertCursorBelow')<cr>
nnoremap <C-Right> <Cmd>call VSCodeNotify('workbench.action.nextEditor')<cr>
nnoremap <C-Left> <Cmd>call VSCodeNotify('workbench.action.previousEditor')<cr>
nnoremap <leader>o <Cmd>call VSCodeNotify('workbench.action.openRecent')<CR>
nnoremap ,w <Cmd>call VSCodeNotify('workbench.action.files.save')<cr>
nnoremap ,W <Cmd>call VSCodeNotify('workbench.action.files.saveWithoutFormatting')<cr>
nnoremap gh <Cmd>call VSCodeNotify('editor.action.showHover')<cr>
" VsCode Folding
map za <Cmd>call VSCodeNotify('editor.toggleFold')<CR>
map zC <Cmd>call VSCodeNotify('editor.foldAll')<CR>
map zO <Cmd>call VSCodeNotify('editor.unfoldAll')<CR>
map zp <Cmd>call VSCodeNotify('editor.gotoParentFold')<CR>
nnoremap <C-b> <Cmd>call VSCodeNotify('workbench.action.toggleSidebarVisibility')<cr>
nnoremap <C-j> <Cmd>call VSCodeNotify('workbench.action.terminal.toggleTerminal')<cr>
nnoremap <leader>gg <Cmd>call VSCodeNotify('workbench.view.scm')<cr>
nnoremap <leader>ge <Cmd>call VSCodeNotify('workbench.view.extensions')<cr>
nnoremap <leader>gs <Cmd>call VSCodeNotify('workbench.view.search.toggleVisibility')<cr>
nnoremap <leader>gf <Cmd>call VSCodeNotify('workbench.view.explorer')<cr>
nnoremap <leader>gk <Cmd>call VSCodeNotify('workbench.action.openGlobalKeybindings')<cr>
" VsCode Scrolling
map zl <Cmd>call VSCodeNotify('toggleTypewriter')<CR>
" nnoremap <C-w><C-c> <Cmd>call VSCodeNotify('workbench.action.closeActiveEditor')<CR>k
imap <C-k> <Cmd>call VSCodeNotify('editor.action.insertLineBefore')<CR>
nnoremap <A-h> <Cmd>call VSCodeNotify('workbench.action.previousEditor')<cr>
nnoremap <A-l> <Cmd>call VSCodeNotify('workbench.action.nextEditor')<cr>
else
noremap <C-f> <C-f>zz
noremap <C-b> <C-b>zz
map <C-d> 12jzz
map <C-u> 12kzz
nnoremap zp vaBo^<Esc>
endif
highlight QuickScopePrimary guifg='#afff5f' gui=underline ctermfg=155 cterm=underline
highlight QuickScopeSecondary guifg='#5fffff' gui=underline ctermfg=81 cterm=underline
nmap s <plug>(SubversiveSubstitute)
nmap ss <plug>(SubversiveSubstituteLine)
nmap S <plug>(SubversiveSubstituteToEndOfLine)
nmap 0 ^
nnoremap <Esc> <cmd>nohl<cr>
" nnoremap / /\v
" nnoremap ? ?\v
" vnoremap s <Plug>VSurround
vnoremap c "_c
nnoremap c "_c
nnoremap C "_C
nnoremap dl "_dl
vnoremap <expr> p 'pgv"'.v:register.'y'
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
vnoremap > >gv
vnoremap < <gv
" nnoremap <C-h> <C-w><C-h>
" nnoremap <C-j> <C-w><C-j>
" nnoremap <C-k> <C-w><C-k>
" nnoremap <C-l> <C-w><C-l>
nnoremap <A-j> mz:m+<cr>`z
nnoremap <A-k> mz:m-2<cr>`z
nmap j gj
nmap k gk
nmap <C-a> <Plug>(dial-increment)
nmap <C-x> <Plug>(dial-decrement)
vmap <C-a> <Plug>(dial-increment)
vmap <C-x> <Plug>(dial-decrement)
vmap g<C-a> g<Plug>(dial-increment)
vmap g<C-x> g<Plug>(dial-decrement)
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
onoremap <silent> ie :exec "normal! ggVG"<cr>
onoremap <silent> iv :exec "normal! HVL"<cr>
augroup highlight_yank
autocmd!
autocmd TextYankPost * silent! lua vim.highlight.on_yank { higroup="IncSearch", timeout=100 }
augroup END
lua << EOF
local ok_indent, iom = pcall(require,'indent-o-matic')
if ok_indent then
iom.setup {}
end
local ok_dial, augend = pcall(require,'dial.augend')
if ok_dial then
local webs = {
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.constant.alias.bool,
augend.constant.new{
elements = {"&&", "||"},
word = false,
cyclic = true,
},
augend.constant.new{ elements = {"let", "const"} },
}
local py_lua = {
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.constant.alias.bool,
augend.constant.new{
elements = {"and", "or"},
word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc.
cyclic = true, -- "or" is incremented into "and".
},
}
require("dial.config").augends:register_group{
default = {
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.constant.alias.bool,
augend.constant.new{
elements = {"&&", "||"},
word = false,
cyclic = true,
},
},
vue = webs,
javascript = webs,
javascriptreact = webs,
typescript = webs,
typescriptreact = webs,
lua = py_lua,
python = py_lua,
visual = {
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.date.alias["%Y/%m/%d"],
augend.constant.alias.alpha,
augend.constant.alias.Alpha,
},
}
end
EOF
Change the init.vim to init.lua
b = {
name = "Buffers",
a = { ":badd<space>", "Add", silent = false },
d = { "<cmd>bd<cr>", "Delete" },
n = { "<cmd>bn<cr>", "Next" },
p = { "<cmd>bp<cr>", "Prev" },
},
e = {
name = "Edit",
e = { ':edit <C-r>=expand("%:p:h")<cr>/', "here", silent = false },
v = { ':vnew <C-r>=expand("%:p:h")<cr>/', "in vsplit", silent = false },
t = { ':tabedit <C-r>=expand("%:p:h")<cr>/', "in new tab", silent = false },
},
g = {
name = "Git",
a = { "<cmd>!git add %:p<CR>", "stage current" },
A = { "<cmd>!git add .<CR>", "stage all" },
g = { ":Neogit<cr>" },
h = {
name = "Hunk",
b = { "<cmd>Gitsigns blame_line<cr>", "blame line" },
p = { "<cmd>Gitsigns preview_hunk<cr>", "preview" },
r = { "<cmd>Gitsigns reset_buffer<cr>", "reset buffer" },
l = { "<cmd>Gitsigns reset_hunk<cr>", "reset line" },
-- s ={":Gitsigns preview_hunk" , "stage" },
-- u ={":Gitsigns preview_hunk" , "undo stage" },
q = { "<cmd>Gitsigns setqflist<cr>", "Send Hunks to Qflist" },
},
l = {
name = "Log",
a = { "<cmd>FzfLua git_commits<cr>", "All commits" },
c = { "<cmd>FzfLua git_bcommits<cr>", "Buffer commits" },
},
s = { "<cmd>FzfLua git_status<CR>", "status" },
},
s = {
name = "Session/Switch",
s = { "<cmd>SessionManager save_current_session<cr>", "Save" },
l = { "<cmd>SessionManager load_session<cr>", "Load" },
L = { "<cmd>SessionManager load_last_session<cr>", "Load Last" },
c = { "<cmd>SessionManager load_current_dir_session<cr>", "Load Current dir " },
d = { "<cmd>SessionManager delete_session<cr>", "Delete" },
t = { ":Switch<cr>", "Switch(Toggle true/false)" },
T = { ":SwitchReverse<cr>", "Switch Reverse(Toggle true/false)" },
},
import vCardJs from "vcards-js";
type Version = "2.1" | "3.0" | "4.0";
type Gender = "M" | "F";
type AddressType = "home" | "work";
interface Vcard {
version: Version;
name: {
family: string;
given: string;
middle?: string;
prefix?: string;
suffix?: string;
};
fullName: string;
company?: string;
title?: string;
birthday?: number;
anniversary?: number;
note?: string; // ios
gender?: Gender;
address?: {
type: AddressType;
street?: string;
city?: string;
state?: string;
country?: string;
postalCode?: number; // zipcode
}[];
workPhone?: string;
homePhone?: string;
email?: string;
emailWork?: string;
url?: string;
socialUrls?: {
type: string;
url: string;
}[];
}
const contact = vCardJs();
contact.firstName = "Eric";
contact.middleName = "J";
contact.lastName = "Nesser";
contact.organization = "ACME Corporation";
contact.photo.attachFromUrl(
"https://avatars2.githubusercontent.com/u/5659221?v=3&s=460",
"JPEG"
);
// contact.photo.embedFromFile('qr.png');
contact.workPhone = "312-555-1212";
contact.homePhone = "312-555-1313";
contact.email = "[email protected]";
contact.workEmail = "[email protected]";
contact.birthday = new Date(1985, 0, 1);
contact.title = "Software Developer";
contact.url = "https://github.com/enesser";
contact.note = "Notes on Eric";
contact.anniversary = new Date(2004, 0, 1);
contact.namePrefix = "Mr.";
contact.nameSuffix = "JR";
contact.gender = "M";
contact.homeAddress.label = "Home Address";
contact.homeAddress.street = "123 Main Street";
contact.homeAddress.city = "Chicago";
contact.homeAddress.stateProvince = "IL";
contact.homeAddress.postalCode = "12345";
contact.homeAddress.countryRegion = "United States of America";
contact.workAddress.label = "Work Address";
contact.workAddress.street = "123 Corporate Loop\nSuite 500";
contact.workAddress.city = "Los Angeles";
contact.workAddress.stateProvince = "CA";
contact.workAddress.postalCode = "54321";
contact.workAddress.countryRegion = "United States of America";
contact.socialUrls["facebook"] = "https://...";
contact.socialUrls["linkedIn"] = "https://...";
contact.socialUrls["twitter"] = "https://...";
contact.socialUrls["flickr"] = "https://...";
contact.socialUrls["custom"] = "https://...";
const vcardString = contact.getFormattedString();
const parseVcard = (vcardString: string): Vcard => {
const tmp = vcardString.split(/\r?\n/gi);
const vcardArray = tmp.slice(1, tmp.length - 2);
const obj = {} as Vcard;
for (const line of vcardArray) {
const [k, value] = line.split(":");
const key = k.split(";")[0];
if (key !== "URL" && key !== "X-SOCIALPROFILE") {
if (key === "VERSION") {
obj.version = value as Version;
}
if (key === "FN") {
obj.fullName = value;
}
if (key === "N") {
const name = value.split(";");
obj.name = {
family: name[0],
given: name[1],
middle: name[2] ?? "",
prefix: name[3] ?? "",
suffix: name[4] ?? "",
};
}
if (key === "BDAY" || key === "ANNIVERSARY") {
obj[key === "BDAY" ? "birthday" : "anniversary"] = new Date(
`${value.slice(0, 4)}-${value.slice(4, 6)}-${value.slice(6, 8)}`
).getTime();
}
if (key === "ORG") {
obj.company = value;
}
if (key === "TITLE") {
obj.title = value;
}
if (key === "TEL") {
if (k.includes("WORK,VOICE")) {
obj.workPhone = value;
} else if (k.includes("HOME,VOICE")) {
obj.homePhone = value;
}
}
if (key === "EMAIL") {
if (k.includes("WORK,INTERNET")) {
obj.emailWork = value;
} else if (k.includes("HOME,INTERNET")) {
obj.email = value;
}
}
if (key === "ADR") {
if (obj.address === undefined) {
obj.address = [];
}
console.log(value);
const addr: string[] = value.split(";").filter(Boolean) ?? [];
obj.address.push({
type: k.split("=").at(-1) as AddressType,
street: addr[0] ?? "",
city: addr[1] ?? "",
state: addr[2] ?? "",
postalCode: addr[3] ? parseInt(addr[3], 10) : undefined,
country: addr[4] ?? "",
});
}
} else {
// TODO: handle URL and X-SOCIALPROFILE
const [k, ...value] = line.split(":");
const key = k.split(";");
if (key[0] === "URL") {
obj.url = value.join(":").trim();
} else {
if (obj.socialUrls === undefined) {
obj.socialUrls = [];
}
obj.socialUrls.push({
type: key[key.length - 1].split("=")[1],
url: value.join(":").trim(),
});
}
}
}
return obj;
};
console.log(parseVcard(vcardString));
{
version: '3.0',
fullName: 'Eric J Nesser',
name: {
family: 'Nesser',
given: 'Eric',
middle: 'J',
prefix: 'Mr.',
suffix: 'JR'
},
birthday: 473385600000,
anniversary: 1072915200000,
email: '[email protected]',
emailWork: '[email protected]',
homePhone: '312-555-1313',
workPhone: '312-555-1212',
address: [
{
type: 'HOME',
street: '123 Main Street',
city: 'Chicago',
state: 'IL',
postalCode: 12345,
country: 'United States of America'
},
{
type: 'WORK',
street: '123 Corporate Loop\\nSuite 500',
city: 'Los Angeles',
state: 'CA',
postalCode: 54321,
country: 'United States of America'
}
],
title: 'Software Developer',
company: 'ACME Corporation',
url: 'https://github.com/enesser',
socialUrls: [
{ type: 'facebook', url: 'https://...' },
{ type: 'linkedIn', url: 'https://...' },
{ type: 'twitter', url: 'https://...' },
{ type: 'flickr', url: 'https://...' },
{ type: 'custom', url: 'https://...' }
]
}
Add safety check for BEGIN:VCARD and END:VCARD
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.