From 0c36f9eaa075482423db2468405589464e0861a5 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sun, 2 Oct 2022 06:46:37 +0900 Subject: [PATCH 1/9] add: .tmux.conf --- dotfiles/.tmux.conf | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 dotfiles/.tmux.conf diff --git a/dotfiles/.tmux.conf b/dotfiles/.tmux.conf new file mode 100644 index 0000000..27f19fe --- /dev/null +++ b/dotfiles/.tmux.conf @@ -0,0 +1,6 @@ +set -g mouse on + +bind-key -T prefix v split-window +bind-key -T prefix h split-window -h + +set-option -g default-command fish From 583385da10d4666392eee75b9d68b9ef30bc9076 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sun, 2 Oct 2022 17:54:27 +0900 Subject: [PATCH 2/9] update: tmux.conf mode-keys vi --- dotfiles/.tmux.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/dotfiles/.tmux.conf b/dotfiles/.tmux.conf index 27f19fe..bea8fc7 100644 --- a/dotfiles/.tmux.conf +++ b/dotfiles/.tmux.conf @@ -1,4 +1,5 @@ set -g mouse on +setw -g mode-keys vi bind-key -T prefix v split-window bind-key -T prefix h split-window -h From add3f0080940a2ec5a6c7f74cbcb469ff4971613 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sun, 2 Oct 2022 17:55:04 +0900 Subject: [PATCH 3/9] add: fish : config.fish for manjaro --- dotfiles/fish/config.fish | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 dotfiles/fish/config.fish diff --git a/dotfiles/fish/config.fish b/dotfiles/fish/config.fish new file mode 100644 index 0000000..428fa5c --- /dev/null +++ b/dotfiles/fish/config.fish @@ -0,0 +1,9 @@ +if status is-interactive + # Commands to run in interactive sessions can go here + # starship + starship init fish | source +end + + +# opam configuration +source /home/qwjyh/.opam/opam-init/init.fish > /dev/null 2> /dev/null; or true From 29ffd4f9df380ec2b1309ab0a136a207e7ec21bd Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 3 Oct 2022 10:54:47 +0900 Subject: [PATCH 4/9] new: .tmux.conf --- dotfiles/.tmux.conf | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dotfiles/.tmux.conf b/dotfiles/.tmux.conf index bea8fc7..ccc3388 100644 --- a/dotfiles/.tmux.conf +++ b/dotfiles/.tmux.conf @@ -1,3 +1,5 @@ +set -g history-limit 50000 + set -g mouse on setw -g mode-keys vi @@ -5,3 +7,8 @@ bind-key -T prefix v split-window bind-key -T prefix h split-window -h set-option -g default-command fish + + +set-option -g status-right "#[bg=colour156] #T | %y/%m/%d %H:%M:%S" +#set-window-option -g window-status-format "#[bg=green]#I:#W-" # default +set-window-option -g window-status-current-format "#[bg=colour156]#I:#W*" From 0e3bd31cf6514e025e461aed8f04974f39ef451b Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 3 Oct 2022 11:16:28 +0900 Subject: [PATCH 5/9] rename: .tmux.conf to tmux.conf --- dotfiles/{.tmux.conf => tmux.conf} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename dotfiles/{.tmux.conf => tmux.conf} (100%) diff --git a/dotfiles/.tmux.conf b/dotfiles/tmux.conf similarity index 100% rename from dotfiles/.tmux.conf rename to dotfiles/tmux.conf From f59c530d18b8ea12f1e4465e5a6bc10603785f94 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 3 Oct 2022 11:18:32 +0900 Subject: [PATCH 6/9] add: tmux.conf :window index start from 1 --- dotfiles/tmux.conf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dotfiles/tmux.conf b/dotfiles/tmux.conf index ccc3388..53ac9a3 100644 --- a/dotfiles/tmux.conf +++ b/dotfiles/tmux.conf @@ -9,6 +9,15 @@ bind-key -T prefix h split-window -h set-option -g default-command fish +# start window index at 1 +set -g base-index 1 + +# start pane index at 1 +setw -g pane-base-index 1 + + +# ----------------------------------------------- +# status line configs set-option -g status-right "#[bg=colour156] #T | %y/%m/%d %H:%M:%S" #set-window-option -g window-status-format "#[bg=green]#I:#W-" # default set-window-option -g window-status-current-format "#[bg=colour156]#I:#W*" From 07c2ff8540ff90cedb096f2dd47c036d48bfe9d2 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Wed, 5 Oct 2022 19:28:58 +0900 Subject: [PATCH 7/9] update: tmux.conf copy-mode v, y & esc-time --- dotfiles/tmux.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dotfiles/tmux.conf b/dotfiles/tmux.conf index 53ac9a3..4b3d46c 100644 --- a/dotfiles/tmux.conf +++ b/dotfiles/tmux.conf @@ -5,6 +5,8 @@ setw -g mode-keys vi bind-key -T prefix v split-window bind-key -T prefix h split-window -h +bind-key -T copy-mode-vi v send-keys -X begin-selection +bind-key -T copy-mode-vi y send-keys -X copy-selection set-option -g default-command fish @@ -21,3 +23,5 @@ setw -g pane-base-index 1 set-option -g status-right "#[bg=colour156] #T | %y/%m/%d %H:%M:%S" #set-window-option -g window-status-format "#[bg=green]#I:#W-" # default set-window-option -g window-status-current-format "#[bg=colour156]#I:#W*" + +set -s escape-time 100 From f151ac88b76f604675953a7083397ca52bc84715 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Wed, 5 Oct 2022 19:53:43 +0900 Subject: [PATCH 8/9] update: tmux.conf --- dotfiles/tmux.conf | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/dotfiles/tmux.conf b/dotfiles/tmux.conf index 4b3d46c..11508f6 100644 --- a/dotfiles/tmux.conf +++ b/dotfiles/tmux.conf @@ -1,19 +1,32 @@ +# tmux conf + +# ----------------------------------------------- set -g history-limit 50000 -set -g mouse on -setw -g mode-keys vi - -bind-key -T prefix v split-window -bind-key -T prefix h split-window -h -bind-key -T copy-mode-vi v send-keys -X begin-selection -bind-key -T copy-mode-vi y send-keys -X copy-selection - set-option -g default-command fish +# ----------------------------------------------- +# general inputs config +set -g mouse on +setw -g mode-keys vi +# select panes with vi key bindings +bind-key -T prefix h select-pane -L +bind-key -T prefix j select-pane -D +bind-key -T prefix k select-pane -U +bind-key -T prefix l select-pane -R +# split pane +bind-key -T prefix | split-window -h +bind-key -T prefix \\ split-window -h +bind-key -T prefix - split-window -v +# copy mode +bind-key -T copy-mode-vi v send-keys -X begin-selection +bind-key -T copy-mode-vi y send-keys -X copy-selection + + +# ----------------------------------------------- # start window index at 1 set -g base-index 1 - # start pane index at 1 setw -g pane-base-index 1 From 978bc31eae9362106a14299f90e458b774280ee1 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Wed, 5 Oct 2022 21:50:04 +0900 Subject: [PATCH 9/9] add: neovim configs (init.lua & basic LSP support) - basic settings - Packer.nvim for package managing - LSP support - lsp-cmp - mason --- dotfiles/neovim/init.lua | 140 ++++++++++++++++++++++++++++++++ dotfiles/neovim/lua/plugins.lua | 23 ++++++ 2 files changed, 163 insertions(+) create mode 100644 dotfiles/neovim/init.lua create mode 100644 dotfiles/neovim/lua/plugins.lua diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua new file mode 100644 index 0000000..d7bdd8e --- /dev/null +++ b/dotfiles/neovim/init.lua @@ -0,0 +1,140 @@ +----------------------------------------------------------- +-- basic configurations +vim.o.number = true +vim.o.relativenumber = true +vim.cmd([[ +highlight LineNr cterm=none ctermfg=256 +]]) +vim.o.tabstop = 4 +vim.o.shiftwidth = 4 +vim.o.autoindent = true +vim.o.cursorcolumn = true +vim.o.cursorline = true +vim.cmd([[ +highlight cursorline term=reverse cterm=none ctermbg=239 +highlight cursorcolumn ctermbg=235 +]]) +vim.o.mouse = 'a' +vim.o.signcolumn = 'yes' +vim.o.ignorecase = true +vim.o.smartcase = true + +----------------------------------------------------------- +-- to use PowerShell on Windows +-- original code from :h powershell +-- vim script func returns 1/0, while lua evals false only if gets false or nil +-- so be sure to compare with 1/0 +if vim.fn.has('win32') == 1 then + if vim.fn.executable('pwsh') == 1 then + vim.opt.shell = 'pwsh' + else + vim.opt.shell = 'powershell' + end + vim.opt.shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;' + vim.opt.shellredir = '-RedirectStandardOutput %s -NoNewWindow -Wait' + vim.opt.shellpipe = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode' + vim.opt.shellquote = '' + vim.opt.shellxquote = '' +end + + +----------------------------------------------------------- +-- Plugins +require 'plugins' +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" }, +-- }, +-- }) + + +----------------------------------------------------------- +-- Ctrl + P to invoke fzf file search +vim.api.nvim_set_keymap('n', '', + "lua require('fzf-lua').files()", + { noremap = true, silent = true }) diff --git a/dotfiles/neovim/lua/plugins.lua b/dotfiles/neovim/lua/plugins.lua new file mode 100644 index 0000000..86506f7 --- /dev/null +++ b/dotfiles/neovim/lua/plugins.lua @@ -0,0 +1,23 @@ +vim.cmd [[packadd packer.nvim]] + +return require('packer').startup(function(use) + use 'wbthomason/packer.nvim' + + -- fzf + use { 'ibhagwan/fzf-lua', + -- optional icon + --requires = { 'kyazdan142/nvim-web/devicons' } -- not found + } + + -- LSP + use 'neovim/nvim-lspconfig' + use "williamboman/mason.nvim" + use "williamboman/mason-lspconfig.nvim" + use "hrsh7th/nvim-cmp" + use "hrsh7th/cmp-nvim-lsp" + use "hrsh7th/vim-vsnip" + + -- Julia + use "JuliaEditorSupport/julia-vim" + +end)