diff --git a/bin/install.ps1 b/bin/install.ps1 index 0aa87d8..5b508ec 100644 --- a/bin/install.ps1 +++ b/bin/install.ps1 @@ -33,6 +33,8 @@ Write-Output "Latest PSReadLine" Install-Module -Name PSReadLine -Force # Override default version to get the latest one Write-Output "CompletionPredictor" Install-Module -Name CompletionPredictor +Write-Output "npm" +Install-Module -Name npm-completion @@ -43,13 +45,16 @@ if(!(Get-Command scoop -ErrorAction SilentlyContinue)) { } # install basic scoop apps # import from exported json file -# to update the json file, execute ./bin/scoop_apps/update_scoop_list.ps1 -scoop import .\bin\scoop_apps\scoop_minimal_apps.json +# to update the json file, execute ./bin/windows/scoop_apps/update_scoop_list.ps1 +scoop import .\bin\windows\scoop_apps\scoop_minimal_apps.json # make symbolic links # neovim -New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\init.vim -Target (Resolve-Path .\dotfiles\neovim\init.vim) -Force +New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\init.lua -Target (Resolve-Path .\dotfiles\neovim\init.lua) -Force +New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\plugins.lua -Target (Resolve-Path .\dotfiles\neovim\lua\plugins.lua) -Force +New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\lualine_setup.lua -Target (Resolve-Path .\dotfiles\neovim\lua\lualine_setup.lua) -Force +New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\lsp_client_config.lua -Target (Resolve-Path .\dotfiles\neovim\lua\lsp_client_config.lua) -Force # pwsh New-Item -ItemType SymbolicLink -Path $PROFILE -Target (Resolve-Path .\dotfiles\pwsh\powershell_profile.ps1) -Force New-Item -ItemType SymbolicLink -Path ~\.config\powershell\chezmoi_completion.ps1 -Target (Resolve-Path .\dotfiles\pwsh\chezmoi_completion.ps1) -Force diff --git a/bin/install.sh b/bin/install.sh old mode 100644 new mode 100755 index cabc0ff..792fc31 --- a/bin/install.sh +++ b/bin/install.sh @@ -1 +1,27 @@ -ln -s (pwd)/dotfiles/fish/config.fish ~/.config/fish/config.fish +#!/usr/bin/bash +set -eu + +# ========================================================= +# check executing location +# ========================================================= +if [ ! -d "bin" -a ! -d "dotfiles" ]; then + echo "Wrong execution location" + echo "Please run this script on dotfiles root folder." + exit 1 +fi + + +# ========================================================= +# links +# ========================================================= +mkdir -p ~/.config/fish +ln -sf $(pwd)/dotfiles/fish/config.fish ~/.config/fish/config.fish +ln -sf $(pwd)/dotfiles/starship/starship.toml ~/.config/starship.toml +ln -sf $(pwd)/dotfiles/tmux.conf ~/.tmux.conf + +mkdir -p ~/.config/nvim +ln -sf $(pwd)/dotfiles/neovim/init.lua ~/.config/nvim/init.lua +mkdir -p ~/.config/nvim/lua +ln -sf $(pwd)/dotfiles/neovim/lua/plugins.lua ~/.config/nvim/lua/plugins.lua +ln -sf $(pwd)/dotfiles/neovim/lua/lualine_setup.lua ~/.config/nvim/lua/lualine_setup.lua + diff --git a/bin/install_manjaro.sh b/bin/install_manjaro.sh new file mode 100644 index 0000000..5fa4ca1 --- /dev/null +++ b/bin/install_manjaro.sh @@ -0,0 +1,5 @@ +#!/usr/bin/bash -euo + +# alacritty config +ln -sf (pwd)/dotfiles/alacritty.yml ~/.config/alacritty/alacritty.yml + diff --git a/bin/install_ubuntu.sh b/bin/install_ubuntu.sh new file mode 100644 index 0000000..b11fb91 --- /dev/null +++ b/bin/install_ubuntu.sh @@ -0,0 +1,2 @@ +#!/usr/bin/bash -euo + diff --git a/bin/linux/fisher_plugins.fish b/bin/linux/fisher_plugins.fish new file mode 100755 index 0000000..1595c1b --- /dev/null +++ b/bin/linux/fisher_plugins.fish @@ -0,0 +1,29 @@ +#!/bin/fish + +#========================================================== +# fisher plugin install +#========================================================== + +# check fisher existence +if ! type fisher &>/dev/null + echo "fisher does not exist." + echo "Please install fisher from https://github.com/jorgebucaran/fisher" + echo "" + echo "==Automatic install==" + echo "You can run `curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher` right here" + echo "be sure to check install command on the fisher project homepage." + read -p "echo Install\?(default Y / N):\ " ans + if [ $ans = 'N' ] + return 1 + end + # install script from github page + curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher +end + +fisher update + +# installing packages +fisher install edc/bass +#fisher install jethrokuan/z +fisher install patrickf1/fzf.fish + diff --git a/bin/scoop_apps/scoop_apps.json b/bin/windows/scoop_apps/scoop_apps.json similarity index 100% rename from bin/scoop_apps/scoop_apps.json rename to bin/windows/scoop_apps/scoop_apps.json diff --git a/bin/scoop_apps/scoop_minimal_apps.json b/bin/windows/scoop_apps/scoop_minimal_apps.json similarity index 100% rename from bin/scoop_apps/scoop_minimal_apps.json rename to bin/windows/scoop_apps/scoop_minimal_apps.json diff --git a/bin/scoop_apps/update_scoop_list.ps1 b/bin/windows/scoop_apps/update_scoop_list.ps1 similarity index 100% rename from bin/scoop_apps/update_scoop_list.ps1 rename to bin/windows/scoop_apps/update_scoop_list.ps1 diff --git a/dotfiles/ahk/extra_remaps.ahk b/dotfiles/ahk/extra_remaps.ahk index 1229096..5effd07 100644 --- a/dotfiles/ahk/extra_remaps.ahk +++ b/dotfiles/ahk/extra_remaps.ahk @@ -2,10 +2,10 @@ ; mainly for inputting special characters ; Play/Pause -sc121:: - Send {Media_Play_Pause} - return - +;sc121:: +; Send {Media_Play_Pause} +; return +; ; Henkan/Muhenkan + - -> en, em dash vk1D & vkBD:: diff --git a/dotfiles/ahk/key_remaps.ahk b/dotfiles/ahk/key_remaps.ahk index 3f90df4..70722db 100644 --- a/dotfiles/ahk/key_remaps.ahk +++ b/dotfiles/ahk/key_remaps.ahk @@ -57,12 +57,11 @@ vk1C & d:: Send,{Blind}{PgDn} return +; ========================================== +; include extra key remaps +#Include extra_remaps.ahk ; ========================================== ; HankakuZenkaku to esc sc029:: Send, {Escape} - -; ========================================== -; include extra key remaps -#Include extra_remaps.ahk diff --git a/dotfiles/alacritty.yml b/dotfiles/alacritty.yml new file mode 100644 index 0000000..e8a1ec4 --- /dev/null +++ b/dotfiles/alacritty.yml @@ -0,0 +1,85 @@ +# Alacritty config file + +# Window +window: + decorations: none + opacity: 0.85 + + +# Font +font: + size: 11.0 + +# Color schemes +schemes: + # Campbell (Windows 10 default) + campbell: &campbell + # Default colors + primary: + background: '#0c0c0c' + foreground: '#cccccc' + + # Normal colors + normal: + black: '#0c0c0c' + red: '#c50f1f' + green: '#13a10e' + yellow: '#c19c00' + blue: '#0037da' + magenta: '#881798' + cyan: '#3a96dd' + white: '#cccccc' + + # Bright colors + bright: + black: '#767676' + red: '#e74856' + green: '#16c60c' + yellow: '#f9f1a5' + blue: '#3b78ff' + magenta: '#b4009e' + cyan: '#61d6d6' + white: '#f2f2f2' + # Colors (Iceberg Dark) + iceberg_dark: &iceberg_dark + # Default colors + primary: + background: '#161821' + foreground: '#d2d4de' + + # Normal colors + normal: + black: '#161821' + red: '#e27878' + green: '#b4be82' + yellow: '#e2a478' + blue: '#84a0c6' + magenta: '#a093c7' + cyan: '#89b8c2' + white: '#c6c8d1' + + # Bright colors + bright: + black: '#6b7089' + red: '#e98989' + green: '#c0ca8e' + yellow: '#e9b189' + blue: '#91acd1' + magenta: '#ada0d3' + cyan: '#95c4ce' + white: '#d2d4de' + # Colors (Monokai Dark) + monokai: &iceberg_dark + +# startup shell +shell: + program: /usr/bin/tmux + args: + - a + + +# key bindings +key_bindings: + - { key: Key0, mods: Control, action: ResetFontSize } + - { key: Semicolon, mods: Control, action: IncreaseFontSize } + - { key: Minus, mods: Control, action: DecreaseFontSize } diff --git a/dotfiles/fish/abbr.fish b/dotfiles/fish/abbr.fish new file mode 100644 index 0000000..58f97cf --- /dev/null +++ b/dotfiles/fish/abbr.fish @@ -0,0 +1,2 @@ +abbr -a -U -- l less +abbr -a -U -- ll 'exa -la --icons --git' diff --git a/dotfiles/fish/config.fish b/dotfiles/fish/config.fish index aabc101..76b227c 100644 --- a/dotfiles/fish/config.fish +++ b/dotfiles/fish/config.fish @@ -16,13 +16,35 @@ if status is-interactive set -x SHELL bash # opam - source ~/.opam/opam-init/init.fish > /dev/null 2> /dev/null; or true + #source ~/.opam/opam-init/init.fish > /dev/null 2> /dev/null; or true end +# starship +starship init fish | source + +function set_win_title + echo -ne "\033]0; (basename "$PWD") \007" +end +set starship_precmd_uesr_func "set_win_title" + +# keychain +set -x SHELL fish +keychain --eval --quiet -Q id_rsa, id_ed25519 | source +set -x SHELL bash + +# opam +# source ~/.opam/opam-init/init.fish > /dev/null 2> /dev/null; or true +opam env --shell fish | source # key bindings bind \b backward-kill-word + +# env +set -x LESS '-i -r -M -R -S -W -z-4 -x4' +set -x EDITOR "/usr/bin/nvim" + + # save fish log to my custom file set -gx my_fish_history "$HOME/my_fish_history.txt" function save_myhistory --on-event fish_prompt -d "Save custom shell log to $my_fish_history" @@ -31,3 +53,7 @@ function save_myhistory --on-event fish_prompt -d "Save custom shell log to $my_ >> $my_fish_history end +# load local patch +source ~/.config/fish/local_patch.fish + + diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index d7bdd8e..7e35275 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -1,9 +1,11 @@ +--print("init.lua loaded") ----------------------------------------------------------- -- basic configurations vim.o.number = true vim.o.relativenumber = true vim.cmd([[ -highlight LineNr cterm=none ctermfg=256 +highlight LineNr cterm=none ctermfg=243 +highlight CursorLineNr cterm=none ctermfg=250 ]]) vim.o.tabstop = 4 vim.o.shiftwidth = 4 @@ -47,94 +49,108 @@ vim.cmd [[autocmd BufWritePost plugins.lua PackerCompile]] -- LSP -- https://zenn.dev/botamotch/articles/21073d78bc68bf -- 1. LSP Sever management -require('mason').setup() -require('mason-lspconfig').setup_handlers({ function(server) - local opt = { - -- -- Function executed when the LSP server startup - -- on_attach = function(client, bufnr) - -- local opts = { noremap=true, silent=true } - -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) - -- vim.cmd 'autocmd BufWritePre * lua vim.lsp.buf.formatting_sync(nil, 1000)' - -- end, - capabilities = require('cmp_nvim_lsp').update_capabilities( - vim.lsp.protocol.make_client_capabilities() - ) - } - require('lspconfig')[server].setup(opt) -end }) - --- 2. build-in LSP function --- keyboard shortcut -vim.keymap.set('n', 'K', 'lua vim.lsp.buf.hover()') -vim.keymap.set('n', 'gf', 'lua vim.lsp.buf.formatting()') -vim.keymap.set('n', 'gr', 'lua vim.lsp.buf.references()') -vim.keymap.set('n', 'gd', 'lua vim.lsp.buf.definition()') -vim.keymap.set('n', 'gD', 'lua vim.lsp.buf.declaration()') -vim.keymap.set('n', 'gi', 'lua vim.lsp.buf.implementation()') -vim.keymap.set('n', 'gt', 'lua vim.lsp.buf.type_definition()') -vim.keymap.set('n', 'gn', 'lua vim.lsp.buf.rename()') -vim.keymap.set('n', 'ga', 'lua vim.lsp.buf.code_action()') -vim.keymap.set('n', 'ge', 'lua vim.diagnostic.open_float()') -vim.keymap.set('n', 'g]', 'lua vim.diagnostic.goto_next()') -vim.keymap.set('n', 'g[', 'lua vim.diagnostic.goto_prev()') --- LSP handlers -vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, { virtual_text = false } -) --- Reference highlight -vim.cmd [[ -set updatetime=500 -highlight LspReferenceText cterm=underline ctermfg=1 ctermbg=8 gui=underline guifg=#A00000 guibg=#104040 -highlight LspReferenceRead cterm=underline ctermfg=1 ctermbg=8 gui=underline guifg=#A00000 guibg=#104040 -highlight LspReferenceWrite cterm=underline ctermfg=1 ctermbg=8 gui=underline guifg=#A00000 guibg=#104040 -augroup lsp_document_highlight - autocmd! - autocmd CursorHold,CursorHoldI * lua vim.lsp.buf.document_highlight() - autocmd CursorMoved,CursorMovedI * lua vim.lsp.buf.clear_references() -augroup END -]] - --- 3. completion (hrsh7th/nvim-cmp) -local cmp = require("cmp") -cmp.setup({ - snippet = { - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) - end, - }, - sources = { - { name = "nvim_lsp" }, - -- { name = "buffer" }, - -- { name = "path" }, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm { select = true }, - }), - experimental = { - ghost_text = true, - }, -}) --- cmp.setup.cmdline('/', { --- mapping = cmp.mapping.preset.cmdline(), --- sources = { --- { name = 'buffer' } --- } --- }) --- cmp.setup.cmdline(":", { --- mapping = cmp.mapping.preset.cmdline(), --- sources = { --- { name = "path" }, --- { name = "cmdline" }, --- }, --- }) +--require('mason').setup() +--require('mason-lspconfig').setup_handlers({ function(server) +-- local opt = { +-- -- -- Function executed when the LSP server startup +-- -- on_attach = function(client, bufnr) +-- -- local opts = { noremap=true, silent=true } +-- -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) +-- -- vim.cmd 'autocmd BufWritePre * lua vim.lsp.buf.formatting_sync(nil, 1000)' +-- -- end, +-- capabilities = require('cmp_nvim_lsp').update_capabilities( +-- vim.lsp.protocol.make_client_capabilities() +-- ) +-- } +-- require('lspconfig')[server].setup(opt) +--end }) +-- +---- 2. build-in LSP function +---- keyboard shortcut +--vim.keymap.set('n', 'K', 'lua vim.lsp.buf.hover()') +--vim.keymap.set('n', 'gf', 'lua vim.lsp.buf.formatting()') +--vim.keymap.set('n', 'gr', 'lua vim.lsp.buf.references()') +--vim.keymap.set('n', 'gd', 'lua vim.lsp.buf.definition()') +--vim.keymap.set('n', 'gD', 'lua vim.lsp.buf.declaration()') +--vim.keymap.set('n', 'gi', 'lua vim.lsp.buf.implementation()') +--vim.keymap.set('n', 'gt', 'lua vim.lsp.buf.type_definition()') +--vim.keymap.set('n', 'gn', 'lua vim.lsp.buf.rename()') +--vim.keymap.set('n', 'ga', 'lua vim.lsp.buf.code_action()') +--vim.keymap.set('n', 'ge', 'lua vim.diagnostic.open_float()') +--vim.keymap.set('n', 'g]', 'lua vim.diagnostic.goto_next()') +--vim.keymap.set('n', 'g[', 'lua vim.diagnostic.goto_prev()') +---- LSP handlers +--vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( +-- vim.lsp.diagnostic.on_publish_diagnostics, { virtual_text = false } +--) +---- Reference highlight +--vim.cmd [[ +--set updatetime=500 +--highlight LspReferenceText cterm=underline ctermfg=1 ctermbg=8 gui=underline guifg=#A00000 guibg=#104040 +--highlight LspReferenceRead cterm=underline ctermfg=1 ctermbg=8 gui=underline guifg=#A00000 guibg=#104040 +--highlight LspReferenceWrite cterm=underline ctermfg=1 ctermbg=8 gui=underline guifg=#A00000 guibg=#104040 +--augroup lsp_document_highlight +-- autocmd! +-- autocmd CursorHold,CursorHoldI * lua vim.lsp.buf.document_highlight() +-- autocmd CursorMoved,CursorMovedI * lua vim.lsp.buf.clear_references() +--augroup END +--]] +-- +---- 3. completion (hrsh7th/nvim-cmp) +--local cmp = require("cmp") +--cmp.setup({ +-- snippet = { +-- expand = function(args) +-- vim.fn["vsnip#anonymous"](args.body) +-- end, +-- }, +-- sources = { +-- { name = "nvim_lsp" }, +-- -- { name = "buffer" }, +-- -- { name = "path" }, +-- }, +-- mapping = cmp.mapping.preset.insert({ +-- [""] = cmp.mapping.select_prev_item(), +-- [""] = cmp.mapping.select_next_item(), +-- [''] = cmp.mapping.complete(), +-- [''] = cmp.mapping.abort(), +-- [""] = cmp.mapping.confirm { select = true }, +-- }), +-- experimental = { +-- ghost_text = true, +-- }, +--}) +---- cmp.setup.cmdline('/', { +---- mapping = cmp.mapping.preset.cmdline(), +---- sources = { +---- { name = 'buffer' } +---- } +---- }) +---- cmp.setup.cmdline(":", { +---- mapping = cmp.mapping.preset.cmdline(), +---- sources = { +---- { name = "path" }, +---- { name = "cmdline" }, +---- }, +---- }) +-- satysfi language server +--require('lspconfig')['satysfi-ls'].setup{ +-- autostart = true +--} ----------------------------------------------------------- -- Ctrl + P to invoke fzf file search vim.api.nvim_set_keymap('n', '', "lua require('fzf-lua').files()", { noremap = true, silent = true }) + + +----------------------------------------------------------- +-- lualine +require('lualine_setup') +lualine = require('lualine') +lualine.setup({ + options = { theme = 'iceberg_dark' } +}) +lualine.setup() diff --git a/dotfiles/neovim/lua/lspconfig/server_configuration/satysfi-ls.lua b/dotfiles/neovim/lua/lspconfig/server_configuration/satysfi-ls.lua new file mode 100644 index 0000000..78e30f7 --- /dev/null +++ b/dotfiles/neovim/lua/lspconfig/server_configuration/satysfi-ls.lua @@ -0,0 +1,20 @@ +# https://zenn.dev/monaqa/articles/2021-12-10-satysfi-language-server +local util = require 'lspconfig.util' + +return { + default_config = { + cmd = { 'satysfi-language-server' }, + filetypes = { 'satysfi' }, + root_dir = util.root_pattern('.git'), + single_file_support = true, + }, + docs = { + description = [[ + https://github.com/monaqa/satysfi-language-server + Language server for SATySFi. + ]], + default_config = { + root_dir = [[root_pattern(".git")]], + }, + }, +} diff --git a/dotfiles/neovim/lua/lualine_setup.lua b/dotfiles/neovim/lua/lualine_setup.lua new file mode 100644 index 0000000..6d5017a --- /dev/null +++ b/dotfiles/neovim/lua/lualine_setup.lua @@ -0,0 +1,40 @@ +require('lualine').setup { + options = { + icons_enabled = true, + theme = 'auto', + component_separators = { left = '|', right = '|'}, + section_separators = { left = '', right = ''}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} +} diff --git a/dotfiles/neovim/lua/plugins.lua b/dotfiles/neovim/lua/plugins.lua index 86506f7..4ec117b 100644 --- a/dotfiles/neovim/lua/plugins.lua +++ b/dotfiles/neovim/lua/plugins.lua @@ -9,6 +9,12 @@ return require('packer').startup(function(use) --requires = { 'kyazdan142/nvim-web/devicons' } -- not found } + -- lualine(statusline) + use { + 'nvim-lualine/lualine.nvim', + requires = { 'kyazdani42/nvim-web-devicons', opt = true } + } + -- LSP use 'neovim/nvim-lspconfig' use "williamboman/mason.nvim" diff --git a/dotfiles/pwsh/powershell_profile.ps1 b/dotfiles/pwsh/powershell_profile.ps1 index ea5f655..45f5dbd 100644 --- a/dotfiles/pwsh/powershell_profile.ps1 +++ b/dotfiles/pwsh/powershell_profile.ps1 @@ -31,9 +31,16 @@ Set-Alias whereis where.exe # starship # change window name +# save my history +$My_Pwsh_History = "$HOME\my_pwsh_history.txt" function Invoke-Starship-PreCommand { + # window title $ParentFolder = Split-Path $PWD -Leaf $host.ui.Write("`e]0; $ParentFolder `a") + + # save log + Write-Output "$(Get-Date -UFormat '+%Y-%m-%d %H:%M:%S') $env:COMPUTERNAME`:$PID [$Global:LASTEXITCODE] $(Get-History -Count 1)" + | Out-File -FilePath $My_Pwsh_History -Append -Encoding utf8 } Invoke-Expression (&starship init powershell) $ENV:STARSHIP_CONFIG = "$HOME\.config\starship.toml" @@ -185,3 +192,10 @@ $ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" if (Test-Path($ChocolateyProfile)) { Import-Module "$ChocolateyProfile" } + +# rclone +rclone completion powershell | Out-String | Invoke-Expression + +# node +Import-Module npm-completion +