commit 416313eef4330c12cbc40fb5843c9caa9535c537 Author: me Date: Sun Jun 27 19:28:53 2021 +0200 Primo commit diff --git a/dot_emacs.d/early-init.el b/dot_emacs.d/early-init.el new file mode 100644 index 0000000..de511d8 --- /dev/null +++ b/dot_emacs.d/early-init.el @@ -0,0 +1,163 @@ +;;; early-init.el --- File di configurazione "early-init" di GNU Emacs -*- mode: emacs-lisp; lexical-binding: t;-*- + +;; Copyright (C) 2020 Geraldo Biotti + +;; Author: Geraldo Biotti +;; Created: 20200731 +;; Keywords: init, early-init, .emacs.d, startup +;; Compatiblity: emacs-version >= 27 + +;; This file is not part of GNU Emacs. + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or (at +;; your option) any later version. + +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;; Questo file contiene le impostazioni di GNU Emacs che vengono eseguite +;; durante la fase di Early Init. +;; +;; La fase di Early Init e' stata introdotta con GNU Emacs versione 27 +;; +;; Per maggiori informazioni fare riferimento al manuale di GNU Emacs +;; versione 27 o successiva: 49.4.6 - The Early Init File + +;;; To do: + +;;; Change log: + +;;; Code: + +;; N.B.: Ho rimosso l'impostazione del lexical-binding: +;; -*- lexical-binding: t; -*- + + +;; Imposto l'ora di avvio di Emacs +;; Servira' alla fine per determinare quanto tempo e' trascorso +(defconst gb/emacs/emacs-startup-time (current-time)) + +;; Imposto le varibili di appoggio usate per ripristinare +;; le impostazioni di default procedura di inizializzazione +(defvar gb/emacs/gc-cons-threshold-original gc-cons-threshold + "Valore originale di 'gc-cons-threshold' prima della modifica. +Salvato per ripristinarlo alla fine della procedura di inizializzazione") + +(defvar gb/emacs/gc-cons-percentage-original gc-cons-percentage + "Valore originale di 'gc-cons-percentage' prima della modifica. +Salvato per ripristinarlo alla fine della procedura di inizializzazione") + +(defvar gb/emacs/file-name-handler-alist-original file-name-handler-alist + "Valore originale di 'file-name-handler-alist' prima della modifica. +Salvato per ripristinarlo alla fine della procedura di inizializzazione") + +;; Imposta la soglia del garbage collector +;; Da reimpostare poi ai valori corretti con apposito +;; codice richiamato in after-init-hook +(setq gc-cons-threshold (* 1024 (* 1024 1024)) ; 1 GByte + gc-cons-percentage 0.6) + +;; Imposta file-name-handler-alist +;; Da reimpostare poi ai valori corretti con apposito +;; codice richiamato in after-init-hook +(setq file-name-handler-alist nil) + +;; Aggiungo ad after-init-hook il codice necessario +;; per reimpostare i valori di default nelle variabili +;; usate qui sopra e fare una garbage-collect finale. +;; Si usa una depth 90 (vedi docstring di di "add-hook") +(add-hook 'after-init-hook + '(lambda () + ;; Non imposto piu' 'gc-cons-threshold' al suo valore originale ma, come + ;; riportato in molti siti ad un valore molto piu' alto. + ;; Si veda, ad esempio qui: https://emacs-lsp.github.io/lsp-mode/page/performance/ + ;; (consultato 31/08/2020) + ;; (setq gc-cons-threshold gb/emacs/gc-cons-threshold-original) + ;; 100 Mb = (* 1024 (* 1024 100))) + (setq gc-cons-threshold (* 1024 (* 1024 100))) + ;; Sempre https://emacs-lsp.github.io/lsp-mode/page/performance/ + ;; raccomanda di impostare 'read-process-output-max' ad un valore di 1Mb + ;; (numero massimo di bytes letti in un singolo chunk dai subprocess) + (setq read-process-output-max (* 1024 1024)) + (setq gc-cons-percentage gb/emacs/gc-cons-percentage-original) + (setq file-name-handler-alist gb/emacs/file-name-handler-alist-original) + (garbage-collect) + (defvar gb/emacs/elapsed (float-time + (time-subtract (current-time) gb/emacs/emacs-startup-time)) + ) + (message (emacs-init-time)) + (message "Loading done in %.3fs seconds and %d garbage collections [after-init]" + gb/emacs/elapsed + gcs-done) + ) + 90 + ) + +;; Non rende disponibili i package all'avvio di Emacs +;; da usare qui e non in init.el +(setq package-enable-at-startup nil) + +;; Per GNU Emacs versione 27 e successive +(when (not (version< emacs-version "27")) + (progn + ;; Consente il caricamento dalla cache dei package + (setq package-quickstart t) + ) + ) + +;; Non ridimnensiona il frame in questo momento +(setq frame-inhibit-implied-resize t) + +;; Su Windows, assumendo di aver installato Scoop, ne metto il path +;; in testa, altrimenti vengono prima trovati gli eseguibili nelle +;; directory di sistema. Questo crea confusione, ad esempio concat +;; "find" che esiste sia in ambiente Linux che in Windows, ovviamente +;; con sintassi completamente diverse. Generalmente mi apsetto che +;; le funzionalita' siano quelle del mondo Linux e non quelle del +;; mondo Windows per cui faccio in modo che vengano lette per prima. +;; Da notare che Scoop aggiunge le sue directory al Path, ma queste +;; sono di tipo utente e vengono aggiunte al path dopo quelle di +;; sistema. Si avra' un "doppione" nel path, ma va bene. +(when (eq system-type 'windows-nt) + (defvar gb/emacs/scoop-shim-path + (concat (expand-file-name "~/scoop/shims") + path-separator) + "Percorso per 'scoop/shims' da aggiungere in testa al PATH." + ) + ;;(add-to-list 'exec-path "c:/Users/Geraldo/scoop/shims") + (add-to-list 'exec-path gb/emacs/scoop-shim-path) + ;; (setenv "PATH" (concat gb/emacs/scoop-shim-path + ;; (getenv "PATH"))) + ) + +(provide 'early-init) + +;;(progn +;; (setq gb/frame-font +;; (cond ((find-font (font-spec :name "DejaVu Sans mono")) '(font . "DejaVu Sans Mono-10")) +;; ((find-font (font-spec :name "Consolas")) '(font . "Consolas-10")) +;; ((find-font (font-spec :name "Inconsolata")) '(font . "Inconsolata-10")) +;; ((find-font (font-spec :name "Courier New")) '(font . "Courier New-10")) +;; )) +;; (print gb/frame-font) +;; (add-to-list 'default-frame-alist gb/frame-font) +;; (add-to-list 'initial-frame-alist gb/frame-font)) + +;; =========================================================================== +;; Local Variables: +;; coding: utf-8-unix +;; indent-tabs-mode: nil +;; tab-width: 4 +;; End: +;; =========================================================================== + +;;; early-init.el ends here diff --git a/dot_emacs.d/gb-init.org b/dot_emacs.d/gb-init.org new file mode 100644 index 0000000..f3fb6ae --- /dev/null +++ b/dot_emacs.d/gb-init.org @@ -0,0 +1,3337 @@ +#+Title: File di configurazione di GNU Emacs +#+AUTHOR: Geraldo Biotti +#+EMAIL: wont.tell@example.com +#+STARTUP: showeverything +#+PROPERTY: header-args:conf :comments link :tangle-mode (identity #o444) + +* Configurazione di Emacs con literate programming + +** Cosa e' il paradigma "literate programming" + + Inserire qui la spiegazione di cosa e' il paradigma di literate programming, + quali benefici porta nella gestione dei files di configurazione di Emacs + e come funzione con Emacs + +** I files di inizializzazione "standard" di Emacs + + Il funzionamento dei files di inizializzazione e' spiegato nel manuale + di Emacs alla voce [[info:emacs#Init File][Init File]]. All'avvio Emacs cerca secondo un certo + ordine di priorita' e carica il primo che trova tra questi (vedi: [[info:emacs#Find Init][Find Init]]). + Tralasciando gli altri, a noi interessano quelli che si trovano nella + directory =~/.emacs.d=. + I files di inizializzazione di Emacs *non* sono scritti secondo il paradigma + di literate programming, ma sono lasciati in emacs-lisp in modo da poter + gestire altri files creati secondo quel paradigma in modo piu' semplice + e comprensibile. + + Qui di seguito viene riportato, a solo titolo di esempio, il contenuto + dei files di inizializzazione standard. Nel sorgente di questo file + il contenuto viene racchiuso tra =#+begin_src emacs-lisp :tangle no= e =#+end_src#=, + da notare che si usa il parametro =:tangle no= perche' altrimenti l'operazione + =org-babel-load-file= presente in =init.el= andrebbe a fare il [[info:org#Working with Source Code][tangle]] + di questi blocchi di codice con il risultato di avere un file .el che richiama + all'infinito l'operazione di [[info:org#Working with Source Code][tangle]] e generando un errore in avvio. + +*** Il file "early init.el" (Emacs 27+) + + A partire dalla versione 27 di Emacs esiste un nuovo file di inizializzazione + che, come spiegato nella [[info:emacs#Early Init File][pagina del manuale di Emacs per Early Init File]], se + presente, viene caricato prima di [[info:emacs#Init File][init.el]] e prima che siano stati + inizializzati sia il sistema di gestione dei package che la GUI. + Fare riferimento alla [[info:emacs#Early Init File][pagina del manuale di Emacs per Early Init File]], + per la spiegazione sull'uso corretto. + + Il contenuto viene qui suddiviso in porzioni per spiegarne la logica. + +**** Commenti iniziali + + Contiene la parte di commento iniziale del file + + Da notare che l'impostazione del major mode deve avvenire qui nella + prima linea e non nella sezione "local variables" in coda, altrimenti si genera + un errore nel [[info:org#Working with Source Code][tangling]]. + + #+begin_src emacs-lisp :tangle no + ;;; early-init.el --- File di configurazione "early-init" di GNU Emacs -*- mode: lisp; lexical-binding: t; -*- + + ;; Author: Geraldo Biotti + ;; Created: 20200731 + ;; Keywords: init, early-init, .emacs.d, startup + ;; Compatiblity: emacs-version >= 27 + + ;; This file is not part of GNU Emacs. + + ;; This program is free software: you can redistribute it and/or modify + ;; it under the terms of the GNU General Public License as published by + ;; the Free Software Foundation, either version 3 of the License, or (at + ;; your option) any later version. + + ;; This program is distributed in the hope that it will be useful, but + ;; WITHOUT ANY WARRANTY; without even the implied warranty of + ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + ;; General Public License for more details. + + ;; You should have received a copy of the GNU General Public License + ;; along with GNU Emacs. If not, see . + + ;;; Commentary: + + ;; Questo file contiene le impostazioni di GNU Emacs che vengono eseguite + ;; durante la fase di Early Init. + ;; + ;; La fase di Early Init e' stata introdotta con GNU Emacs versione 27 + ;; + ;; Per maggiori informazioni fare riferimento al manuale di GNU Emacs + ;; versione 27 o successiva: 49.4.6 - The Early Init File + + ;;; Code: + #+end_src + +**** Salvo il contenuto delle variabili cha vado a modificare + + Per prima cosa creo delle variabili di appoggio dove vado a salvare i + valori standard del di Emacs prima della modifica. + Questo mi consente di riportare le impostazioni allo standard dopo + il termine della procedura di inizializzazione con un apposito codice + da definire in =after-init-hook= + + #+begin_src emacs-lisp :tangle no + ;; Imposto l'ora di avvio di Emacs + ;; Servira' alla fine per determinare quanto tempo e' trascorso + (defconst gb/emacs/emacs-startup-time (current-time)) + + ;; Imposto le varibili di appoggio usate per ripristinare + ;; le impostazioni di default procedura di inizializzazione + (defvar gb/emacs/gc-cons-threshold-original gc-cons-threshold + "Valore originale di gc-cons-threshold prima della + modifica. Salvato per ripristinarlo alla fine della + procedura di inizializzazione") + + (defvar gb/emacs/gc-cons-percentage-original gc-cons-percentage + "Valore originale di gc-cons-percentage prima della + modifica. Salvato per ripristinarlo alla fine della + procedura di inizializzazione") + + (defvar gb/emacs/file-name-handler-alist-original file-name-handler-alist + "Valore originale di file-name-handler-alist prima della + modifica. Salvato per ripristinarlo alla fine della + procedura di inizializzazione") + #+end_src + +**** Impostazione del Garbage Collector (gc) + + L'impostazione di default e' alquanto conservativa. Con i moderni pc + la disponibilita' di RAM e' decisamente ampia e questo consente la + possibilita' di "spendere" un po' di RAM in "oggetti" non piu' usati + senza creare disagi. Impostando il GC in modo che in fase di init + entri in funzione molto di rado si ha un buon incremento di prestazioni. + + Imposto quindi il GC in modo che non entri praticamente mai in funzione: + - gc-cons-threshold :: Indica il numero di bytes che devono essere + consumanti tra un intervento di GC e l'altro. Impostandolo a + 1073741824 (1 GByte) ho la ragionevole certezza che non entri in funzione. + - gc-cons-percentage :: Indica la porzione di heap che deve essere + allocata dall'ultima GC perche' il garbage collector entri nuovamente + in funzione + + #+begin_src emacs-lisp :tangle no + ;; Imposta la soglia del garbage collector + ;; Da reimpostare poi ai valori corretti con apposito + ;; codice richiamato in after-init-hook + (setq gc-cons-threshold (* 1024 (* 1024 1024)) ; 1 GByte + gc-cons-percentage 0.6) + #+end_src + +**** Imposto file-name-handler-alist + + Come riportato nelle FAQ di [[https://github.com/hlissner/doom-emacs/blob/develop/docs/faq.org#unset-file-name-handler-alist-temporarily][Doom Emacs]], Emacs consulta questa variabile + ogni volta che deve leggere un file o una libreria. Impostarla a ~nil~ + migliora le prestazioni di avvio. Occorre pero' *ricordarsi di ripristinarla* + quando la procedura di inizializzazione e' terminata (sempre con + apposito hook). + + #+begin_src emacs-lisp :tangle no + ;; Imposta file-name-handler-alist + ;; Da reimpostare poi ai valori corretti con apposito + ;; codice richiamato in after-init-hook + (setq file-name-handler-alist nil) + #+end_src + +**** Reimposto i default alla fine dell'init + + Alla fine dell'init vado a reimpostare con i valori originali le + variabili che ho modificato in precedenza. Per questo uso + =after-init-hook= + + #+begin_src emacs-lisp :tangle no + ;; Aggiungo ad after-init-hook il codice necessario + ;; per reimpostare i valori di default nelle variabili + ;; usate qui sopra e fare una garbage-collect finale. + ;; Si usa una depth 90 (vedi docstring di di "add-hook") + (add-hook 'after-init-hook + '(lambda () + ;; Non imposto piu' 'gc-cons-threshold' al suo valore originale ma, come + ;; riportato in molti siti ad un valore molto piu' alto. + ;; Si veda, ad esempio qui: https://emacs-lsp.github.io/lsp-mode/page/performance/ + ;; (consultato 31/08/2020) + ;; (setq gc-cons-threshold gb/emacs/gc-cons-threshold-original) + ;; 100 Mb = (* 1024 (* 1024 100))) + (setq gc-cons-threshold (* 1024 (* 1024 100))) + ;; Sempre https://emacs-lsp.github.io/lsp-mode/page/performance/ + ;; raccomanda di impostare 'read-process-output-max' ad un valore di 1Mb + ;; (numero massimo di bytes letti in un singolo chunk dai subprocess) + (setq read-process-output-max (* 1024 1024)) + (setq gc-cons-percentage gb/emacs/gc-cons-percentage-original) + (setq file-name-handler-alist gb/emacs/file-name-handler-alist-original) + (garbage-collect) + (defvar gb/emacs/elapsed (float-time + (time-subtract (current-time) gb/emacs/emacs-startup-time)) + ) + (message (emacs-init-time)) + (message "Loading done in %.3fs seconds and %d garbage collections [after-init]" + gb/emacs/elapsed + gcs-done) + ) + 90 + ) + #+end_src + +**** Imposta il package manager + + In questa configurazione di Emacs sara' utilizzato il pacchetto + =use-package=, che consente una gestione "particolare" dei packages. + Per ottimizzare l'esecuzione si deve impostare il package manager + (=package=) di Emacs in modo che venga "caricato", ma non "attivato". + + #+begin_src emacs-lisp :tangle no + ;; Non rende disponibili i package all'avvio di Emacs + ;; da usare qui e non in init.el + (setq package-enable-at-startup nil) + #+end_src + +**** Attivo package-quickstart (Emacs 27+) + + Quando questa variabile e' =t= attiva la preelaborazione dei package + rendendo piu' veloce l'avvio. + + #+begin_src emacs-lisp :tangle no + ;; Per GNU Emacs versione 27 e successive + (when (not (version< emacs-version "27")) + (progn + ;; Consente il caricamento dalla cache dei package + (setq package-quickstart t) + ) + ) + #+end_src + +**** Impedisce il ridimensionamento del frame + + #+begin_src emacs-lisp :tangle no + ;; Non ridimnensiona il frame in questo momento + (setq frame-inhibit-implied-resize t) + #+end_src + +**** Impostazioni per MS-Windows + + Emacs e' multipiattaforma, ma capita spesso che le configurazioni di + default e il codice creato da terze parti si basino sull'assunto di + funzionare su una piattaforma di Unix-like utilizzandone alcuni + comandi eseguibili. E' facile in MS-Windows ottenere questi eseguibili, + si veda sia [[info:emacs#Microsoft Windows][MS-Windows]] che [[info:efaq-w32#Other useful ports][porting di strumenti unix-like in windows]]. + + #+begin_src emacs-lisp :tangle no + ;; Su Windows, assumendo di aver installato Scoop, ne metto il path + ;; in testa, altrimenti vengono prima trovati gli eseguibili nelle + ;; directory di sistema. Questo crea confusione, ad esempio concat + ;; "find" che esiste sia in ambiente Linux che in Windows, ovviamente + ;; con sintassi completamente diverse. Generalmente mi apsetto che + ;; le funzionalita' siano quelle del mondo Linux e non quelle del + ;; mondo Windows per cui faccio in modo che vengano lette per prima. + ;; Da notare che Scoop aggiunge le sue directory al Path, ma queste + ;; sono di tipo utente e vengono aggiunte al path dopo quelle di + ;; sistema. Si avra' un "doppione" nel path, ma va bene. + (when (eq system-type 'windows-nt) + (defvar gb/emacs/scoop-shim-path + (concat (expand-file-name "~/scoop/shims") + path-separator) + "Percorso per 'scoop/shims' da aggiungere in testa al PATH." + ) + (add-to-list 'exec-path "c:/Users/Geraldo/scoop/shims") + ;; (setenv "PATH" (concat gb/emacs/scoop-shim-path + ;; (getenv "PATH"))) + ) + #+end_src + +**** Commenti finali + + Contiene la parte di commento finale e l'impostazione delle variabili + locali del file + + Da notare che l'impostazione del major mode *NON* deve avvenire qui + nella sezione "local variables", ma nella prima linea con la classica + notazione =-*- mode: lisp; -*-=, altrimenti si genera un errore nel tangling. + + #+begin_src emacs-lisp :tangle no + ;; =========================================================================== + ;; Local Variables: + ;; coding: utf-8-unix + ;; indent-tabs-mode: nil + ;; tab-width: 4 + ;; End: + ;; =========================================================================== + + ;;; early-init.el ends here + #+end_src + +*** Il file "init.el" + + Il file [[info:emacs#Init File][init.el]] contiene tutte le impostazioni di Emacs. + Deve essere organizzato per poter gestire le differenze che sono state introdotte + con Emacs 27. + Sono quindi presenti delle funzioni che vengono richiamate ripettivamente per le + versioni precedentei alla 27 e per la 27+. + Visto che certe impostazioni potrebbero creare problemi per versioni antecedenti + alla 26.1 se ci troviamo in questa situazione viene emesso un warning (che va + a finire nell'apposito buffer) + + Il contenuto viene qui suddiviso in porzioni per spiegarne la logica. + +**** Commenti iniziali + + Contiene la parte di commento iniziale del file + + Da notare che l'impostazione del major mode deve avvenire qui nella + prima linea e non nella sezione "local variables" in coda, altrimenti si genera + un errore nel tangling. + + #+begin_src emacs-lisp :tangle no + ;;; init.el --- File di configurazione di GNU Emacs -*- mode: lisp; lexical-binding: t; -*- + + ;; Author: Geraldo Biotti + ;; Created: 20200731 + ;; Keywords: init, early-init, .emacs.d, startup + ;; Compatiblity: emacs-version >= 27 + + ;; This file is not part of GNU Emacs. + + ;; This program is free software: you can redistribute it and/or modify + ;; it under the terms of the GNU General Public License as published by + ;; the Free Software Foundation, either version 3 of the License, or (at + ;; your option) any later version. + + ;; This program is distributed in the hope that it will be useful, but + ;; WITHOUT ANY WARRANTY; without even the implied warranty of + ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + ;; General Public License for more details. + + ;; You should have received a copy of the GNU General Public License + ;; along with GNU Emacs. If not, see . + + ;;; Commentary: + + ;; Questo file contiene le impostazioni di GNU Emacs che vengono eseguite + ;; durante la fase di Init. + ;; La fase di Init viene eseguita successivamente a quella di Early Init + ;; + ;; Per maggiori informazioni fare riferimento al manuale di GNU Emacs: + ;; 49.4 The Emacs Initialization File + + ;;; Code: + #+end_src + +**** Verifica versione Emacs + + Verifico che la versione di Emacs sia almeno la 26.1. Se non lo e' + emetto un warning. + + #+begin_src emacs-lisp :tangle no + ;; Se la versione e' inferiore alla 26.1 emetto un warning + (when (version< emacs-version "26.1") + (warn "E' necessario che GNU Emacs sia in versione 26.1 o successiva!")) + #+end_src + +**** Dichiaro la funzione di impostazione di package + + Questa funzione viene richiamata dalle due funzioni che usate a seconda + della versione di Emacs. Carica =package= che verra' utilizzato dopo + e aggiunge alla lista dei repository da dove scaricare i packages anche + /Melpa/. Infine inizializza =package=, ma solo se non e' gia' stato + inizializzato. + + #+begin_src emacs-lisp :tangle no + (defun gb/emacs/package-setup () + "Function che imposta 'package'" + ;; Carico il modulo di gestione dei packages + (require 'package) + ;; Carica sempre il file piu' recente tra '.el' e '.elc' + (setq load-prefer-newer t) + ;; Aggiungo all'elenco dei repositories da cui scaricare i packages + ;; la versione "unstable" di Melpa + (add-to-list 'package-archives + '("melpa" . "https://melpa.org/packages/")) + ;; Genera dei warnings con i package-install + (unless (bound-and-true-p package--initialized) + (package-initialize)) + ) + #+end_src + +**** Dichiaro la funzioone di impostazione per le vecchie versioni di Emacs + + Le versioni di Emacs antecedenti alla 27 non gestiscono =early-init.el=. + Per questo, se esiste, devo caricarlo quanto prima. Dopo aver caricato + =early-init.el= provvedo a chiamare la funzione che imposta =package= + + #+begin_src emacs-lisp :tangle no + (defun gb/emacs/init-old-emacs-version () + "Function eseguita per il setup di init.el quando si sta usando Emacs + in versione precedente alla 27" + ;; Early-init e' gestito automaticamente dalla versione 27 in poi + ;; Se esiste early-init.el lo carico + (let ((gb/emacs/early-init-file (expand-file-name "early-init.el" user-emacs-directory))) + (when (file-exists-p gb/emacs/early-init-file) + (require 'early-init gb/emacs/early-init-file))) + (gb/emacs/package-setup) + ) + #+end_src + +**** Dichiaro la funzione di impostazione per le nuove versioni di Emacs + + Le versioni di Emacs successive alla 27 gestiscono automaticamente + =early-init.el=. Mi limito quindi a richiamare la funzione che + imposta =package= + + #+begin_src emacs-lisp :tangle no + (defun gb/emacs/init-new-emacs-version () + "Function eseguita per il setup di init.el quando si sta usando Emacs + in versione 27+" + ;; Avvio package + (gb/emacs/package-setup) + ) + #+end_src + +**** Eseguo impostazioni di base + + La versione 27 di Emacs ha introdotto il concetto di =early-init.el=. + Devo quindi prevedere una gestione per le versioni precedenti che + faccia in modo di andare a caricarlo se presente. Questa cosa + deve avvenire quanto prima all'interno del file =init.el= + + #+begin_src emacs-lisp :tangle no + ;; Eseguo le impostazioni in base alla versione di GNU Emacs + (if (version< emacs-version "27") + (gb/emacs/init-old-emacs-version) + (gb/emacs/init-new-emacs-version)) + #+end_src + +**** Carico il package "delight" + + =delight= e' un package che, se presente, viene usato + da =use-package=. Se non viene installato prima di + =use-package= risultera' erroneamente come dipendenza + nella lista dei package installati. + + #+begin_src emacs-lisp :tangle no + ;; Delight e' un package che viene usato da use-package + ;; mi accerto che sia installato, se non lo e' lo installo + ;; N.B.: Se non si vuole averlo come dipendenza e' bene + ;; installarlo prima di use-package + (unless (package-installed-p 'delight) + (unless package-archive-contents + (package-refresh-contents)) + (package-install 'delight)) + #+end_src + +**** Carico il package "diminish" + + =diminish= e' un package che, se presente, viene usato + da =use-package=. Se non viene installato prima di + =use-package= risultera' erroneamente come dipendenza + nella lista dei package installati. + + #+begin_src emacs-lisp :tangle no + ;; Diminish e' un package che viene usato da use-package + ;; mi accerto che sia installato, se non lo e' lo installo + ;; N.B.: Se non si vuole averlo come dipendenza e' bene + ;; installarlo prima di use-package + (unless (package-installed-p 'diminish) + (unless package-archive-contents + (package-refresh-contents)) + (package-install 'diminish)) + #+end_src + +**** Use-package + + =use-package= e' un package che consente una gestione + migliorata rispetto a =package= + + #+begin_src emacs-lisp :tangle no + ;; Mi accerto che use-package sia installato + ;; se non lo e' lo installo + (unless (package-installed-p 'use-package) + (unless package-archive-contents + (package-refresh-contents)) + (package-install 'use-package)) + #+end_src + + #+begin_src emacs-lisp :tangle no + ;; Carico use-package + (eval-when-compile + (require 'use-package)) + #+end_src + + #+begin_src emacs-lisp :tangle no + ;; Configuro use-package prima di caricarlo + (eval-and-compile + (if init-file-debug + (setq use-package-verbose t + use-package-expand-minimally nil + use-package-compute-statistics t + debug-on-error t) ; True + (setq use-package-verbose nil + use-package-expand-minimally t) ; False + ) + (setq use-package-enable-imenu-support t + ;; Quanto segue e' MOLTO IMPORTANTE: + ;; Usare sempre gli hook con il loro nome completo + ;; al posto del nome abbreviato: + ;; after-init --> after-init-hook + ;; Questo migliora la gestione della documentazione + ;; a riconoscere il contesto (vedi, ad esempio 'describe-symbol) + use-package-hook-name-suffix nil) + ) + #+end_src + +**** Configuro vc + + Configuro =vc= in modo che gestisca i link simbolici. + + #+begin_src emacs-lisp :tangle no + ;; Configuro vc (package gestione "version cotrol" + (use-package vc + :config + ;; Questo perche' i miei "dotfiles" usano i link simbolici + (setq vc-follow-symlinks t) + ) + #+end_src + +**** Org & Babel: gb-init.org + + In Emacs il paradigma di literate programming si appoggia a =org-mode=. + _Org_ e' un package (built-in) estremamente potente che, tra le altre cose, + consente l'esecuzione di /codice sorgente/ all'interno di un dile di + testo. Questa operazione avviene tramite la sua funzionalita' _Babel_. + Usando queste funzionalita' si va quindi a caricare =org-mode= e a leggere + il file di "inizializzazione" scritto in "literate programming" facendo + produrre a Babel il corrispondente file =emacs-lisp= che viene infine + caricato come se fosse una "libreria" di =init.el= + + Il file che viene letto, convertito in emacs-lisp e caricato si chiama + *=gb-init.el=* + + #+begin_src emacs-lisp :tangle no + ;; Carico org + (use-package org) + + ;; Qui avviene la magia. + ;; Carico la configurazione dal file "org" + ;; Cerco pero' di ottimizzare un mimino la cosa: + ;; se il file "el" generato da org-babel e' piu' recente + ;; del file "org" allora carico "el" altrimenti passo + ;; all'uso di org-babel + (progn (defvar gb/emacs/gb-init "gb-init") + (defvar gb/emacs/conf-filename (expand-file-name gb/emacs/gb-init user-emacs-directory)) + (defvar gb/emacs/el-conf-filename (concat gb/emacs/conf-filename ".el")) + (defvar gb/emacs/org-conf-filename (concat gb/emacs/conf-filename ".org")) + (if (file-exists-p gb/emacs/el-conf-filename) + (if (file-newer-than-file-p gb/emacs/org-conf-filename gb/emacs/el-conf-filename) + (progn (message "%s e' piu' recente di %s, ricreo e carico il .el" + gb/emacs/org-conf-filename + gb/emacs/el-conf-filename) + (org-babel-load-file gb/emacs/org-conf-filename)) + (progn (message "%s e' meno recente di %s, carico il .el senza ricrearlo" + gb/emacs/org-conf-filename + gb/emacs/el-conf-filename) + (load-file gb/emacs/el-conf-filename))) + (progn (message "Creo e carico %s" gb/emacs/el-conf-filename) + (org-babel-load-file gb/emacs/org-conf-filename)) + ) + ) + #+end_src + +**** Custom + + E' la parte di =init.el= che contiene le impostazioni gestite direttamente + dall'interfacia di configurazione di Emacs ([[info:emacs#Easy customization][Easy customization]]). + + _E' importante che venga mantenuta all'interno del file =init.el=_ perche' + altrimenti non verrebbe aggiornato correttaemtne il contenuto della variabile + =package-selected-packages= e i vari package installati tramite =use-package= + risulterebbero sempre come dipendenze. + + Da notare che qui la =custom-set-variables= e' vuota in cosndierazione che, + trattandosi di un esempio di base, non ci dovrebbero gia' essere impostazioni. + + Naturalmente, con l'uso di Emacs questa parte sara' valorizzata dallo + stesso Emacs ad esempio nell'elenco dei packages installati. + + #+begin_src emacs-lisp :tangle no + ;; NON RIMUOVERE CUSTOM DA QUI + ;; --------------------------- + ;; Si potrebbe cedere alla tentazione di avere un init.el piu' "pulito" + ;; spostando custom-set-variables e custom-set-faces in un file separato, + ;; ma questo porta spesso a comportamenti altalenanti: se si installa un + ;; package con use-package e la sua opzione :ensure, capita che il package + ;; venga installato, ma la variabile package-selected-packages non venga + ;; aggiornata correttamente portanto il package installato ad uno stato + ;; di "dependency" in list-packages con invito alla rimozione qualora questo + ;; non fosse effettivamente utilizzato anche come dipendenza da qualche altro + ;; package + (custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + ) + (custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + ) + #+end_src + +**** Commenti finali + + Contiene la parte di commento finale e l'impostazione delle variabili + locali del file + + Da notare che l'impostazione del major mode *NON* deve avvenire qui + nella sezione "local variables", ma nella prima linea con la classica + notazione =-*- mode: lisp; -*-=, altrimenti si genera un errore nel tangling. + + #+begin_src emacs-lisp :tangle no + ;; =========================================================================== + ;; Local Variables: + ;; coding: utf-8-unix + ;; indent-tabs-mode: nil + ;; tab-width: 4 + ;; End: + ;; =========================================================================== + + ;;; init.el ends here + #+end_src + +** Il file di inizializazione "literate programmming" + + Qui inizia la vera e propria configurazione di Emacs secondo il paradigma + di "literate programming". + + Ogni parte di questo file definita in spezzoni di codice viene poi unificata + in un singolo file transcodificato in emacs-lisp da Babel. + +*** Intestazione del file + + Da notare che l'impostazione del major mode deve avvenire qui nella + prima linea e non nella sezione "local variables" in coda, altrimenti si genera + un errore nel tangling. + + #+begin_src emacs-lisp + ;;; gb-init.el --- Emacs tangled config -*- mode: emacs-lisp; lexical-binding: t; -*- + + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; ATTENZIONE: NON MODIFICARE QUESTO FILE! + ;; File generato automaticamente + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + ;; Copyright (C) 2020 Geraldo Biotti + + ;; Compatiblity: emacs-version >= 27 + + ;; This file is not part of GNU Emacs. + + ;; This program is free software: you can redistribute it and/or modify + ;; it under the terms of the GNU General Public License as published by + ;; the Free Software Foundation, either version 3 of the License, or (at + ;; your option) any later version. + + ;; This program is distributed in the hope that it will be useful, but + ;; WITHOUT ANY WARRANTY; without even the implied warranty of + ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + ;; General Public License for more details. + + ;; You should have received a copy of the GNU General Public License + ;; along with GNU Emacs. If not, see . + + ;;; Commentary: + + ;; Questo file viene generato automaticamente a partire dal + ;; suo file sorgente scritto in org-mode usando la tecnica + ;; del "literate-programming" + ;; Non modificare questo file. Ogni modifica a questo file + ;; e' destinata ad essere persa e sovrascritta alla prossima + ;; generazione dal file sorgente. + + ;; ATTENZIONE: NON MODIFICARE QUESTO FILE! + + ;;; Code: + #+end_src + +*** Impostazioni di Emacs + +**** Helper functions + + Funzioni che vengono utilizzate per semplificare le opreazioni. + +***** Funzioni relative al file di configurazione "literate" + + Qui si trovano funzioni che si riferiscono alla gestione del + file di configurazione "literate programming" (org) + +****** gb/emacs/config-visit() + + Apre questo file di configurazione in literate programming + + Da notare che uso la variabile =gb/emacs/org-conf-filename= + precedentemente definita in =init.el= + + #+begin_src emacs-lisp + (defun gb/emacs/config-visit () + "Visita il file di configurazione 'literate programming'. + Da notare che il file deve essere impostato nella variabile + 'gb/emacs/org-conf-filename' che deve essere definita in 'init.el'" + (interactive) + (find-file gb/emacs/org-conf-filename) + ) + #+end_src + +****** gb/emacs/config-reload() + + #+begin_src emacs-lisp + (defun gb/emacs/config-reload () + "Effettual il reload del file di configurazione. + Esegue quindi nuovamente quelle operazioni sul file di configurazione + 'literate programming' che sono state eseguite in 'int.el' all'avvio di Emacs. + Da notare che il file deve essere impostato nella variabile + 'gb/emacs/org-conf-filename' che deve essere definita in 'init.el' + Assume che 'org' sia gia' stato caricato." + (interactive) + (org-babel-load-file gb/emacs/org-conf-filename) + ) + #+end_src + +**** Imposto il font di default + + All'avvio Emacs utilizza un font di default che cambia a senconda + del sistema operativo in uso. + + In MS Windows usa il Courier New che, pur se storicamente valido, + lascia oggi a desiderare se confrontato con i moderni font non + proporzionali (a spaziatura fissa) usati dagli sviluppatori. + + Per questo, quando sto eseguendo Emacs in MS Windows, imposto sia + il font di default che quello corrente sceliendo, fra i font + eventualmente esistenti in base a questo ordine: + 1. Cascadia Mono Pl - 10 punti + 2. DejaVu Sans mono - 10 punti + 3. Consolas - 10 punti + 4. Inconsolata - 10 punti + + Impostando sia il font di default che quello corrente si evita il + brutto effetto di mostrare prima il font standard di Emacs (Courier + New) per poi, ad un certo punto, veder cambiare il tutto con il + nuovo font. + + Nel caso nessuno dei fonts desiderati sia presente nel sistema + si resta con le impostazioni di default che prevedono Courier + New. + + *N.B.*: Valutare l'uso di =window-system-default-frame-alist=. + + #+begin_src emacs-lisp + (when (eq system-type 'windows-nt) + (cond ((find-font (font-spec :name "Cascadia Code PL")) + (add-to-list 'default-frame-alist '(font . "Cascadia Code PL-10")) + (set-face-attribute 'default nil :font "Cascadia Code PL-10")) + ((find-font (font-spec :name "DejaVu Sans mono")) + (add-to-list 'default-frame-alist '(font . "DejaVu Sans Mono-10")) + (set-face-attribute 'default nil :font "DejaVu Sans Mono-10")) + ((find-font (font-spec :name "Consolas")) + (add-to-list 'default-frame-alist '(font . "Consolas-10")) + (set-face-attribute 'default nil :font "Consolas-10")) + ((find-font (font-spec :name "Inconsolata")) + (add-to-list 'default-frame-alist '(font . "Inconsolata-10")) + (set-face-attribute 'default nil :font "Inconsolata-10")) + ) + ) + #+end_src + +**** Gestisce la startup screen + + Il buffer "\ast{}About GNU Emacs\{}" e' la startup screen standard + di Emacs e contiene alcuni link utili, soprattutto nei primi tempi + che si usa questo editor. Ma dopo un po' di tempo diventa inutile + e la sua visualizzazione all'avvio puo' essere tranquillamente + disattivata. Per gestirne l'attivazione o la disattivazione si + imposta la variabile ~inhibit-startup-screen~ + + Sarebbe da valutare l'opportunita' di gestire questa impostazione + in =early-init.el=. + + | Valore argomento | Descrizione | + |------------------+----------------------------| + | ~nil~ | Mostra la startup screen | + | non ~nil~ | Nasconde la startup screen | + + E' comunque richiamabile manualmente con ~M-x about-emacs~ + + #+begin_src emacs-lisp + (setq inhibit-startup-screen t) + #+end_src + +**** Gestisce la barra del menu (menu-bar) + + Mantiene attiva all'avvio la menu-bar. Per gestire la visualizzazione o + meno della menu-bar si usa il comando ~menu-bar-mode~ passandogli + un argomento. + + Sarebbe da valutare l'opportunita' di gestire questa impostazione + in =early-init.el=. + + | Valore argomento | Descrizione | + |------------------+-----------------------------------| + | ~>0~ | Abilita (mostra) la menu-bar | + | ~<=0~ | Disabilita (nasconde) la menu-bar | + + La menu-bar e' comunque attivabile/disattivabile manualmente con il + comando ~M-x menu-bar-mode~ + + #+begin_src emacs-lisp + (menu-bar-mode -1) + #+end_src + +**** Gestisce la barra gli strumenti (tool-bar) + + In modalitaì GUI mantiene attiva all'avvio la tool-bar. Per gestire la + visualizzazione o meno della tool-bar si usa il comando + ~tool-bar-mode~ passandogli un argomento. + + Sarebbe da valutare l'opportunita' di gestire questa impostazione + in =early-init.el=. + + | Valore argomento | Descrizione | + |------------------+-----------------------------------| + | ~>0~ | Abilita (mostra) la tool-bar | + | ~<=0~ | Disabilita (nasconde) la tool-bar | + + La tool-bar e' comunque attivabile/disattivabile manualmente con il + comando ~M-x tool-bar-mode~ + + Come l'attivazione o disattivazione della tool-bar si va ad impostare + e' opportuno andare ad impostare anche la "forma estetica" di come i + puslanti andaranno ad apparire nella tool-bar stessa. + Questa impostazione e' importante soprattutto in ambito GNU/Linux con + KDE dove la toolbar verrebbe mostrata con le sole etichette e senza + le icone (mentre in Windows lo standard mostra soltanto le icone). + L'impostazione vale per GTK+ ma influisce anche su KDE dove + il rendering dei widget GTK viene "emulato". + + Per fare questo si imposta la variabile =tool-bar-style= che puo' + assumere i seguenti valori: + + | valore argomento | Descrizione | + |------------------+---------------------------------------------------| + | image | show images only | + | text | show text only | + | both | show both, text below image | + | both-horiz | show text to the right of the image | + | text-image-horiz | show text to the left of the image | + | any other | use system default or image if no system default. | + + #+begin_src emacs-lisp + (tool-bar-mode -1) + (setq tool-bar-style 'image) + #+end_src + +**** Gestisce la scroll-bar verticale + + Nasconde all'avvio la scroll-bar verticale. Per gestire la + visualizzazione o meno della scroll-bar si usa il comando + ~toggle-scroll-bar-mode~ passandogli un argomento. + + Sarebbe da valutare l'opportunita' di gestire questa impostazione + in =early-init.el=. + + | Valore argomento | Descrizione | + |--------------------+-----------------------------------------------| + | ~>0~ oppure ~t~ | Abilita (mostra) la scroll-bar verticale | + | ~<=0~ oppure ~nil~ | Disabilita (nasconde) la scroll-bar verticale | + + La menu-bar e' comunque attivabile/disattivabile manualmente con il + comando ~M-x toggle-scroll-bar~ + + #+begin_src emacs-lisp + (toggle-scroll-bar -1) + #+end_src + +**** Gestisce la file-dialog + + Questa opzione entra in gioco in modalita' GUI quando, tramite menu-bar + o tool-bar, si esegue una operazione che richiede un file. Se la + file-dialog e' abilitata viene mostrata una dialog box grafica secondo + le impostazioni del sistema operativo; se invece e' disabilitata si + opera nel minibuffer come quando, ad esempio, si visita un file con + ~C-x C-f~. Per gestire questa impostazione si imposta la variabile + ~use-file-dialog~ + + Sarebbe da valutare l'opportunita' di gestire questa impostazione + in =early-init.el=. + + | Valore argomento | Descrizione | + |------------------+------------------------------------| + | non ~nil~ | Abilita l'uso della file-dialog | + | ~nil~ | Disabilita l'uso della file-dialog | + + #+begin_src emacs-lisp + (setq use-file-dialog nil) + #+end_src + +**** Gestisce le dialog-box per le conferme + + Questa opzione gestisce l'uso o meno delle richieste di conferma + "grafiche" tramite l'uso di una dialog-box quando un "evento" + scatenato dal mouse necessita di una conferma. Si applica alle + richieste ~y-or-n-p~ e ~yes-or-no-p~. Per fare questo si imposta + la variabile ~use-dialog-box~ + + Sarebbe da valutare l'opportunita' di gestire questa impostazione + in =early-init.el=. + + | Valore argomento | Descrizione | + |------------------+-----------------------------------| + | non ~nil~ | Abilita l'uso della dialog-box | + | ~nil~ | Disabilita l'uso della dialog-box | + + #+begin_src emacs-lisp + (setq use-dialog-box nil) + #+end_src + +**** Imposta la gestione dei backup e degli auto-save + + E' possibile disabilitare sia la creazione dei files di backup + che gli auto-saves. + + Tutte e due queste variabili accettano: + + | Valore argomento | Descrizione | + |------------------+----------------------------| + | non ~nil~ | Attiva la funzionalita' | + | ~nil~ | Disattiva la funzionalita' | + + #+begin_src emacs-lisp + (setq make-backup-files t + auto-save-default t) + #+end_src + +**** Gestisce le combinazioni "fastidiose" + + Alcune combinazioni di tasti presenti per impostazione predefinita sono + piuttosto infelici. + - ~C-z~: "sospende" il frame. In ambiente GUI riduce semplicemente + ad icona, in ambiente terminale sospende il processo di Emacs + mettendolo in background e uscendo alla shell; il processo puo' + poi essere "ripreso". _Non funziona in Microsoft Windows_. + La combinazione e' infelice perche' universalmente abbinata alla + funzionalita' di "undo" e per questo facilmente richiamabile + per errore. Volendo puo' comunque essere richiamata tramite il + comando ~M-x suspend-frame~ + - ~C-h h~: funzionalita' inutile che mostra le capacita' di rendering + dei font non latini di Emacs. Volendo puo' essere richiamata + tramite il comando ~M-x view-hello-file~ + + Per gestire quest impostazioni si utilizza una funzionalita' messa + a disposizione da =use-package=. La funzionalita' ~:bind~ consente + la gestione degli abbinamenti tra comandi e combinazioni di tasti. + + E' possibile richimare =use-package= con un nome di package "speciale": + =emacs= che non e' un package vero e proprio, ma e' comunque gestito + correttamente (esempio trovato in rete: [[https://protesilaos.com/dotemacs/]]). + + Oltretutto sembra possibile richiamare piu' volte =use-package= sullo stesso + package fornento integrazioni alle impostazioni. Impostazioni che vengono + gestite nell'ordine che si presentano. + + #+begin_src emacs-lisp + (use-package emacs + :bind (("C-z" . nil) + ("C-h h" . nil)) + ) + #+end_src + +**** Gestisce le combinazioni di tasti per ibuffer + + =ibuffer= e' un'alternativa avanzata al =buffer-menu= e alla funzione + =list-buffers= e consente di gestire i buffers in una modalita' + simile a =dired=. + + Vado a modificare l'abbinamento standard di Emacs per la combinazione + di tasti =C-x C-b= sostituendo la chiamata a =list-buffers= con + =ibuffer=. + + #+begin_src emacs-lisp + ;; (use-package emacs + ;; :bind ([remap list-buffers] . ibuffer) + ;; ) + (global-set-key [remap list-buffers] 'ibuffer) + #+end_src + +**** Gestisce le richieste Si/No + + In Emacs le richieste che prevedono risposta Si/No sono di due tipi e + e gestite da due funzioni: + - =y-or-n-p= :: Richiesta Yes/No a cui e' possibile rispondere con un + solo tasto (Y/N). Generalmente usata per richieste alle quali una + risposta poco attenta non provoca gravi consequenze + - =yes-or-no-p= :: Richiesta Yes/No che necessita di una maggiore attenzione + perche' una risposta errata potrebbe creare dei problemi maggiori, + per questo necessitano di una risposta esplicita. Per queto e' necesario + risponere in modo completo. + + E' possibile "accorciare" la riposta usando l'istruzione + =(fset 'yes-or-no-p 'y-or-n-p)=. Al momento preferisco pero' non usare questa + scorciatoia. + +**** Imposta il sistema di encoding + + Imposta il sistema di encoding predefinito a =utf-8= questo uniforma il + comportamento tra GNU/Linux e MS Windows. Si potrebbero comunque verificare + disagi quando si andranno a modificare files gia' esistenti, creati con un + altro editor che, in MS Windows, hanno mantenuto l'impostazione di default + del sistema opreativo e' solitamente "Windows-1252" (almeno in Italia). + + [[https://www.masteringemacs.org/article/working-coding-systems-unicode-emacs]] + + #+begin_src emacs-lisp + (prefer-coding-system 'utf-8) + (set-default-coding-systems 'utf-8) + (set-terminal-coding-system 'utf-8) + (set-keyboard-coding-system 'utf-8) + + ;; backwards compatibility as default-buffer-file-coding-system + ;; is deprecated in 23.2. + (if (boundp 'buffer-file-coding-system) + (setq-default buffer-file-coding-system 'utf-8) + (setq default-buffer-file-coding-system 'utf-8)) + + ;; Treat clipboard input as UTF-8 string first; compound text next, etc. + (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)) + + ;; Messages encoding system + (setq locale-coding-system 'utf-8) + #+end_src + +**** Mostra la "highlight line" + + Lo faccio soltanto se sono nella GUI altrimenti e' troppo invasivo + dal punto di vista visuale. + + #+begin_src emacs-lisp + (when (window-system) + (global-hl-line-mode 1)) + #+end_src + +**** Disattiva il continuamento riga + + L'impostazione di default di Emacs prevede che righe contenenti + testo piu' lungo della dimensione della window vengano + continuate nella riga successiva ed evidenziate con un apposito + simbolo. + Con questa impostazione si imposta il funzionamento piu' o meno + consolidato nel resto del mondo: la riga prosegue "uscendo" + dallo schermo. + + E' possibile alternare questa impostazione anche una volta che + Emacs e' partito usando il comando =M-x toggle-truncate-line= + + #+begin_src emacs-lisp + (setq-default truncate-lines t) + #+end_src + +**** Mostra la parentesi abbinata + + #+begin_src emacs-lisp + (show-paren-mode 1) + #+end_src + +**** Scroll verticale "come te lo aspetteresti" + + L'impostazione di default di Emacs per lo scroll verticale e' quella di + portare il cursore al centro della window quando questo esce dall'area + visibile. Questo causa uno spostamento "a balzi" che puo' essere fastidioso. + + Questo e' uno dei metodi per impostare uno scroll verticale che incontri + le normali aspettative. + + #+begin_src emacs-lisp + (setq scroll-conservatively most-positive-fixnum) + #+end_src + +**** Scroll orizzontale come te lo aspetteresti + + L'impostazione di default porta il cursore al centro del buffer quando si + esegue uno scroll orizzontale e il cursore esce dallo schermo causando un + movimento "a balzi" che puo' essere fastidioso. + + Con questa impostazione lo scroll orizzontale viene impostato per comportarsi + come normalmente avviene: un carattere per volta. + + #+begin_src emacs-lisp + (setq hscroll-step 1) + #+end_src + +**** Bell + + Disattiva il "ding", per il momento mantengo attivo il "flashing" check + mostra visivamente l'equivalente del "ding". E' possibile disattivare anche + il flashing impostando =visbile-bell nil=. Il ding audio e' disattivato + usando come funzione associata una funzione inesistente "ignore". + + #+begin_src emacs-lisp + (setq visible-bell t + ring-bell-function 'ignore) + #+end_src + +**** Delete selection + + Il comportamento normale di Emacs e' quello di inserire il testo dove e' + posizionato il cursore anche quando e' in corso una selezione del testo + (si e' selezionata auna "region"). Questo comportamento e' diverso da + quello usato dalla maggior parte delle applicazioni attuali dove la + digitando il testo questo va a sostituire quello selezionato. + + #+begin_src emacs-lisp + (delete-selection-mode t) + #+end_src + +**** Tabulazioni + + Gestione delle impostazioni relative alle tabulazioni. + In certi ambiti le impostazioni sono "arcaiche" o diverse da quelle che + normalmente ci si possono aspettare. + + L'impostazione predefinita sara' di usare gli spazi al posto dei "tab". + + #+begin_src emacs-lisp + (setq-default indent-tabs-mode nil) + #+end_src + + Con la dimensione di una tabulazione espressa come 4 spazi. + + #+begin_src emacs-lisp + (setq-default tab-width 4) + #+end_src + + Creo quindi una "lista" di tabulazioni ogni 4 caratteri (un po' come + nelle vecchie macchine per scrivere o nei programmi tipo Word), iniziando + dal 4° carattere e ogni 4 caratteri fino al raggiungimento dei 200 caratteri. + + #+begin_src emacs-lisp + (setq tab-stop-list + (number-sequence 4 200 4)) + #+end_src + +**** Impostazioni per la stampa + + #+begin_src emacs-lisp + ;; Devo caricare il modulo di supporto per la stgampa + (require 'ps-print) + ;; Imposto il formato pagina a "A4" + (setq ps-paper-type 'a4) + ;; (setq ps-print-color-p 'black-white) + (setq doc-view-continuous t) + (cond ((eq system-type 'windows-nt) + ;; Windows-specific code goes here. + ;; ATTENZIONE + ;; Se si installa una versione diversa di GhostScript RICORDARSI + ;; di modificare qui i percorsi!!!!! + (setq ps-lpr-command "C:/Program Files/gs/gs9.50/bin/gswin64c.exe") + (setq ps-lpr-switches '("-q" + "-dNOPAUSE" + "-dBATCH" + "-dNoCancel" + "-sDEVICE=mswinpr2" + ;; "-IC:/Program Files/gs/gs9.50/lib" + ;; "-sFONTPATH=C:/Windows/Fonts" + ;; "-sOutputICCProfile=default_cmyk.icc" + ;; "-dBitsPerPixel=24" + ;; "-dEmbedAllFonts=true" + )) + (setq doc-view-ghostscript-program "C:/Program Files/gs/gs9.50/bin/gswin64c.exe") + (setq ps-printer-name t) + (setq ps-printer-name-option nil) + ) + ((eq system-type 'gnu/linux) + ;; Linux-specific code goes here. + )) + + ;; Start Emacs fullscreen mode + ;; (add-hook 'emacs-startup-hook 'toggle-frame-maximized) + #+end_src + +*** Package aggiuntivi + +**** Async + + Consente l'uso di processi asincroni quando possibile. + + #+begin_src emacs-lisp + (use-package async + :ensure t + :init + (dired-async-mode 1) + ) + #+end_src + +**** All-the-icons + + I package /all-the-icons/ installano font e immagini che possono essere + usati in abbinamento alle varie voci che Emacs mostra. Ad esempio + mostrando una lista di files ecc. + +***** All-the-icons + + =all-the-icons= e' un package che installa una quantita' di immagini + grafiche che possono essere usate per identificare meglio files e/o + contesti. Il package necessita di una parte di configurazione + manuale (in MS Windows) per l'installazione dei fonts necessari. + + Occorre leggere la documentazione sul sito del produttore: + [[https://github.com/domtronn/all-the-icons.el]] + + Il package deve essere attivato immediatamente dopo l'installazione + altrimenti gli altri package che lo usano non lo troveranno attivo + e non mostreranno le icone. Per questo si usa =:demand t= + + Naturalmente ha senso usare questo package soltanto quando siamo + in ambiente grafico, per questo uso =:if (window-system)= + + #+begin_src emacs-lisp + (use-package all-the-icons + :if (window-system) + :ensure t + :demand t + ) + #+end_src + +***** All-the-icons-dired + + Usa quanto fornito da =all-the-icons= nei buffer =dired= + + Questo package viene caricato in modalita' differita (non viene + caricato al momento della lettura di =use-package=) quando viene + attivato. L'attivazione avviene, tramite =dired-mode-hook=, + quando si apre un buffer =dired=. + + #+begin_src emacs-lisp + (use-package all-the-icons-dired + :if (window-system) + :ensure t + :defer t + :after all-the-icons + :hook (dired-mode-hook . all-the-icons-dired-mode) + ) + #+end_src + +***** All-the-icons-ibuffer + + Mostra le icone di =all-the-icons= negli =ibuffer= + + Questo package viene caricato in modalita' differita quando si + apre un buffer =ibuffer= (tramite =ibuffer-mode-hook=). + + #+begin_src emacs-lisp + (use-package all-the-icons-ibuffer + :if (window-system) + :ensure t + :defer t + :hook (ibuffer-mode-hook . all-the-icons-ibuffer-mode) + :after all-the-icons + ) + #+end_src + +**** Color themes + + Sono i temi di Emacs. Ce ne sono veramente una quantita' enorme ed esistono + anche siti che ne consentono la ricerca con anteprima ([[https://emacsthemes.com/][emacsthemes]]). + + Qui installo con =use-package= alcuni temi. E' necessario che i temi vengano + installati con l'opzione =:defer t= altrimenti, dopo l'installazione vengono + anche attivati con lo sgradevole effetto del passaggio in serie da un tema + all'altro ciclando su tutti i temi scelti. + + Naturalmente ha senso usare questi package soltanto quando siamo + in ambiente grafico, per questo uso =:if (window-system)= in ciascun blocco + =use-package= + + Alla versione 27.1 con Emacs vengono distribuiti i seguenti temi: + - =adwaita-theme= + - =deeper-blue-theme= + - =dichromacy-theme= + - =leuven-theme= + - =light-blue-theme= + - =manoj-dark-theme= + - =misterioso-theme= + - =tango-dark-theme= + - =tango-theme= + - =tsdh-dark-theme= + - =tsdh-light-theme= + - =wheatgrass-theme= + - =whiteboard-theme= + - =wombat-theme= + +***** Installo i package dei temi aggiuntivi + +****** Doom + + Questo package contiene una raccolta di color-themes usati dal + produttore di doom-emacs. + + Molti di questi temi sono riproduzioni o adattamenti di temi + prodotti da altri. Tra questi si possono trovare versioni di + /Gruvbox/, /Monokai/ ecc. + + Qui ho utilizzato la configurazione di esempio mostrata sul sito + del produttore: [[https://github.com/hlissner/emacs-doom-themes]] + togliendo soltanto l'istruzione che attiva il tema: + =(load-theme 'doom-one t)= + + #+begin_src emacs-lisp + (use-package doom-themes + :if (window-system) + :ensure t + :defer t + :config + ;; Global settings (defaults) + (setq doom-themes-enable-bold t ; if nil, bold is universally disabled + doom-themes-enable-italic t) ; if nil, italics is universally disabled + + ;; Enable flashing mode-line on errors + (doom-themes-visual-bell-config) + + ;; Enable custom neotree theme (all-the-icons must be installed!) + ;; (doom-themes-neotree-config) + ;; or for treemacs users + (setq doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme + (doom-themes-treemacs-config) + + ;; Corrects (and improves) org-mode's native fontification. + (doom-themes-org-config) + ) + #+end_src + +****** Spacemacs + + Tema standad per [[https://github.com/syl20bnr/spacemacs][Spacemacs]]. + + Dispone di due modalita': + - *Dark*: =spacemacs-dark= + - *Light*: =spacemacs-light= + + #+begin_src emacs-lisp + (use-package spacemacs-theme + :if (window-system) + :ensure t + :defer t + ) + #+end_src + +****** Material + + Tema basato sui colori proposti dal [[http://www.google.com/design/spec/style/color.html#color-color-palette][Google Material Design]] + + Dispone di due modalita': + - *Dark*: =material= + - *Light*: =material-light= + + #+begin_src emacs-lisp + (use-package material-theme + :if (window-system) + :ensure t + :defer t + ) + #+end_src + +****** Zenburn + + Trasposizione per Emacs del popolare colorscheme di Vim. + Tema dark a basso contrasto. + + #+begin_src emacs-lisp + (use-package zenburn-theme + :if (window-system) + :ensure t + :defer t + ) + #+end_src + +****** Monokai + + Trasposizione per Emacs del popolare tema Monokai di Textmate. + + #+begin_src emacs-lisp + (use-package monokai-theme + :if (window-system) + :ensure t + :defer t + ) + #+end_src + +****** Gruvbox + + Trasposizione per Emacs del popolare colorscheme di Vim. + + Dispone delle seguenti modalita': + - *Dark* + - *medium*: =gruvbox-dark-medium= (default) + - *soft*: =gruvbox-dark-soft= + - *hard*: =gruvbox-dark-hard= + - *Light* + - *medium*: =gruvbox-light-medium= + - *soft*: =gruvbox-light-soft= + - *hard*: =gruvbox-light-hard= + + #+begin_src emacs-lisp + (use-package gruvbox-theme + :if (window-system) + :ensure t + :defer t + ) + #+end_src + +****** Modus themes + + Temi creati da [[https://protesilaos.com/][Protesilaos Stavrou]] + + Sono due temi di tipo [[https://www.w3.org/WAI/standards-guidelines/][WCAG AAA]]. + + I due vecchi packages (modus-vivendi e modus-operandi) sono stati recentemente unificati in un unico + package "modus-themes". La distribuzione e' inoltre passata da MELPA a ELPA + + #+begin_src emacs-lisp + (use-package modus-themes + ;; Da notare che questo tema e' valido sia in ambiente grafico + ;; che in ambiente terminale. Per questo lo carico comunque + ;; indipendentemente dal fatto che sia in "window-system" o meno + ;; :if (window-system) + :ensure t + :defer t + ) + #+end_src + +****** Zerodark + + Un tema *dark* suggerito da [[https://github.com/daedreth/UncleDavesEmacs#a-nice-theme][Uncle Dave]]. + + #+begin_src emacs-lisp + (use-package zerodark-theme + :if (window-system) + :ensure t + :defer t + ) + #+end_src + +****** Atom one-dark + + #+begin_src emacs-lisp + (use-package atom-one-dark-theme + :if (window-system) + :ensure t + :defer t + ) + #+end_src + +****** Dracula + + #+begin_src emacs-lisp + (use-package dracula-theme + :if (window-system) + :ensure t + :defer t + ) + #+end_src + +****** Tomorrow + + #+begin_src emacs-lisp + (use-package color-theme-sanityinc-tomorrow + :if (window-system) + :ensure t + :defer t + ) + #+end_src + +****** Solarized + + #+begin_src emacs-lisp + (use-package solarized-theme + :if (window-system) + :ensure t + :defer t + ) + #+end_src + +****** Moe + + #+begin_src emacs-lisp + (use-package moe-theme + :if (window-system) + :ensure t + :defer t + ) + #+end_src + +****** Seti + + #+begin_src emacs-lisp + (use-package seti-theme + :if (window-system) + :ensure t + :defer t + ) + #+end_src + +****** Base16 + + #+begin_src emacs-lisp + (use-package base16-theme + :if (window-system) + :ensure t + :defer t + ) + #+end_src + +***** Attivo il tema che piu' mi piace in questo momento + + Imposto il tema considerando il fatto che emacs sia in esecuzione in + modalita' grafica o terminale. + + Di seguito un elenco dei vari temi che possono essere installati + + #+begin_src emacs-lisp :tangle no + ;; (load-theme 'doom-one t) + ;; + ;; (progn + ;; ;; Add all your customizations prior to loading the themes + ;; (setq modus-themes-slanted-constructs t + ;; modus-themes-bold-constructs nil + ;; modus-themes-region 'no-extend) + ;; ;; Load the theme files before enabling a theme (else you get an error). + ;; (modus-themes-load-themes) + ;; ;; Load the theme of your choice: + ;; ;; OR (modus-themes-load-vivendi) + ;; ;; OR (modus-themes-load-operandi) + ;; (modus-themes-load-vivendi) + ;; ) + ;; + ;; (load-theme 'spacemacs-dark t) + ;; + ;; (load-theme 'monokai t) + ;; + ;; (load-theme 'gruvbox t) + ;; + ;; (load-theme 'zenburn t) + ;; + ;; (load-theme 'zerodark t) + ;; + ;; (load-theme 'atom-one-dark-theme t) + ;; + ;; (load-theme 'material t) + #+end_src + + #+begin_src emacs-lisp + (if (display-graphic-p) + (progn + ;; Add all your customizations prior to loading the themes + (setq modus-themes-slanted-constructs t + modus-themes-bold-constructs nil + modus-themes-region 'no-extend) + ;; Load the theme files before enabling a theme (else you get an error). + (modus-themes-load-themes) + ;; Load the theme of your choice: + ;; OR (modus-themes-load-vivendi) + ;; OR (modus-themes-load-operandi) + (modus-themes-load-vivendi)) + (progn + ;; Add all your customizations prior to loading the themes + (setq modus-themes-slanted-constructs t + modus-themes-bold-constructs nil + modus-themes-region 'no-extend) + ;; Load the theme files before enabling a theme (else you get an error). + (modus-themes-load-themes) + ;; Load the theme of your choice: + ;; OR (modus-themes-load-vivendi) + ;; OR (modus-themes-load-operandi) + (modus-themes-load-vivendi)) + ) + #+end_src + +**** Gestione della modeline + + Nell'[[info:emacs#Screen][organizzazione dello schermo]] di Emacs la [[info:emacs#Mode Line][modeline]] e' quella parte del + [[info:emacs#Frames][frame]] di Emacs che si va a trovare nella parte inferiore di ogni [[info:emacs#Windows][window]] e, + come spiegato nel manuale di Emacs, "descrive cosa sta accadendo nel [[info:emacs#Buffers][buffer]] + corrente" + +***** Doom modeline + + Esistono molti modi di "personalizzare" la modeline. E' possibile farlo + direttamente nella configurazione di Emacs oppure e' possibile usare uno + dei tanti package disponibili. Tra i vari package ho scelto =doom-modeline= + perhche' mi sembra un buon compromesso tra la veste grafica e la quantita' + di informazioni presentate. + + *N.B:*: =doom-modeline= richiede, per funzionare correttamente che in precedenza + sia stato installato, configurato e caricato correttamente il package + =all-the-icons=. E' inoltre /fortemente consigliato/ l'abbiamenteo ad uno + dei =doom-themes= + + Le impostazioni di sono quelle suggerite dal produttore. + + Naturalmente ha senso usare questo package soltanto quando siamo + in ambiente grafico, per questo uso =:if (window-system)= + + #+begin_src emacs-lisp + (use-package doom-modeline + :if (window-system) + :ensure t + :after all-the-icons + ;;:init (doom-modeline-mode 1) + :hook (after-init-hook . doom-modeline-mode) + ) + #+end_src + +***** Minions + + Questo package consente la gestione dei minor modes tramite un menu della tool-bar. + Riduce quindi il numero di voci "lighter" presenti nella toolbar e li raggruppa + in una sola voce. + + Attivo =minions-mode= quando ho terminato l'inizializzazione tramite l'apposito + hook. + + Imposto =toom-modeline-minor-modes= a =t= per mostrare i minor modes nella + =doom-modeline= + + Naturalmente ha senso usare questo package soltanto quando siamo + in ambiente grafico, per questo uso =:if (window-system)= + + #+begin_src emacs-lisp + (use-package minions + :if (window-system) + :ensure t + :hook (after-init-hook . minions-mode) + :custom (doom-modeline-minor-modes t) + ) + #+end_src + +***** Mostra informazioni sulla riga e colonna e colonna corrente + + Con queste impostazioni sia il numero di riga che il numero di colonna + vengono mostrati nella modeline. + + #+begin_src emacs-lisp + (setq line-number-mode t + column-number-mode t) + #+end_src + + Queste impostazioni, invece, servono a mostrare il numero accanto ad ogni riga + del buffer. + + #+begin_src emacs-lisp + ;; Per adesso non mostro i numeri di riga sul lato della window + ;; (global-display-line-numbers-mode) + #+end_src + +<<<<<<< HEAD +**** Dashboard + + Dasboard attiva soltanto in ambiente grafico + + #+begin_src emacs-lisp + (use-package dashboard + :ensure t + :if (window-system) + :config + (dashboard-setup-startup-hook) + ;; (setq dashboard-startup-banner "~/.emacs.d/img/Logog-b.png") + (setq dashboard-startup-banner "~/.emacs.d/img/Logog-b.png" + ;; dashboard-startup-banner "~/.emacs.d/img/Logob-w.png" + dashboard-set-heading-icons t + dashboard-set-file-icons t + dashboard-image-banner-max-height 250 + dashboard-image-banner-max-width 250) + ) + #+end_src + +======= +>>>>>>> 882e78da61898ea1a55ccd08f8d569598fe1179c +**** Discoverability + +***** Which-key + + Si tratta di un package che aiuta nella comprensione delle combinazione + dei tasti di Emacs. Iniziando a digitare una qualsiasi combinazione + di tasti =C-=, =M-=, =S-= ecc. mostra in un buffer popup tutti i tasti + che possono essere scelti con una breve spiegazione. + + Elimino il lighter dalla modeline: serve soltanto per attivare/disattivre + il minor-mode. + + + #+begin_src emacs-lisp + (use-package which-key + :ensure t + :defer 5 + :delight + :commands which-key-mode + :config + (which-key-mode) + ) + #+end_src + +***** Hydra + + Consente la creazione di "popup" personalizzati che, alla pressione di + una combinazione di tasti, si attivano mostrando quali ulteriori tasti + possono essere utilizzati e a quale funzionalita' sono abbinati. + + Mentre =which-key= mostra le combinazioni "standard", =hydra= consente + la crazioni di reaggruppamenti non standard. + + #+begin_src emacs-lisp + (use-package hydra + :ensure t + :defer t + ) + #+end_src + +**** Dashboard + + Dashboard attiva soltanto in ambiente grafico + + #+begin_src emacs-lisp + (use-package dashboard + :ensure t + :if (window-system) + :config + (dashboard-setup-startup-hook) + ;; (setq dashboard-startup-banner "~/.emacs.d/img/Logog-b.png") + (setq dashboard-startup-banner "~/.emacs.d/img/Logog-b.png" + ;; dashboard-startup-banner "~/.emacs.d/img/Logob-w.png" + dashboard-set-heading-icons t + dashboard-set-file-icons t + dashboard-image-banner-max-height 250 + dashboard-image-banner-max-width 250) + ) + #+end_src + +**** Ivy / Counsel / Swiper + +***** Ivy + + + Elimino il lighter dalla modeline: serve soltanto per attivare/disattivre + il minor-mode. + + #+begin_src emacs-lisp + (use-package ivy + :ensure t + :delight + ;; :hook (after-init-hook . ivy-mode) + :custom + (ivy-use-virtual-buffers t) + (enable-recursive-minibuffers t) + (ivy-count-format "%d/%d ") + :config + ;; Key bingings - Ivy based interface to stanard commands + ;; (global-set-key (kbd "C-x b") 'ivy-switch-buffer) + (global-set-key (kbd "C-c v") 'ivy-push-view) + (global-set-key (kbd "C-c V") 'ivy-pop-view) + ;; Key bindints - Ivy resume + (global-set-key (kbd "C-c C-r") 'ivy-resume) + (ivy-mode 1) + ) + #+end_src + +***** Swiper + + #+begin_src emacs-lisp + (use-package swiper + :ensure t + :after ivy + :config + ;; Key bindings - Ivy based interface to standard commands + (global-set-key (kbd "C-s") 'swiper-isearch) + ) + #+end_src + +***** Counsel + + Elimino il lighter dalla modeline: serve soltanto per attivare/disattivre + il minor-mode. + + #+begin_src emacs-lisp + (use-package counsel + :ensure t + :delight + :after (ivy swiper) + :config + (counsel-mode t) + ;; (global-set-key (kbd " u") 'counsel-unicode-char) + ;; (global-set-key (kbd "C-c g") 'counsel-git) + ;; (global-set-key (kbd "C-c j") 'counsel-git-grep) + ;; ;; (global-set-key (kbd "C-c k") 'counsel-ag) + ;; ;; (global-set-key (kbd "C-x l") 'counsel-locate) + ;; ;; (global-set-key (kbd "C-S-o") 'counsel-rhythmbox) + (define-key read-expression-map (kbd "C-r") 'counsel-expression-history) + ;; Key bindings - Ivy/Counsel interface to standard commands + (global-set-key (kbd "M-x") 'counsel-M-x) + (global-set-key (kbd "C-x C-f") 'counsel-find-file) + (global-set-key (kbd "M-y") 'counsel-yank-pop) + (global-set-key (kbd " f") 'counsel-describe-function) + (global-set-key (kbd " v") 'counsel-describe-variable) + (global-set-key (kbd " l") 'counsel-find-library) + (global-set-key (kbd " i") 'counsel-info-lookup-symbol) + (global-set-key (kbd " u") 'counsel-unicode-char) + (global-set-key (kbd " j") 'counsel-set-variable) + (global-set-key (kbd "C-x b") 'counsel-switch-buffer) + ;; Key bindings - Ivy/Counsel interface to shell and system tools + (global-set-key (kbd "C-c c") 'counsel-compile) + (global-set-key (kbd "C-c g") 'counsel-git) + (global-set-key (kbd "C-c j") 'counsel-git-grep) + (global-set-key (kbd "C-c L") 'counsel-git-log) + (global-set-key (kbd "C-c k") 'counsel-rg) + (global-set-key (kbd "C-c m") 'counsel-linux-app) + (global-set-key (kbd "C-c n") 'counsel-fzf) + (global-set-key (kbd "C-x l") 'counsel-locate) + (global-set-key (kbd "C-c J") 'counsel-file-jump) + (global-set-key (kbd "C-S-o") 'counsel-rhythmbox) + (global-set-key (kbd "C-c w") 'counsel-wmctrl) + ;; Key bindings - Counsel other commands + (global-set-key (kbd "C-c b") 'counsel-bookmark) + (global-set-key (kbd "C-c d") 'counsel-descbinds) + (global-set-key (kbd "C-c g") 'counsel-git) + (global-set-key (kbd "C-c o") 'counsel-outline) + (global-set-key (kbd "C-c t") 'counsel-load-theme) + (global-set-key (kbd "C-c F") 'counsel-org-file) + ) + #+end_src + +****** Counsel-etags + + _*Per il momento disabilitato, da valutare se serve veramente*_ + + #+begin_src emacs-lisp + (use-package counsel-etags + :disabled + :ensure t + :after counsel + ;; :bind (("C-]" . counsel-etags-find-tag-at-point)) + :init + (add-hook 'prog-mode-hook + (lambda () + (add-hook 'after-save-hook + 'counsel-etags-virtual-update-tags 'append 'local))) + :custom + (counsel-etags-update-interval 60) + :config + (push "build" counsel-etags-ignore-directories) + ) + #+end_src + +****** Counsel-css + + _*Per il momento disabilitato, da valutare se serve veramente*_ + + #+begin_src emacs-lisp + (use-package counsel-css + :disabled + :ensure t + :defer t + :after counsel + :hook (css-mode-hook . counsel-css-imenu-setup) + ) + #+end_src + +***** Ivy-rich + + #+begin_src emacs-lisp + (use-package ivy-rich + :ensure t + :after (ivy counsel) + ;; :init + ;; (ivy-rich-mode 1) + :config + (ivy-rich-mode 1) + ) + #+end_src + +***** All-the-icons-ivy-rich + + #+begin_src emacs-lisp + (use-package all-the-icons-ivy-rich + :if (window-system) + :ensure t + :after (ivy counsel ivy-rich all-the-icons) + ;; :init + ;; (all-the-icons-ivy-rich-mode 1) + :config + (all-the-icons-ivy-rich-mode 1) + ) + #+end_src + +***** Ivy-Hydra + + #+begin_src emacs-lisp + (use-package ivy-hydra + :ensure t + :defer t + :after (ivy hydra) + ) + #+end_src + +**** Amx + +#+begin_src emacs-lisp + (use-package amx + :ensure t + :defer t + :after (:all counsel) + ;; :bind (("M-X" . amx-major-mode-commands)) + :config (amx-mode t) + ) +#+end_src + +**** Org-mode + + Org-mode e' gia' stato caricato in =init.el=, qui si vanno ad aggiungere + alcune impostazioni. + + #+begin_src emacs-lisp + (use-package org + :defer t + :config + ;; Aggiungo exporter normalmente non abilitati + (add-to-list 'org-export-backends 'ascii) + (add-to-list 'org-export-backends 'beamer) + (add-to-list 'org-export-backends 'md) + (add-to-list 'org-export-backends 'org) + (progn (add-to-list 'org-latex-packages-alist '("" "tabularx" nil)) + (add-to-list 'org-latex-packages-alist '("" "tabu" nil)) + ) + ) + #+end_src + +***** Org-bullets + + Miglioramento grafico dei simboli per gli header di org. + Normalmente sarebbero degli asterischi, qui si unsano dei simboli. + + *N.B.*: ricordarsi che nel cosa si voglia stampare un file org + e' necessario disattivare =org-bullets-mode= altrimenti la stampa + che si ottiene presenta degli asterischi (secondo lo standar org) + e dei punti interrogativi (?) dovuti a problemi di rendering dei + caratteri utilizzati per i bullets. + + Questo package ha senso solo in ambiente grafico. + + Imposto qui =org-hide-leading-stars= e non in org perche' + qui mi interessa non mostrare artefatti prima del simbolo + grafico. + + #+begin_src emacs-lisp + (use-package org-bullets + :if (window-system) + :ensure t + :defer t + :hook (org-mode-hook . org-bullets-mode) + :after (org) + :custom + (org-hide-leading-stars t) + ) + #+end_src + +***** Org-superstar-mode + + Il nuovo package che mira a sostituire =org-bullet= + + Questo package ha senso solo in ambiente grafico. + + Imposto qui =org-hide-leading-stars= e non in org perche' + qui mi interessa non mostrare artefatti prima del simbolo + grafico. + + *DISATTIVO PERCHE' HA PERFORMACNES _PESSIME_ NELLA RICERCA!!!!* + + #+begin_src emacs-lisp + (use-package org-superstar + :disabled + :if (window-system) + :ensure t + :defer t + :after org + :hook (org-mode-hook . org-superstar-mode) + :custom + (org-hide-leading-stars t) + ) + + #+end_src + +***** Org-edna + + #+begin_src emacs-lisp + (use-package org-edna + :ensure t + :defer t + :after org + :hook (org-mode-hook . org-edna-mode) + :config + (org-edna-load) + ) + #+end_src + +**** htmlize + + #+begin_src emacs-lisp + (use-package htmlize + :ensure t + :defer t + ) + #+end_src + +**** Beacon + + Mostra un artifatto grafico partendo dal punto in cui si trova il cursore + rendendone piu' visibile la posizione secondo la metafora del fascio di + luce di un faro (beacon = faro). + + - beacon-mode :: E' la funzione che attiva o disattiva il beacon + + | Valore argomento | Descrizione | + |------------------+----------------------| + | ~>0~ | Abilita il beacon | + | ~<=0~ | Disabilita il beacon | + + Il beacon puo' essere attivato/disattivato manualmente con il + comando ~M-x beacon-mode~ + + - beacon-blink-when-focused :: E' la variabile che indica se il + beacon deve essere visualizzato anche quando Emacs riprende il + focus dopo che si e' passati ad un'altra finestra. + + | Valore argomento | Descrizione | + |------------------+----------------------| + | ~t~ | Mostra il beacon | + | non ~t~ | Non mostra il beacon | + + - beacon-size :: Imposta la lunghezza in caratteri del beacon. + La sua impostazione di default (40 caratteri) non rende particolarmente + visibile il beacon. Si puo' pero' allungare cambiando l'impostazione + con un valore maggiore + + Purtroppo sembra che Beacon abbia dei problemi con di funzionamento + in modalita' non grafica (terminale). Con il terminale il beacon + viene mostrato, ma non viene poi sempre rimosso. Per questo lo + abilito soltanto in modalita' GUI usando =:if (window-system)= + + Elimino il lighter dalla modeline: serve soltanto per attivare/disattivre + il minor-mode. + + #+begin_src emacs-lisp + (use-package beacon + :if (window-system) + :ensure t + :defer t + :delight + :hook (after-init-hook . beacon-mode) + :custom + (beacon-blink-when-focused t) + ;;(beacon-size 64) + :config + (beacon-mode 1) + ) + #+end_src + +**** System monitor + + Un piccolo monitor di sistema. + + #+begin_src emacs-lisp + (use-package symon + :ensure t + :defer t + ) + #+end_src + +**** Try + + _*NON USARE!*_ + + Try crea dei problemi enormi con Emacs 27+ perche' in questa versione + di emacs viene gestito il file =package-quickstart.el= dove vengono + memorizzati i dati di autoload di tutti i packages. Peccato che vi + vengano memorizzati anche quelli che sono "temporanei" grazie alla + funzionalita' di =try= ma che non vengano rimossi alla chiusura di + Emacs. Quindi quando si apre nuovamente Emacs si ottengono degli + errori di inizializzazione. + + Per il momento non e' assolutamente da usare! Se proprio si vuole + usare occorre ricordarsi di eliminare il file =package-quickstart.el= + (e' la cosa piu' semplice) che comunque verra' ricreato auotomaticamente + da Emacs al primo riavvio. + + #+begin_src emacs-lisp + (use-package try + :disabled + :ensure t + :defer t + ) + #+end_src + +**** Avy + + #+begin_src emacs-lisp + (use-package avy + :ensure t + ) + #+end_src + +**** Gestione windows e buffrs + +***** Ace-window + + Vado a modificare l'abbinamento standard di Emacs per la combinazione + di tasti =C-x o= sostituendo la chiamata a =other-window= con + =ace-window= + + #+begin_src emacs-lisp + (use-package ace-window + :ensure t + :defer t + :after avy + :bind ([remap other-window] . ace-window) + ) + #+end_src + +**** Autocompletamento + + Emacs consente la scelta tra vari strumenti di autocompletamento. + Company quello che sembra ricevere maggiori apprezzamenti. + +***** Company + + Company consente l'uso di diversi backand aggiuntivi per l'autocompletamento. + + Imposto il ritardo per attivare l'autocompletamento a 0 ms in modo da avere + una risposta immediata (per default richiede comunque 3 caratteri). + + Attivo company-mode globalmente in modo che funzioni su qualsiasi buffer. + + Elimino il lighter dalla modeline: serve soltanto per attivare/disattivre + il minor-mode. + + #+begin_src emacs-lisp + (use-package company + :ensure t + :defer t + :delight + ;; :after yasnippet + :custom + (company-idle-delay 0.5) + (company-mimimum-prefix-length 3) + :hook (;;(prog-mode-hook . company-mode) + (after-init-hook . global-company-mode)) + ) + #+end_src + +***** Company quickhelp + + Un backend aggiuntivo per company. Mostra la documentazione relativa + all'elemento selezionato. + + #+begin_src emacs-lisp + (use-package company-quickhelp + :ensure t + :defer t + :after company + :custom + (company-quickhelp-delay 0.1) + :config + (company-quickhelp-mode 1) + ) + #+end_src + +**** Fondling - Origami + + #+begin_src emacs-lisp + (use-package origami + :ensure t + :defer t + :commands origami-mode + ) + #+end_src + +**** Undo-tree + + #+begin_src emacs-lisp + (use-package undo-tree + ;; Treat undo history as a tree + :ensure t + :defer t + :delight "Ut" + :bind (("C-z" . undo) + ("C-S-z" . undo-tree-redo)) + :config + (progn + (global-undo-tree-mode) + (setq undo-tree-visualizer-timestamps t) + (setq undo-tree-visualizer-diff t)) + ) + #+end_src + +**** Git + +***** Magit + + In Emacs standard (27,1) =C-x g= non e' agganciato a nessuna + funzionalita' + + #+begin_src emacs-lisp + (use-package magit + :ensure t + :defer t + :after (ivy) + :bind ("C-x g" . 'magit-status) + ) + #+end_src + +***** gitconfig-mode + + #+begin_src emacs-lisp + (use-package gitconfig-mode + :ensure t + :defer 5 + :mode ("/\\.gitconfig\\'" + "/\\.git/config\\'" + "/modules/.*/config\\'" + "/git/config\\'" + "/\\.gitmodules\\'" + "/etc/gitconfig\\'") + ) + #+end_src + +***** gitignore-mode + + #+begin_src emacs-lisp + (use-package gitignore-mode + :ensure t + :defer 5 + :mode ("/\\.gitignore\\'" + "/info/exclude\\'" + "/git/ignore\\'") + ) + #+end_src + +***** gitattribute-mode + + #+begin_src emacs-lisp + (use-package gitattributes-mode + :ensure t + :defer 5 + :mode ("/\\.gitattributes\\'" + "/info/attributes\\'" + "/git/attributes\\'") + ) + #+end_src + +***** git-timemachine + + #+begin_src emacs-lisp + (use-package git-timemachine + :ensure t + :defer t + :commands git-timemachine + ) + #+end_src + +**** Treemacs + + #+begin_src emacs-lisp + (use-package treemacs + :ensure t + :defer t + :commands treemacs + :init + (with-eval-after-load 'winum + (define-key winum-keymap (kbd "M-0") #'treemacs-select-window)) + :config + (progn + (setq treemacs-collapse-dirs (if treemacs-python-executable 3 0) + treemacs-deferred-git-apply-delay 0.5 + treemacs-directory-name-transformer #'identity + treemacs-display-in-side-window t + treemacs-eldoc-display t + treemacs-file-event-delay 5000 + treemacs-file-extension-regex treemacs-last-period-regex-value + treemacs-file-follow-delay 0.2 + treemacs-file-name-transformer #'identity + treemacs-follow-after-init t + treemacs-git-command-pipe "" + treemacs-goto-tag-strategy 'refetch-index + treemacs-indentation 2 + treemacs-indentation-string " " + treemacs-is-never-other-window nil + treemacs-max-git-entries 5000 + treemacs-missing-project-action 'ask + treemacs-move-forward-on-expand nil + treemacs-no-png-images nil + treemacs-no-delete-other-windows t + treemacs-project-follow-cleanup nil + treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory) + treemacs-position 'left + treemacs-recenter-distance 0.1 + treemacs-recenter-after-file-follow nil + treemacs-recenter-after-tag-follow nil + treemacs-recenter-after-project-jump 'always + treemacs-recenter-after-project-expand 'on-distance + treemacs-show-cursor nil + treemacs-show-hidden-files t + treemacs-silent-filewatch nil + treemacs-silent-refresh nil + treemacs-sorting 'alphabetic-asc + treemacs-space-between-root-nodes t + treemacs-tag-follow-cleanup t + treemacs-tag-follow-delay 1.5 + treemacs-user-mode-line-format nil + treemacs-user-header-line-format nil + treemacs-width 35 + treemacs-workspace-switch-cleanup nil) + + ;; The default width and height of the icons is 22 pixels. If you are + ;; using a Hi-DPI display, uncomment this to double the icon size. + ;;(treemacs-resize-icons 44) + + (treemacs-follow-mode t) + (treemacs-filewatch-mode t) + (treemacs-fringe-indicator-mode t) + (pcase (cons (not (null (executable-find "git"))) + (not (null treemacs-python-executable))) + (`(t . t) + (treemacs-git-mode 'deferred)) + (`(t . _) + (treemacs-git-mode 'simple)))) + :bind + (:map global-map + ("M-0" . treemacs-select-window) + ("C-x t 1" . treemacs-delete-other-windows) + ("C-x t t" . treemacs) + ("C-x t B" . treemacs-bookmark) + ("C-x t C-t" . treemacs-find-file) + ("C-x t M-t" . treemacs-find-tag))) + #+end_src + + #+begin_src emacs-lisp + (use-package treemacs-magit + :after (treemacs magit) + :ensure t + :defer t + ) + #+end_src + + #+begin_src emacs-lisp + (use-package treemacs-projectile + :after (treemacs projectile) + :ensure t + :defer t + ) + #+end_src + + + #+begin_src emacs-lisp + (use-package treemacs-all-the-icons + :after (treemacs all-the-icons) + :ensure t + :defer t + ) + #+end_src + +**** Internet + +***** Restclient + + #+begin_src emacs-lisp + (use-package restclient + :ensure t + :defer t + ) + #+end_src + + #+begin_src emacs-lisp + (use-package company-restclient + :ensure t + :after (company restclient) + :config + (add-to-list 'company-backends 'company-restclient) + ) + #+end_src + +***** Elfeed + + Devo disabilitare la cosa perche' ci sono problemi con org 9.4.4 + + #+begin_src emacs-lisp + (use-package elfeed + ;; + :disabled + ;; + :ensure t + :defer t + ;; Imposto la directory del db di elfeed per stare dentro .emacs.d + :custom ((elfeed-db-directory "~/Dropbox/Sync/emacs/elfeed/db") + (elfeed-enclosure-default-dir "~/Downloads/elfeed")) + :config + ;; (setq elfeed-feeds + ;; '("http://status.register.it/history.rss" + ;; "https://golem.linux.it/wp/feed/" + ;; ("http://dilbert.com/feed" Divertimento Webcomic) + ;; ("https://xkcd.com/rss.xml" Divertimento Webcomic) + ;; ("http://www.soft-land.org/rss/softland/commenti.rss" Divertimento Soft-land) + ;; ("http://www.soft-land.org/rss/softland/sdsm.rss" Divertimento Soft-land) + ;; ("http://www.soft-land.org/rss/softland/ospiti.rss" Divertimento Soft-land) + ;; ("https://bufalopedia.blogspot.com/feeds/posts/default" Antibufala Attivissimo) + ;; ("http://feeds.feedburner.com/Disinformatico" Antibufala Attivissimo) + ;; ("https://undicisettembre.blogspot.com/feeds/posts/default" Antibufala Attivissimo) + ;; ("https://complottilunari.blogspot.com/feeds/posts/default" Antibufala Attivissimo) + ;; ("http://www.valigiablu.it/feed/" Antibufala) + ;; ("https://blog.mikrotik.com/rss/?cat=security" CyberSecurity MikroTi) + ;; ("https://www.cert.garr.it/certrss" CyberSecurity CERT Cert-Italiani) + ;; ("https://www.certnazionale.it/news/feed/" CiberSecurity CERT Cert-Italiani) + ;; ("https://www.commissariatodips.it/feeds/rss.xml" CiberSecurity CERT Cert-Italiani) + ;; ("https://www.cert-pa.it/feed/" CiberSecurity CERT Cert-Italiani) + ;; ("https://www.us-cert.gov/ncas/all.xml" CiberSecurity CERT Cert-USA) + ;; ("https://www.us-cert.gov/ncas/alerts.xml" CiberSecurity CERT Cert-USA) + ;; ("https://www.us-cert.gov/ncas/bulletins.xml" CiberSecurity CERT Cert-USA) + ;; ("https://www.us-cert.gov/ncas/tips.xml" CiberSecurity CERT Cert-USA) + ;; ("https://www.us-cert.gov/ncas/current-activity.xml" CiberSecurity CERT Cert-USA) + ;; ("https://www.microsoft.com/technet/security/bulletin/secrss.aspx" CiberSecurity CERT Cert-USA Cert-Microsoft) + ;; ("https://www.microsoft.com/technet/security/bulletin/RssFeed.aspx?snscomprehensive" CiberSecurity CERT Cert-USA Cert-Microsoft) + ;; ("https://blogs.technet.microsoft.com/msrc/feed/" CiberSecurity CERT Cert-USA Cert-Microsoft) + ;; ("https://www.kaspersky.com/blog/feed/" CiberSecurity Kaspersky) + ;; ("https://securelist.com/feed/" CiberSecurity Kaspersky) + ;; ("https://threatpost.com/feed/" CiberSecurity Kaspersky) + ;; ("http://securityinfo.it/feed/?cat=251" CiberSecurity SecurityInfo) + ;; ("https://protesilaos.com/news.xml" Emacs) + ;; ("https://protesilaos.com/codelog.xml" Emacs) + ;; ("http://www.virtuouscode.com/feed/" Emacs) + ;; ("http://www.virtuouscode.com/comments/feed/" Emacs) + ;; ("http://ergoemacs.org/emacs/blog.xml" Emacs) + ;; ("http://xahlee.info/comp/blog.xml" Emacs) + ;; ("http://xahlee.info/js/blog.xml" Emacs) + ;; ("http://xahlee.info/math/blog.xml" Emacs) + ;; ("https://alexschroeder.ch/wiki/feed/full/" Emacs) + ;; ("http://emacshorrors.com/feed.atom" Emacs) + ;; ("http://emacsredux.com/atom.xml" Emacs) + ;; ("https://emacspeak.blogspot.com/feeds/posts/default" Emacs) + ;; ("https://endlessparentheses.com/atom.xml" Emacs) + ;; ("http://www.howardism.org/index.xml" Emacs) + ;; ("http://irreal.org/blog/?feed=rss2" Emacs) + ;; ("https://www.masteringemacs.org/feed" Emacs) + ;; ("http://mbork.pl?action=rss" Emacs) + ;; ("http://emacsblog.org/feed/" Emacs) + ;; ("http://nullprogram.com/feed/" Emacs) + ;; ("https://oremacs.com/atom.xml" Emacs) + ;; ("http://planet.emacsen.org/atom.xml" Emacs) + ;; ("https://planet.emacslife.com/atom.xml" Emacs) + ;; ("http://pragmaticemacs.com/feed/" Emacs) + ;; ("https://emacs.stackexchange.com/feeds" Emacs) + ;; ("http://sachachua.com/blog/feed/" Emacs) + ;; ("https://babbagefiles.xyz/index.xml" Emacs) + ;; ("https://babbagefiles.blogspot.com/feeds/posts/default" Emacs) + ;; ("http://whattheemacsd.com/atom.xml" Emacs) + ;; ("https://www.wisdomandwonder.com/feed" Emacs) + ;; ("https://cestlaz.github.io/rss.xml" Emacs) + ;; ("https://bzg.fr/index.xml" Emacs) + ;; ("http://kitchinresearchgroup.disqus.com/latest.rss" Emacs) + ;; ("https://noonker.github.io/index.xml" Emacs) + ;; ("https://codingquark.com/feed.xml" Emacs) + ;; ("http://xenodium.com/rss.xml" Emacs) + ;; ("https://karthinks.com/blog/index.xml" Emacs) + ;; ("http://joshrollinswrites.com/index.xml" Emacs) + ;; ("https://punchagan.muse-amuse.in/feed.xml" Emacs) + ;; ("https://willschenk.com/feed.xml" Emacs) + ;; ("https://emacs.cafe/feed.xml" Emacs) + ;; ("https://groups.google.com/forum/feed/git-for-windows/msgs/rss.xml?num=50" Git) + ;; ("https://groups.google.com/forum/feed/git-users/msgs/rss.xml?num=50" Git) + ;; ("https://groups.google.com/forum/feed/git-packagers/topics/rss.xml?num=50" Git) + ;; ("https://groups.google.com/group/idempiere/feed/rss_v2_0_msgs.xml" iDempiere) + ;; ("https://groups.google.com/group/adempiere-colombia/feed/rss_v2_0_msgs.xml" iDempiere) + ;; ("https://groups.google.com/group/idempiere-dev/feed/rss_v2_0_msgs.xml" iDempiere) + ;; ("https://groups.google.com/group/idempiere-es/feed/rss_v2_0_msgs.xml" iDempiere) + ;; ("https://groups.google.com/group/idempiere-italia/feed/rss_v2_0_msgs.xml" iDempiere) + ;; ("https://www.liberliber.it/online/feed/" Ebooks Letteratura) + ;; ("https://www.paginatre.it/online/feed/" Ebooks Letteratura) + ;; ("http://it.feedbooks.com/books/recent.atom?lang=it" Ebooks Letteratura) + ;; ("http://pennablu.it/feed/" Ebooks Letteratura) + ;; ("https://www.reddit.com/r/bashonubuntuonwindows/.rss" Microsoft WSL) + ;; ("https://blogs.msdn.microsoft.com/wsl/feed/" Microsoft WSL) + ;; ("https://blogs.technet.microsoft.com/enterprisemobility/author/BradAnderson/feed/rss/" Microsoft) + ;; ("https://blogs.msdn.microsoft.com/bharry/feed" Microsoft) + ;; ("https://blogs.msdn.microsoft.com/powershell/feed/" Microsoft) + ;; ("https://weblogs.asp.net/scottgu/rss?containerid=13" Microsoft) + ;; ("https://blogs.msdn.microsoft.com/stevengu/feed/" Microsoft) + ;; ("https://code.visualstudio.com/feed.xml" Microsoft) + ;; ("http://blogs.msdn.microsoft.com/commandline/feed/" Microsoft) + ;; "https://www.paulekman.com/feed/" + ;; "https://github.blog/feed/" + ;; "https://blog.bitbucket.org/feed/" + ;; "https://www.blog.google/rss/" + ;; "https://calebmadrigal.com/atom.xml" + ;; ) + ;; ) + (elfeed-org) + ) + #+end_src + + #+begin_src emacs-lisp + (use-package elfeed-goodies + ;; + :disabled + ;; + :ensure t + :defer t + :config + (elfeed-goodies/setup) + ) + #+end_src + + #+begin_src emacs-lisp + (use-package elfeed-org + ;; + :disabled + ;; + :ensure t + :defer t + ;; :after (elfeed org) + :config + (elfeed-org) + (setq rmh-elfeed-org-files (list "~/Dropbox/Sync/emacs/elfeed/feeds.org")) + ) + #+end_src + + #+begin_src emacs-lisp + (use-package elfeed-protocol + ;; + :disabled + ;; + :ensure t + :defer t + ) + #+end_src + +***** Pretty symbols + + Mostra come simboli alcune parole chiave. Ad esempio quando trova + =lambda= ne mostra il simbolo grafico. Naturalmente solo quando + siamo in ambiente GUI. + + Lo installo ma non lo attivo di default perche' ha un impatto grafico + accattivante ma a cui non e' immediato abituarsi e potrebbe portare + a condizioni di confusione nella scrittura/lettura del codice. + + #+begin_src emacs-lisp + (use-package pretty-mode + :if (window-system) + :ensure t + :config + ;; (global-pretty-mode t) + ) + #+end_src + +***** CSV mode + + #+begin_src emacs-lisp + (use-package csv-mode + :ensure t + :defer t + ) + #+end_src + +**** PDF-Tools + + #+begin_src emacs-lisp + ;;-------------------------------------------------------- + (use-package pdf-tools + :ensure t + :defer t + :after (pdf-annot) + :magic ("%PDF" . pdf-view-mode) + ;; :bind (("h" . 'pdf-annot-add-highlight-markup-annotation) + ;; ("t" . 'pdf-annot-add-text-annotation) + ;; ("D" . 'pdf-annot-delete) + ;; ("C-s" . 'isearch-forward) + ;; ("m" . 'mrb/mailfile) + ;; ("" . 'pdf-annot-edit-contents-commit) + ;; ("" . 'newline) + ;; ;; ("\\" . hydra-pdftools/body) + ;; ;; ("" . pdf-view-scroll-down-or-next-page) + ;; ;; ("g" . pdf-view-first-page) + ;; ;; ("G" . pdf-view-last-page) + ;; ;; ("l" . image-forward-hscroll) + ;; ;; ("h" . image-backward-hscroll) + ;; ;; ("j" . pdf-view-next-page) + ;; ;; ("k" . pdf-view-previous-page) + ;; ;; ("e" . pdf-view-goto-page) + ;; ;; ("u" . pdf-view-revert-buffer) + ;; ;; ("al" . pdf-annot-list-annotations) + ;; ;; ("ad" . pdf-annot-delete) + ;; ;; ("aa" . pdf-annot-attachment-dired) + ;; ;; ("am" . pdf-annot-add-markup-annotation) + ;; ;; ("at" . pdf-annot-add-text-annotation) + ;; ;; ("y" . pdf-view-kill-ring-save) + ;; ;; ("i" . pdf-misc-display-metadata) + ;; ;; ("s" . pdf-occur) + ;; ;; ("b" . pdf-view-set-slice-from-bounding-box) + ;; ;; ("r" . pdf-view-reset-slice) + ;; :map pdf-view-mode-map + ;; :map pdf-annot-edit-contents-minor-mode-map + ;; ) + :config + ;; Some settings from http://pragmaticemacs.com/emacs/even-more-pdf-tools-tweaks/ + ;; (fullframe pdf-view-mode quit-window) + (setq-default pdf-view-display-size 'fit-page) ;scale to fit page by default + ;; (gsetq-default pdf-view-display-size 'fit-width) + (setq pdf-annot-activate-created-annotations t ; automatically annotate highlights + pdf-view-resize-factor 1.1 ; more fine-grained zooming + ;;pdf-misc-print-program "/usr/bin/lpr" + pdf-view-midnight-colors '("#DCDCCC" . "#383838")) ; Not sure what this is + ;; (add-hook 'pdf-view-mode-hook (lambda () (cua-mode 0))) ; turn off cua so copy works + ;; (pdf-tools-install :no-query)) ; no-query auto builds epfinfo when needed + (pdf-tools-install) + ;; (eval-after-load 'org '(require 'org-pdfview) + ) + + ;; ;;-------------------------------------------------------- + ;; (use-package pdf-tools + ;; :magic ("%PDF" . pdf-view-mode) + ;; :config + ;; (dolist + ;; (pkg + ;; '(pdf-annot pdf-cache pdf-dev pdf-history pdf-info pdf-isearch + ;; pdf-links pdf-misc pdf-occur pdf-outline pdf-sync + ;; pdf-util pdf-view pdf-virtual)) + ;; (require pkg)) + ;; (pdf-tools-install)) + #+end_src + +**** EMMS (The Emacs Multimedia System) + + #+begin_src emacs-lisp + (use-package emms + :ensure t + :defer t + :config + (require 'emms-setup) + (require 'emms-player-mplayer) + (emms-all) + (setq emms-player-list '(emms-player-mpg321 + emms-player-ogg123 + emms-player-mplayer)) + (defun emms-player-mplayer-volume(amount) + (process-send-string + emms-player-simple-process-name + (format "volume %d\n" amount))) + (setq emms-volume-change-function 'emms-player-mplayer-volume) + (setq emms-source-file-default-directory "~/music/") + (emms-add-directory-tree emms-source-file-default-directory) + (emms-add-directory-tree "C:\Temp\_cancellami\_cancellami") + ) + #+end_src + +**** Docker + + #+begin_src emacs-lisp + (use-package docker + :ensure t + :defer t + ) + #+end_src + + #+begin_src emacs-lisp + (use-package dockerfile-mode + :ensure t + :defer t + :mode ("/\\Dockerfile\\'") + ) + #+end_src + + #+begin_src emacs-lisp + (use-package docker-compose-mode + :ensure t + :defer t + ) + #+end_src + +**** Simple httpd + + #+begin_src emacs-lisp + (use-package simple-httpd + :ensure t + :defer t + :config + (setq httpd-port 7070) + (setq httpd-host (system-name)) + ) + #+end_src + +**** Impatient mode + + #+begin_src emacs-lisp + (use-package impatient-mode + :ensure t + :defer t + :after simple-httpd + :commands impatient-mode + ) + #+end_src + +**** Formati di documento + +***** Markdown + + #+begin_src emacs-lisp + (use-package markdown-mode + :ensure t + :defer t + :commands (markdown-mode gfm-mode) + :mode (("README\\.md\\'" . gfm-mode) + ("\\.md\\'" . markdown-mode) + ("\\.markdown\\'" . markdown-mode)) + :init (setq markdown-command "multimarkdown") + :hook (markdown-mode-hook . gb/markdown-preview) + :config + (progn + (cond ((eq system-type 'windows-nt) + ;; Windows + (setq markdown-command "pandoc.exe -t html5") + ) + ((eq system-type 'gnu/linux) + ;; Linux + (setq markdown-command "pandoc -t html5") + )) + (defun gb/markdown-filter (buffer) + (princ + (with-temp-buffer + (let ((tmp (buffer-name))) + (set-buffer buffer) + (set-buffer (markdown tmp)) + (format "Markdown preview +
%s
" (buffer-string)))) + (current-buffer))) + (defun gb/markdown-preview () + "Preview markdown." + (interactive) + (unless (process-status "httpd") + (httpd-start)) + (impatient-mode) + (imp-set-user-filter 'gb/markdown-filter) + (imp-visit-buffer)) + ) + ) + #+end_src + +***** LaTex (Auctex) + + #+begin_src emacs-lisp + (use-package auctex + :ensure t + :defer t + ) + #+end_src + + #+begin_src emacs-lisp + (use-package company-auctex + :ensure t + :after (company auctex) + :config + (company-auctex-init) + ) + #+end_src + +**** Programmazione + +***** Regular Expressions: pcre2el + + Elimino il lighter dalla modeline: serve soltanto per attivare/disattivre + il minor-mode. + + #+begin_src emacs-lisp + (use-package pcre2el + :ensure t + :delight + :commands (rxt-mode rxt-global-mode) + :config + (pcre-mode) + ) + #+end_src + +***** Aggressive-indent + + #+begin_src emacs-lisp + (use-package aggressive-indent + :ensure t + :defer t + :diminish + :hook (emacs-lisp-mode-hook . aggressive-indent-mode) + ) + #+end_src + +***** Highlight-indent-guides + + Elimino il lighter dalla modeline: serve soltanto per attivare/disattivre + il minor-mode. + + #+begin_src emacs-lisp + (use-package highlight-indent-guides + :ensure t + :defer t + :delight + :hook (prog-mode-hook . highlight-indent-guides-mode) + :custom + ((highlight-indent-guides-method 'character) + (highlight-indent-guides-responsive 'stack)) + :config + (unless (window-system) + (set-face-background 'highlight-indent-guides-odd-face "darkgray") + (set-face-background 'highlight-indent-guides-even-face "dimgray") + (set-face-foreground 'highlight-indent-guides-character-face "dimgray")) + ) + #+end_src + +***** Flycheck + + #+begin_src emacs-lisp + (use-package flycheck + :ensure t + ;;:init (global-flycheck-mode) + :defer t + :hook (prog-mode-hook . flycheck-mode) + ) + #+end_src + + E' possibile avere informazioni da FlyCheck sia in un "pos-tip" che in + un "popup-tip". + La differenza e' tecnica mentre dal punto di vista visuale non e' cosi' + evidente. Sembra che il pos-tip possa avere problemi in modalita' TTY. + Vediamo, per ora uso pos-tip + + #+begin_src emacs-lisp + (use-package flycheck-pos-tip + :ensure t + ;;:defines flycheck-pos-tip-timeout + :hook (flycheck-mode-hook . flycheck-pos-tip-mode) + :config (setq flycheck-pos-tip-timeout 30) + ) + #+end_src + + #+begin_src emacs-lisp + (use-package flycheck-popup-tip + :disabled + :ensure t + :defer t + ;;:defines flycheck-pos-tip-timeout + :hook (flycheck-mode-hook . flycheck-popup-tip-mode) + ;; :config (setq flycheck-pos-tip-timeout 30) + ) + #+end_src + +***** Smartparens + + + Elimino il lighter dalla modeline: serve soltanto per attivare/disattivare + il minor-mode. + + #+begin_src emacs-lisp + (use-package smartparens + :ensure t + :defer t + :delight + :hook (prog-mode-hook . smartparens-mode) + :config + (require 'smartparens-config) + ;; (smartparens-global-mode) + ) + #+end_src + +***** Rainbow-delimiters + + #+begin_src emacs-lisp + (use-package rainbow-delimiters + :ensure t + :defer t + :hook (prog-mode-hook . rainbow-delimiters-mode) + ) + #+end_src + +***** Snippets + +****** Yasnippet + + #+begin_src emacs-lisp + (use-package yasnippet + :ensure t + :defer t + :hook (after-init-hook . yas-global-mode) + ;; :init (yas-global-mode 1) + :config (yas-reload-all) + ) + #+end_src + +****** Yasnippet-snippets + + #+begin_src emacs-lisp + (use-package yasnippet-snippets + :ensure t + :defer t + :after yasnippet + ) + #+end_src + +***** Projectile + + #+begin_src emacs-lisp + (use-package projectile + :ensure t + :defer 5 + :config + (setq projectile-completion-system 'ivy) + ;; (define-key projectile-mode-map (kbd "s-p") 'projectile-command-map) + (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) + (projectile-mode 1) + ) + #+end_src + +****** Ibuffer-projectile + + #+begin_src emacs-lisp + (use-package ibuffer-projectile + :ensure t + :defer t + :after (projectile) + ) + #+end_src + +****** Counsel-projectile + + Occorre accertarsi che venga caricato sia dopo =counsel= + che dopo =projectile= + + #+begin_src emacs-lisp + (use-package counsel-projectile + :ensure t + :defer t + :after (counsel projectile) + :hook (projectile-mode-hook . counsel-projectile-mode) + ) + #+end_src + +****** Treemacs-projectile + + Occorre accertarsi che venga caricato sia dopo =treemacs= + che dopo =projectile= + + #+begin_src emacs-lisp + (use-package treemacs-projectile + :ensure t + :defer t + :after treemacs projectile + :hook (treemacs-mode-hook . treemacs-project-mode) + ) + #+end_src + +***** Powershell + + #+begin_src emacs-lisp + (use-package powershell + :ensure t + :defer t + ) + #+end_src + +***** C# + + #+begin_src emacs-lisp + (use-package csharp-mode + :ensure t + :defer t + ) + #+end_src + +***** SQL + + #+begin_src emacs-lisp + (use-package sql-indent + :ensure t + :defer t + ) + #+end_src + +***** Go lang + + #+begin_src emacs-lisp + (use-package go-mode + :ensure t + :defer t + ) + #+end_src + + #+begin_src emacs-lisp + (use-package go-errcheck + :ensure t + :defer t + :after go-mode + ) + #+end_src + + #+begin_src emacs-lisp + (use-package company-go + :ensure t + :after (company go-mode) + ) + #+end_src + +***** Rust + + #+begin_src emacs-lisp + (defun gb/rust/rustic-mode-hook () + ;; so that run C-c C-c C-r works without having to confirm + ;; (setq-local buffer-save-without-query t) + (cargo-minor-mode t) + (company-mode t) + ) + + (use-package rustic + :ensure t + :defer t + ;; :bind (:map rustic-mode-map + ;; ("M-j" . lsp-ui-imenu) + ;; ("M-?" . lsp-find-references) + ;; ("C-c C-c l" . flycheck-list-errors) + ;; ("C-c C-c a" . lsp-execute-code-action) + ;; ("C-c C-c r" . lsp-rename) + ;; ("C-c C-c q" . lsp-workspace-restart) + ;; ("C-c C-c Q" . lsp-workspace-shutdown) + ;; ("C-c C-c s" . lsp-rust-analyzer-status)) + :hook ((rustic-mode-hook . gb/rust/rustic-mode-hook)) + :config + ;; uncomment for less flashiness + ;; (setq lsp-eldoc-hook nil) + ;; (setq lsp-enable-symbol-highlighting nil) + ;; (setq lsp-signature-auto-activate nil) + + ;; comment to disable rustfmt on save + ;; (setq rustic-format-on-save t) + + ;; (setq rustic-lsp-server 'rls) + ;; attenzione, il .exe va bene solo su windows + (setq lsp-rust-analyzer-server-command '("~/.cargo/bin/rust-analyzer.exe")) + (setq rustic-lsp-client 'eglot) + (push 'rustic-clippy flycheck-checkers) + (setq rustic-flycheck-clippy-params "--message-format=json") + ) + #+end_src + + #+begin_src emacs-lisp + (use-package flycheck-rust + :ensure t + :defer t + :after (flycheck) + :hook (flyckeck-mode-hook . flycheck-rust-setup) + ;; :hook ((rust-mode-hook . flycheck-rust-setup) + ;; (flycheck-mode . flycheck-rust-setup) + ;; ) + ;; :after (flycheck rust-mode) + ;; :config (flycheck-rust-setup) + ) + #+end_src + + #+begin_src emacs-lisp + (use-package rust-mode + ;; --------------------- + :disabled + ;; --------------------- + :ensure t + :defer t + :after (company flycheck-rust cargo) + :hook ((rust-mode-hook . company-mode) + ;; (rust-mode-hook . flycheck-rust-setup) + (rust-mode-hook . cargo-minor-mode) + ) + :config + (setq indent-tabs-mode nil) + ;; (setq rust-format-on-save t) + (setq company-tooltip-align-annotations t) + ) + #+end_src + + #+begin_src emacs-lisp + (use-package cargo + :ensure t + :defer t + ;; :after rust-mode + ;; :after rustic-mode + ;; :hook ((rust-mode-hook . cargo-minor-mode) + ;; ;; (conf-toml-mode-hook . cargo-minor-mode) + ;; ) + ) + #+end_src + +***** LSP (Language Server Protocol) - temporaneamente disaiblitato - + + Vedi la documentazione sul sito del produttore. + [[https://emacs-lsp.github.io/lsp-mode/]] + + Per adesso disabilito tutti i moduli, voglio provare + eglot che pare piu' semplice, oltre ad essere inserito + in gnu-elpa. + + #+begin_src emacs-lisp + (use-package lsp-mode + ;; ------------------------------ + :disabled + ;; ------------------------------ + :ensure t + :commands (lsp) + :after (yasnippet) + ;; Ricordarsi di leggere la documentazione + ;; sul sito del produttore. + :custom + (lsp-keymap-prefix "C-c l") + :hook (;; Avvio normale (XXX-mode . lsp) + ;; Avvio differito (XXX-mode . lsp-deferred) + (c++-mode-hook . lsp-deferred) + (c-mode-hook . lsp-deferred) + (csharp-mode-hook . lsp-deferred) + (css-mode-hook . lsp-deferred) + (dart-mode-hook . lsp-deferred) + (go-mode-hook . lsp-deferred) + (groovy-mode-hook . lsp-deferred) + (haxe-mode-hook . lsp-deferred) + (html-mode-hook . lsp-deferred) + (java-mode-hook . lsp-deferred) + (js-mode-hook . lsp-deferred) + (json-mode-hook . lsp-deferred) + (kotlin-mode-hook . lsp-deferred) + (latex-mode-hook . lsp-deferred) + (less-css-mode-hook . lsp-deferred) + (nxml-mode-hook . lsp-deferred) + (powershell-mode-hook . lsp-deferred) + (python-mode-hook . lsp-deferred) + (rust-mode-hook . lsp-deferred) + (scss-mode-hook . lsp-deferred) + (sh-mode-hook . lsp-deferred) + ;; (sql-mode-hook . lsp-deferred) + (typescript-mode-hook . lsp-deferred) + (xml-mode-hook . lsp-deferred) + (yaml-mode-hook . lsp-deferred) + (clojure-mode-hook . lsp-deferred) + + (lsp-mode-hook . lsp-enable-which-key-integration) + ) + :commands (lsp lsp-deferred lsp-doctor) + :config + ;; (setq lsp-completion-enable-additional-text-edit nil) + ;; Come riportato qui: https://emacs-lsp.github.io/lsp-mode/page/performance/ + (setq lsp-completion-provider :capf) + ;; (setq lsp-log-io t + ;; lsp-server-trace "verbose") + ) + #+end_src + + #+begin_src emacs-lisp + (use-package company-lsp + ;; ------------------------------ + :disabled + ;; ------------------------------ + :ensure t + :disabled + :after (lsp-mode company) + :config + (setq company-lsp-enable-snippet t) + (push 'company-lsp company-backends) + ) + #+end_src + + #+begin_src emacs-lisp + (use-package lsp-ui + ;; ------------------------------ + :disabled + ;; ------------------------------ + :ensure t + ;; :defer t + :after (lsp-mode markdown-mode) + :commands lsp-ui-mode + :custom + (lsp-ui-peek-always-show t) + (lsp-ui-sideline-show-hover t) + (lsp-ui-doc-enable nil) + ) + #+end_src + + #+begin_src emacs-lisp + (use-package lsp-ivy + ;; ------------------------------ + :disabled + ;; ------------------------------ + :ensure t + ;; :defer t + :after (lsp-mode ivy) + :commands lsp-ivy-workspace-symbol + ) + #+end_src + + #+begin_src emacs-lisp + (use-package dap-mode + ;; ------------------------------ + :disabled + ;; ------------------------------ + :ensure t + :defer t + :after (lsp-mode lsp-treemacs) + ) + ;; (use-package dap-csharp + ;; :ensure t + ;; :defer t + ;; ) + #+end_src + + #+begin_src emacs-lisp + (use-package lsp-treemacs + ;; ------------------------------ + :disabled + ;; ------------------------------ + :ensure t + :after (lsp-mode treemacs) + :commands (lsp-treemacs-errors-list) + :custom + (lsp-treemacs-sync-mode 1) + ) + #+end_src + + #+begin_src emacs-lisp + (use-package lsp-origami + ;; ------------------------------ + :disabled + ;; ------------------------------ + :ensure t + :defer t + :after (lsp-mode origami) + :hook (lsp-after-open-hook . lsp-origami-try-enable) + ) + #+end_src + + #+begin_src emacs-lisp + ;; (use-package lsp-mssql + ;; :ensure t + ;; :defer t + ;; :after (lsp-mode lsp-treemacs) + ;; :hook (sql-mode-hook . lsp) + ;; ) + #+end_src + + - lsp-java + - lsp-latex + - lsp-mssql + - lsp-origami + - lsp-python-ms ?? + +***** EGlot (lsp) + + Uso EGlot come interfaccia verso i vari lsp server. + Lo provo in alternativa a lsp-mode perche' le recensioni + lo danno come piu' semplice da configurare ed utilizzare + anche se, sulla carta, con meno funzionalita'. + + Con Rust e' consigliato l'uso di lsp-mode per questo disattivo + eglot e riattivo lsp-mode + + #+begin_src emacs-lisp + (use-package eglot + :ensure t + :defer t + ;; :custom + ;; (eglot-autoreconnect nil) + ;; (eglot-autoshutdown t) + :hook ((c++-mode-hook . eglot-ensure) + (c-mode-hook . eglot-ensure) + (csharp-mode-hook . eglot-ensure) + (css-mode-hook . eglot-ensure) + (dart-mode-hook . eglot-ensure) + (go-mode-hook . eglot-ensure) + (groovy-mode-hook . eglot-ensure) + (haxe-mode-hook . eglot-ensure) + (html-mode-hook . eglot-ensure) + (java-mode-hook . eglot-ensure) + (js-mode-hook . eglot-ensure) + (json-mode-hook . eglot-ensure) + (kotlin-mode-hook . eglot-ensure) + (latex-mode-hook . eglot-ensure) + (less-css-mode-hook . eglot-ensure) + (nxml-mode-hook . eglot-ensure) + (powershell-mode-hook . eglot-ensure) + (python-mode-hook . eglot-ensure) + (rust-mode-hook . eglot-ensure) + (scss-mode-hook . eglot-ensure) + (sh-mode-hook . eglot-ensure) + (sql-mode-hook . eglot-ensure) + (typescript-mode-hook . eglot-ensure) + (xml-mode-hook . eglot-ensure) + (yaml-mode-hook . eglot-ensure) + (clojure-mode-hook . eglot-ensure)) + ) + #+end_src + +*** Piede del file di inizializzazione + + Qui vanno le impostazioni delle variabili locali del file. + + Da notare che l'impostazione del major mode *NON* deve avvenire qui + nella sezione "local variables", ma nella prima linea con la classica + notazione =-*- mode: lisp; -*-=, altrimenti si genera un errore nel tangling. + + #+begin_src emacs-lisp + ;; =========================================================================== + ;; Local Variables: + ;; coding: utf-8-unix + ;; indent-tabs-mode: nil + ;; tab-width: 4 + ;; End: + ;; =========================================================================== + + ;;; gb-init ends here + #+end_src + +** Variabili locali di file :noexport: + + Qui si e' utilizzato l'attributo =:noexport= perche' l'intenzione e' stata + quella di raggruppare le variaibli locali di questo file in un header + specifico; ma mentre le variabili locali sono "commenti" (iniziano per =#= e + non vengono quindi esportate, l'header non lo e' e senza questo attributo + verrebbe esportato. + + # =========================================================================== + # Local variables: + # coding: utf-8-unix + # mode: org + # indent-tabs-mode: nil + # tab-width: 4 + # end: + # =========================================================================== diff --git a/dot_emacs.d/img/Logob-w.png b/dot_emacs.d/img/Logob-w.png new file mode 100644 index 0000000..211212f Binary files /dev/null and b/dot_emacs.d/img/Logob-w.png differ diff --git a/dot_emacs.d/img/Logog-b.png b/dot_emacs.d/img/Logog-b.png new file mode 100644 index 0000000..0ce2631 Binary files /dev/null and b/dot_emacs.d/img/Logog-b.png differ diff --git a/dot_emacs.d/img/logo-BlackGreen-noText.svg b/dot_emacs.d/img/logo-BlackGreen-noText.svg new file mode 100644 index 0000000..a46f6b4 --- /dev/null +++ b/dot_emacs.d/img/logo-BlackGreen-noText.svg @@ -0,0 +1,89 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/dot_emacs.d/img/logo-GOLEM-text.svg b/dot_emacs.d/img/logo-GOLEM-text.svg new file mode 100644 index 0000000..d1c7a4a --- /dev/null +++ b/dot_emacs.d/img/logo-GOLEM-text.svg @@ -0,0 +1,67 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/dot_emacs.d/img/logo-GOLEM-website.svg b/dot_emacs.d/img/logo-GOLEM-website.svg new file mode 100644 index 0000000..be25552 --- /dev/null +++ b/dot_emacs.d/img/logo-GOLEM-website.svg @@ -0,0 +1,72 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/dot_emacs.d/img/logo-WhiteBlack-noText.svg b/dot_emacs.d/img/logo-WhiteBlack-noText.svg new file mode 100644 index 0000000..42ed0a6 --- /dev/null +++ b/dot_emacs.d/img/logo-WhiteBlack-noText.svg @@ -0,0 +1,89 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/dot_emacs.d/img/original_Logob-w.png b/dot_emacs.d/img/original_Logob-w.png new file mode 100644 index 0000000..703d16e Binary files /dev/null and b/dot_emacs.d/img/original_Logob-w.png differ diff --git a/dot_emacs.d/img/original_Logog-b.png b/dot_emacs.d/img/original_Logog-b.png new file mode 100644 index 0000000..6dfbf2f Binary files /dev/null and b/dot_emacs.d/img/original_Logog-b.png differ diff --git a/dot_emacs.d/init.el b/dot_emacs.d/init.el new file mode 100644 index 0000000..365f344 --- /dev/null +++ b/dot_emacs.d/init.el @@ -0,0 +1,227 @@ +;;; init.el --- File di configurazione di GNU Emacs -*- mode: emacs-lisp; lexical-binding: t;-*- + +;; Copyright (C) 2020 Geraldo Biotti + +;; Author: Geraldo Biotti +;; Created: 20200731 +;; Keywords: init, early-init, .emacs.d, startup +;; Compatiblity: emacs-version >= 27 + +;; This file is not part of GNU Emacs. + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or (at +;; your option) any later version. + +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;; Questo file contiene le impostazioni di GNU Emacs che vengono eseguite +;; durante la fase di Init. +;; La fase di Init viene eseguita successivamente a quella di Early Init +;; +;; Per maggiori informazioni fare riferimento al manuale di GNU Emacs: +;; 49.4 The Emacs Initialization File + +;;; To do: + +;;; Change log: + +;;; Code: + +;; ---------------------------------------------------------------------------------------- +;; https://etienne.depar.is/emacs.d/init.html +;; https://github.com/MatthewZMD/.emacs.d + +;; https://www.reddit.com/r/emacs/comments/2edbau/what_are_some_great_emacsd_examples/ +;; https://www.reddit.com/r/emacs/comments/2edbau/what_are_some_great_emacsd_examples/ + +;; https://github.com/AndreaCrotti + +;; https://github.com/grettke/ + +;; Pastebin off topic: +;; https://www.privacytools.io/ +;; https://alternativeto.net/list/18434/xenmaster-s-privacy-tools + +;; https://send-anywhere.com/ +;; https://framasoft.org/en/ +;; https://gofile.io/welcome +;; ---------------------------------------------------------------------------------------- + +;; N.B.: Ho rimosso l'impostazione del lexical-binding: +;; -*- lexical-binding: t; -*- + +;; Se la versione e' inferiore alla 26.1 emetto un warning +(when (version< emacs-version "26.1") + (warn "E' necessario che GNU Emacs sia in versione 26.1 o successiva!")) + +(defun gb/emacs/package-setup () + "Function che imposta 'package'" + ;; Carico il modulo di gestione dei packages + (require 'package) + ;; Carica sempre il file piu' recente tra '.el' e '.elc' + (setq load-prefer-newer t) + ;; Aggiungo all'elenco dei repositories da cui scaricare i packages + ;; la versione "unstable" di Melpa + (add-to-list 'package-archives + '("melpa" . "https://melpa.org/packages/")) + ;; Genera dei warnings con i package-install + (unless (bound-and-true-p package--initialized) + (package-initialize)) + ) + +(defun gb/emacs/init-old-emacs-version () + "Function eseguita per il setup di init.el quando si sta usando Emacs + in versione precedente alla 27" + ;; Early-init e' gestito automaticamente dalla versione 27 in poi + ;; Se esiste early-init.el lo carico + (let ((gb/emacs/early-init-file (expand-file-name "early-init.el" user-emacs-directory))) + (when (file-exists-p gb/emacs/early-init-file) + (require 'early-init gb/emacs/early-init-file))) + (gb/emacs/package-setup) + ) + +(defun gb/emacs/init-new-emacs-version () + "Function eseguita per il setup di init.el quando si sta usando Emacs + in versione 27+" + ;; Avvio package + (gb/emacs/package-setup) + ) + +;; Eseguo le impostazioni in base alla versione di GNU Emacs +(if (version< emacs-version "27") + (gb/emacs/init-old-emacs-version) + (gb/emacs/init-new-emacs-version)) + +;; Delight e' un package che viene usato da use-package +;; mi accerto che sia installato, se non lo e' lo installo +;; N.B.: Se non si vuole averlo come dipendenza e' bene +;; installarlo prima di use-package +(unless (package-installed-p 'delight) + (unless package-archive-contents + (package-refresh-contents)) + (package-install 'delight)) + +;; Diminish e' un package che viene usato da use-package +;; mi accerto che sia installato, se non lo e' lo installo +;; N.B.: Se non si vuole averlo come dipendenza e' bene +;; installarlo prima di use-package +(unless (package-installed-p 'diminish) + (unless package-archive-contents + (package-refresh-contents)) + (package-install 'diminish)) + +;; Mi accerto che use-package sia installato +;; se non lo e' lo installo +(unless (package-installed-p 'use-package) + (unless package-archive-contents + (package-refresh-contents)) + (package-install 'use-package)) + +;; Carico use-package +(eval-when-compile + (require 'use-package)) + +;; Configuro use-package prima di caricarlo +(eval-and-compile + (if init-file-debug + (setq use-package-verbose t + use-package-expand-minimally nil + use-package-compute-statistics t + debug-on-error t) ; True + (setq use-package-verbose nil + use-package-expand-minimally t) ; False + ) + (setq use-package-enable-imenu-support t + ;; Quanto segue e' MOLTO IMPORTANTE: + ;; Usare sempre gli hook con il loro nome completo + ;; al posto del nome abbreviato: + ;; after-init --> after-init-hook + ;; Questo migliora la gestione della documentazione + ;; a riconoscere il contesto (vedi, ad esempio 'describe-symbol) + use-package-hook-name-suffix nil) + ) + +;; Configuro vc (package gestione "version cotrol" +(use-package vc + :config + ;; Questo perche' i miei "dotfiles" usano i link simbolici + (setq vc-follow-symlinks t) + ) + +;; Carico org +(use-package org + ;; Accertarsi di caricare quello presente nel repository GNU + ;; e non quello "builtin": quello in GNU e' sempre aggiornato. + :pin gnu + :ensure org + ) + +;; Qui avviene la magia. +;; Carico la configurazione dal file "org" +;; Cerco pero' di ottimizzare un mimino la cosa: +;; se il file "el" generato da org-babel e' piu' recente +;; del file "org" allora carico "el" altrimenti passo +;; all'uso di org-babel +(progn (defvar gb/emacs/gb-init "gb-init") + (defvar gb/emacs/conf-filename (expand-file-name gb/emacs/gb-init user-emacs-directory)) + (defvar gb/emacs/el-conf-filename (concat gb/emacs/conf-filename ".el")) + (defvar gb/emacs/org-conf-filename (concat gb/emacs/conf-filename ".org")) + (if (file-exists-p gb/emacs/el-conf-filename) + (if (file-newer-than-file-p gb/emacs/org-conf-filename gb/emacs/el-conf-filename) + (progn (message "%s e' piu' recente di %s, ricreo e carico il .el" + gb/emacs/org-conf-filename + gb/emacs/el-conf-filename) + (org-babel-load-file gb/emacs/org-conf-filename)) + (progn (message "%s e' meno recente di %s, carico il .el senza ricrearlo" + gb/emacs/org-conf-filename + gb/emacs/el-conf-filename) + (load-file gb/emacs/el-conf-filename))) + (progn (message "Creo e carico %s" gb/emacs/el-conf-filename) + (org-babel-load-file gb/emacs/org-conf-filename)) + ) + ) + +;; NON RIMUOVERE CUSTOM DA QUI +;; --------------------------- +;; Si potrebbe cedere alla tentazione di avere un init.el piu' "pulito" +;; spostando custom-set-variables e custom-set-faces in un file separato, +;; ma questo porta spesso a comportamenti altalenanti: se si installa un +;; package con use-package e la sua opzione :ensure, capita che il package +;; venga installato, ma la variabile package-selected-packages non venga +;; aggiornata correttamente portanto il package installato ad uno stato +;; di "dependency" in list-packages con invito alla rimozione qualora questo +;; non fosse effettivamente utilizzato anche come dipendenza da qualche altro +;; package +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(package-selected-packages + '(modus-themes dockerfile-mode cargo docker docker-compose-mode flycheck-rust impatient-mode simple-httpd yasnippet yasnippet-snippets org projectile company-go go-errcheck go-mode company-auctex auctex sql-indent markdown-mode csharp-mode powershell counsel-projectile ibuffer-projectile rainbow-delimiters smartparens flycheck-pos-tip flycheck highlight-indent-guides aggressive-indent pcre2el emms pdf-tools csv-mode pretty-mode elfeed-protocol elfeed-org elfeed-goodies elfeed company-restclient restclient treemacs-all-the-icons treemacs-projectile treemacs-magit treemacs git-timemachine gitattributes-mode gitignore-mode gitconfig-mode magit undo-tree origami company-quickhelp ace-window avy symon beacon htmlize org-edna org-bullets amx ivy-hydra all-the-icons-ivy-rich ivy-rich swiper hydra which-key dashboard minions doom-modeline base16-theme seti-theme moe-theme solarized-theme color-theme-sanityinc-tomorrow dracula-theme atom-one-dark-theme zerodark-theme gruvbox-theme monokai-theme zenburn-theme material-theme spacemacs-theme doom-themes all-the-icons-ibuffer all-the-icons-dired all-the-icons async use-package diminish delight))) +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + ) + +;; =========================================================================== +;; Local Variables: +;; coding: utf-8-unix +;; indent-tabs-mode: nil +;; tab-width: 4 +;; End: +;; =========================================================================== + +;;; init.el ends here diff --git a/dot_git_template/hooks/dot_gitattributes b/dot_git_template/hooks/dot_gitattributes new file mode 100644 index 0000000..c3cd4ec --- /dev/null +++ b/dot_git_template/hooks/dot_gitattributes @@ -0,0 +1,2 @@ +* text=auto +pre-commit text eol=lf diff --git a/dot_git_template/hooks/pre-commit b/dot_git_template/hooks/pre-commit new file mode 100644 index 0000000..44cda68 --- /dev/null +++ b/dot_git_template/hooks/pre-commit @@ -0,0 +1,30 @@ +#!/bin/bash + +function get_org_of_current_repo() { + local orgs_from_global_config=$(git config --get-regexp ^orgs. | cut -d . -f 2) + + for org in $orgs_from_global_config; do + local org_remotes=$(git remote -v | grep -i $org/) + + if [ ! -z "$org_remotes" ]; then + echo $org + fi + done +} + + +org=$(get_org_of_current_repo) + +if [ ! -z "$org" ]; then + organization_email=$(git config orgs\.$org\.email) + repository_email=$(git config --local user.email) + + if [ "$organization_email" != "$repository_email" ]; then + echo "Organization '$org' identified!" + echo "Setting the configured e-mail <$organization_email>" + git config --local user.email $organization_email + + echo "Please repeat the commit command to use the new e-mail" + exit 1 + fi +fi diff --git a/dot_gitconfig.tmpl b/dot_gitconfig.tmpl new file mode 100644 index 0000000..3b3f061 --- /dev/null +++ b/dot_gitconfig.tmpl @@ -0,0 +1,26 @@ +[core] + editor = emacs + quotepath = false +[user] +{{ if (eq .chezmoi.hostname "abuelo") }} + # Configurazione per hostname uguale a "abuelo" + name = me + email = me@example.com +{{ else }} + # Configurazione per hostname diverso da "abuelo" + name = me + email = me@example.com +{{ end }} +[alias] + graph = log --decorate --oneline --graph + whatsnew = !git log ..origin/`git rev-parse --abbrev-ref HEAD` +[init] + templatedir = ~/.git_template +[pull] + rebase = false +[fetch] + prune = false +[rebase] + autoStash = false + +# vim: set ft=gitconfig : \ No newline at end of file diff --git a/dot_gitignore b/dot_gitignore new file mode 100644 index 0000000..c9a447c --- /dev/null +++ b/dot_gitignore @@ -0,0 +1,99 @@ +# -*- mode: gitignore; -*- +# +# https://www.toptal.com +# +# ------------------------------------------------------------------------ +# WINDOWS gitignore settings +# ------------------------------------------------------------------------ +# Windows image file caches +Thumbs.db +ehthumbs.db +# Folder config file +Desktop.ini +# Recycle Bin used on file shares +$RECYCLE.BIN/ +# Windows Installer files +*.cab +*.msi +*.msm +*.msp +# Windows shortcuts +*.lnk +# ------------------------------------------------------------------------ + +# ------------------------------------------------------------------------ +# EMACS gitignore settings +# ------------------------------------------------------------------------ +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive +ltximg/** + +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ +dist/ + +# Flycheck +flycheck_*.el + +# server auth directory +/server/ + +# projectiles files +.projectile + +# directory configuration +.dir-locals.el + +# network security +/network-security.data +# ------------------------------------------------------------------------ + +# ------------------------------------------------------------------------ +# VIM gitignore settings +# ------------------------------------------------------------------------ +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ +# ------------------------------------------------------------------------ diff --git a/dot_vim/autoload/plug.vim b/dot_vim/autoload/plug.vim new file mode 100644 index 0000000..afb1772 --- /dev/null +++ b/dot_vim/autoload/plug.vim @@ -0,0 +1,2524 @@ +" vim-plug: Vim plugin manager +" ============================ +" +" Download plug.vim and put it in ~/.vim/autoload +" +" curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ +" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +" +" Edit your .vimrc +" +" call plug#begin('~/.vim/plugged') +" +" " Make sure you use single quotes +" +" " Shorthand notation; fetches https://github.com/junegunn/vim-easy-align +" Plug 'junegunn/vim-easy-align' +" +" " Any valid git URL is allowed +" Plug 'https://github.com/junegunn/vim-github-dashboard.git' +" +" " Multiple Plug commands can be written in a single line using | separators +" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' +" +" " On-demand loading +" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } +" Plug 'tpope/vim-fireplace', { 'for': 'clojure' } +" +" " Using a non-master branch +" Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' } +" +" " Using a tagged release; wildcard allowed (requires git 1.9.2 or above) +" Plug 'fatih/vim-go', { 'tag': '*' } +" +" " Plugin options +" Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' } +" +" " Plugin outside ~/.vim/plugged with post-update hook +" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } +" +" " Unmanaged plugin (manually installed and updated) +" Plug '~/my-prototype-plugin' +" +" " Initialize plugin system +" call plug#end() +" +" Then reload .vimrc and :PlugInstall to install plugins. +" +" Plug options: +" +"| Option | Description | +"| ----------------------- | ------------------------------------------------ | +"| `branch`/`tag`/`commit` | Branch/tag/commit of the repository to use | +"| `rtp` | Subdirectory that contains Vim plugin | +"| `dir` | Custom directory for the plugin | +"| `as` | Use different name for the plugin | +"| `do` | Post-update hook (string or funcref) | +"| `on` | On-demand loading: Commands or ``-mappings | +"| `for` | On-demand loading: File types | +"| `frozen` | Do not update unless explicitly specified | +" +" More information: https://github.com/junegunn/vim-plug +" +" +" Copyright (c) 2017 Junegunn Choi +" +" MIT License +" +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be +" included in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +if exists('g:loaded_plug') + finish +endif +let g:loaded_plug = 1 + +let s:cpo_save = &cpo +set cpo&vim + +let s:plug_src = 'https://github.com/junegunn/vim-plug.git' +let s:plug_tab = get(s:, 'plug_tab', -1) +let s:plug_buf = get(s:, 'plug_buf', -1) +let s:mac_gui = has('gui_macvim') && has('gui_running') +let s:is_win = has('win32') +let s:nvim = has('nvim-0.2') || (has('nvim') && exists('*jobwait') && !s:is_win) +let s:vim8 = has('patch-8.0.0039') && exists('*job_start') +let s:me = resolve(expand(':p')) +let s:base_spec = { 'branch': 'master', 'frozen': 0 } +let s:TYPE = { +\ 'string': type(''), +\ 'list': type([]), +\ 'dict': type({}), +\ 'funcref': type(function('call')) +\ } +let s:loaded = get(s:, 'loaded', {}) +let s:triggers = get(s:, 'triggers', {}) + +function! plug#begin(...) + if a:0 > 0 + let s:plug_home_org = a:1 + let home = s:path(fnamemodify(expand(a:1), ':p')) + elseif exists('g:plug_home') + let home = s:path(g:plug_home) + elseif !empty(&rtp) + let home = s:path(split(&rtp, ',')[0]) . '/plugged' + else + return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.') + endif + if fnamemodify(home, ':t') ==# 'plugin' && fnamemodify(home, ':h') ==# s:first_rtp + return s:err('Invalid plug home. '.home.' is a standard Vim runtime path and is not allowed.') + endif + + let g:plug_home = home + let g:plugs = {} + let g:plugs_order = [] + let s:triggers = {} + + call s:define_commands() + return 1 +endfunction + +function! s:define_commands() + command! -nargs=+ -bar Plug call plug#() + if !executable('git') + return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.') + endif + command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install(0, []) + command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update(0, []) + command! -nargs=0 -bar -bang PlugClean call s:clean(0) + command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source' s:esc(s:me) | endif + command! -nargs=0 -bar PlugStatus call s:status() + command! -nargs=0 -bar PlugDiff call s:diff() + command! -nargs=? -bar -bang -complete=file PlugSnapshot call s:snapshot(0, ) +endfunction + +function! s:to_a(v) + return type(a:v) == s:TYPE.list ? a:v : [a:v] +endfunction + +function! s:to_s(v) + return type(a:v) == s:TYPE.string ? a:v : join(a:v, "\n") . "\n" +endfunction + +function! s:glob(from, pattern) + return s:lines(globpath(a:from, a:pattern)) +endfunction + +function! s:source(from, ...) + let found = 0 + for pattern in a:000 + for vim in s:glob(a:from, pattern) + execute 'source' s:esc(vim) + let found = 1 + endfor + endfor + return found +endfunction + +function! s:assoc(dict, key, val) + let a:dict[a:key] = add(get(a:dict, a:key, []), a:val) +endfunction + +function! s:ask(message, ...) + call inputsave() + echohl WarningMsg + let answer = input(a:message.(a:0 ? ' (y/N/a) ' : ' (y/N) ')) + echohl None + call inputrestore() + echo "\r" + return (a:0 && answer =~? '^a') ? 2 : (answer =~? '^y') ? 1 : 0 +endfunction + +function! s:ask_no_interrupt(...) + try + return call('s:ask', a:000) + catch + return 0 + endtry +endfunction + +function! s:lazy(plug, opt) + return has_key(a:plug, a:opt) && + \ (empty(s:to_a(a:plug[a:opt])) || + \ !isdirectory(a:plug.dir) || + \ len(s:glob(s:rtp(a:plug), 'plugin')) || + \ len(s:glob(s:rtp(a:plug), 'after/plugin'))) +endfunction + +function! plug#end() + if !exists('g:plugs') + return s:err('Call plug#begin() first') + endif + + if exists('#PlugLOD') + augroup PlugLOD + autocmd! + augroup END + augroup! PlugLOD + endif + let lod = { 'ft': {}, 'map': {}, 'cmd': {} } + + if exists('g:did_load_filetypes') + filetype off + endif + for name in g:plugs_order + if !has_key(g:plugs, name) + continue + endif + let plug = g:plugs[name] + if get(s:loaded, name, 0) || !s:lazy(plug, 'on') && !s:lazy(plug, 'for') + let s:loaded[name] = 1 + continue + endif + + if has_key(plug, 'on') + let s:triggers[name] = { 'map': [], 'cmd': [] } + for cmd in s:to_a(plug.on) + if cmd =~? '^.\+' + if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i')) + call s:assoc(lod.map, cmd, name) + endif + call add(s:triggers[name].map, cmd) + elseif cmd =~# '^[A-Z]' + let cmd = substitute(cmd, '!*$', '', '') + if exists(':'.cmd) != 2 + call s:assoc(lod.cmd, cmd, name) + endif + call add(s:triggers[name].cmd, cmd) + else + call s:err('Invalid `on` option: '.cmd. + \ '. Should start with an uppercase letter or ``.') + endif + endfor + endif + + if has_key(plug, 'for') + let types = s:to_a(plug.for) + if !empty(types) + augroup filetypedetect + call s:source(s:rtp(plug), 'ftdetect/**/*.vim', 'after/ftdetect/**/*.vim') + augroup END + endif + for type in types + call s:assoc(lod.ft, type, name) + endfor + endif + endfor + + for [cmd, names] in items(lod.cmd) + execute printf( + \ 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "", , , , %s)', + \ cmd, string(cmd), string(names)) + endfor + + for [map, names] in items(lod.map) + for [mode, map_prefix, key_prefix] in + \ [['i', '', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']] + execute printf( + \ '%snoremap %s %s:call lod_map(%s, %s, %s, "%s")', + \ mode, map, map_prefix, string(map), string(names), mode != 'i', key_prefix) + endfor + endfor + + for [ft, names] in items(lod.ft) + augroup PlugLOD + execute printf('autocmd FileType %s call lod_ft(%s, %s)', + \ ft, string(ft), string(names)) + augroup END + endfor + + call s:reorg_rtp() + filetype plugin indent on + if has('vim_starting') + if has('syntax') && !exists('g:syntax_on') + syntax enable + end + else + call s:reload_plugins() + endif +endfunction + +function! s:loaded_names() + return filter(copy(g:plugs_order), 'get(s:loaded, v:val, 0)') +endfunction + +function! s:load_plugin(spec) + call s:source(s:rtp(a:spec), 'plugin/**/*.vim', 'after/plugin/**/*.vim') +endfunction + +function! s:reload_plugins() + for name in s:loaded_names() + call s:load_plugin(g:plugs[name]) + endfor +endfunction + +function! s:trim(str) + return substitute(a:str, '[\/]\+$', '', '') +endfunction + +function! s:version_requirement(val, min) + for idx in range(0, len(a:min) - 1) + let v = get(a:val, idx, 0) + if v < a:min[idx] | return 0 + elseif v > a:min[idx] | return 1 + endif + endfor + return 1 +endfunction + +function! s:git_version_requirement(...) + if !exists('s:git_version') + let s:git_version = map(split(split(s:system('git --version'))[2], '\.'), 'str2nr(v:val)') + endif + return s:version_requirement(s:git_version, a:000) +endfunction + +function! s:progress_opt(base) + return a:base && !s:is_win && + \ s:git_version_requirement(1, 7, 1) ? '--progress' : '' +endfunction + +if s:is_win + function! s:rtp(spec) + return s:path(a:spec.dir . get(a:spec, 'rtp', '')) + endfunction + + function! s:path(path) + return s:trim(substitute(a:path, '/', '\', 'g')) + endfunction + + function! s:dirpath(path) + return s:path(a:path) . '\' + endfunction + + function! s:is_local_plug(repo) + return a:repo =~? '^[a-z]:\|^[%~]' + endfunction +else + function! s:rtp(spec) + return s:dirpath(a:spec.dir . get(a:spec, 'rtp', '')) + endfunction + + function! s:path(path) + return s:trim(a:path) + endfunction + + function! s:dirpath(path) + return substitute(a:path, '[/\\]*$', '/', '') + endfunction + + function! s:is_local_plug(repo) + return a:repo[0] =~ '[/$~]' + endfunction +endif + +function! s:err(msg) + echohl ErrorMsg + echom '[vim-plug] '.a:msg + echohl None +endfunction + +function! s:warn(cmd, msg) + echohl WarningMsg + execute a:cmd 'a:msg' + echohl None +endfunction + +function! s:esc(path) + return escape(a:path, ' ') +endfunction + +function! s:escrtp(path) + return escape(a:path, ' ,') +endfunction + +function! s:remove_rtp() + for name in s:loaded_names() + let rtp = s:rtp(g:plugs[name]) + execute 'set rtp-='.s:escrtp(rtp) + let after = globpath(rtp, 'after') + if isdirectory(after) + execute 'set rtp-='.s:escrtp(after) + endif + endfor +endfunction + +function! s:reorg_rtp() + if !empty(s:first_rtp) + execute 'set rtp-='.s:first_rtp + execute 'set rtp-='.s:last_rtp + endif + + " &rtp is modified from outside + if exists('s:prtp') && s:prtp !=# &rtp + call s:remove_rtp() + unlet! s:middle + endif + + let s:middle = get(s:, 'middle', &rtp) + let rtps = map(s:loaded_names(), 's:rtp(g:plugs[v:val])') + let afters = filter(map(copy(rtps), 'globpath(v:val, "after")'), '!empty(v:val)') + let rtp = join(map(rtps, 'escape(v:val, ",")'), ',') + \ . ','.s:middle.',' + \ . join(map(afters, 'escape(v:val, ",")'), ',') + let &rtp = substitute(substitute(rtp, ',,*', ',', 'g'), '^,\|,$', '', 'g') + let s:prtp = &rtp + + if !empty(s:first_rtp) + execute 'set rtp^='.s:first_rtp + execute 'set rtp+='.s:last_rtp + endif +endfunction + +function! s:doautocmd(...) + if exists('#'.join(a:000, '#')) + execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '' : '') join(a:000) + endif +endfunction + +function! s:dobufread(names) + for name in a:names + let path = s:rtp(g:plugs[name]) + for dir in ['ftdetect', 'ftplugin', 'after/ftdetect', 'after/ftplugin'] + if len(finddir(dir, path)) + if exists('#BufRead') + doautocmd BufRead + endif + return + endif + endfor + endfor +endfunction + +function! plug#load(...) + if a:0 == 0 + return s:err('Argument missing: plugin name(s) required') + endif + if !exists('g:plugs') + return s:err('plug#begin was not called') + endif + let names = a:0 == 1 && type(a:1) == s:TYPE.list ? a:1 : a:000 + let unknowns = filter(copy(names), '!has_key(g:plugs, v:val)') + if !empty(unknowns) + let s = len(unknowns) > 1 ? 's' : '' + return s:err(printf('Unknown plugin%s: %s', s, join(unknowns, ', '))) + end + let unloaded = filter(copy(names), '!get(s:loaded, v:val, 0)') + if !empty(unloaded) + for name in unloaded + call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + endfor + call s:dobufread(unloaded) + return 1 + end + return 0 +endfunction + +function! s:remove_triggers(name) + if !has_key(s:triggers, a:name) + return + endif + for cmd in s:triggers[a:name].cmd + execute 'silent! delc' cmd + endfor + for map in s:triggers[a:name].map + execute 'silent! unmap' map + execute 'silent! iunmap' map + endfor + call remove(s:triggers, a:name) +endfunction + +function! s:lod(names, types, ...) + for name in a:names + call s:remove_triggers(name) + let s:loaded[name] = 1 + endfor + call s:reorg_rtp() + + for name in a:names + let rtp = s:rtp(g:plugs[name]) + for dir in a:types + call s:source(rtp, dir.'/**/*.vim') + endfor + if a:0 + if !s:source(rtp, a:1) && !empty(s:glob(rtp, a:2)) + execute 'runtime' a:1 + endif + call s:source(rtp, a:2) + endif + call s:doautocmd('User', name) + endfor +endfunction + +function! s:lod_ft(pat, names) + let syn = 'syntax/'.a:pat.'.vim' + call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn) + execute 'autocmd! PlugLOD FileType' a:pat + call s:doautocmd('filetypeplugin', 'FileType') + call s:doautocmd('filetypeindent', 'FileType') +endfunction + +function! s:lod_cmd(cmd, bang, l1, l2, args, names) + call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + call s:dobufread(a:names) + execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args) +endfunction + +function! s:lod_map(map, names, with_prefix, prefix) + call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + call s:dobufread(a:names) + let extra = '' + while 1 + let c = getchar(0) + if c == 0 + break + endif + let extra .= nr2char(c) + endwhile + + if a:with_prefix + let prefix = v:count ? v:count : '' + let prefix .= '"'.v:register.a:prefix + if mode(1) == 'no' + if v:operator == 'c' + let prefix = "\" . prefix + endif + let prefix .= v:operator + endif + call feedkeys(prefix, 'n') + endif + call feedkeys(substitute(a:map, '^', "\", '') . extra) +endfunction + +function! plug#(repo, ...) + if a:0 > 1 + return s:err('Invalid number of arguments (1..2)') + endif + + try + let repo = s:trim(a:repo) + let opts = a:0 == 1 ? s:parse_options(a:1) : s:base_spec + let name = get(opts, 'as', fnamemodify(repo, ':t:s?\.git$??')) + let spec = extend(s:infer_properties(name, repo), opts) + if !has_key(g:plugs, name) + call add(g:plugs_order, name) + endif + let g:plugs[name] = spec + let s:loaded[name] = get(s:loaded, name, 0) + catch + return s:err(v:exception) + endtry +endfunction + +function! s:parse_options(arg) + let opts = copy(s:base_spec) + let type = type(a:arg) + if type == s:TYPE.string + let opts.tag = a:arg + elseif type == s:TYPE.dict + call extend(opts, a:arg) + if has_key(opts, 'dir') + let opts.dir = s:dirpath(expand(opts.dir)) + endif + else + throw 'Invalid argument type (expected: string or dictionary)' + endif + return opts +endfunction + +function! s:infer_properties(name, repo) + let repo = a:repo + if s:is_local_plug(repo) + return { 'dir': s:dirpath(expand(repo)) } + else + if repo =~ ':' + let uri = repo + else + if repo !~ '/' + throw printf('Invalid argument: %s (implicit `vim-scripts'' expansion is deprecated)', repo) + endif + let fmt = get(g:, 'plug_url_format', 'https://git::@github.com/%s.git') + let uri = printf(fmt, repo) + endif + return { 'dir': s:dirpath(g:plug_home.'/'.a:name), 'uri': uri } + endif +endfunction + +function! s:install(force, names) + call s:update_impl(0, a:force, a:names) +endfunction + +function! s:update(force, names) + call s:update_impl(1, a:force, a:names) +endfunction + +function! plug#helptags() + if !exists('g:plugs') + return s:err('plug#begin was not called') + endif + for spec in values(g:plugs) + let docd = join([s:rtp(spec), 'doc'], '/') + if isdirectory(docd) + silent! execute 'helptags' s:esc(docd) + endif + endfor + return 1 +endfunction + +function! s:syntax() + syntax clear + syntax region plug1 start=/\%1l/ end=/\%2l/ contains=plugNumber + syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX + syn match plugNumber /[0-9]\+[0-9.]*/ contained + syn match plugBracket /[[\]]/ contained + syn match plugX /x/ contained + syn match plugDash /^-/ + syn match plugPlus /^+/ + syn match plugStar /^*/ + syn match plugMessage /\(^- \)\@<=.*/ + syn match plugName /\(^- \)\@<=[^ ]*:/ + syn match plugSha /\%(: \)\@<=[0-9a-f]\{4,}$/ + syn match plugTag /(tag: [^)]\+)/ + syn match plugInstall /\(^+ \)\@<=[^:]*/ + syn match plugUpdate /\(^* \)\@<=[^:]*/ + syn match plugCommit /^ \X*[0-9a-f]\{7,9} .*/ contains=plugRelDate,plugEdge,plugTag + syn match plugEdge /^ \X\+$/ + syn match plugEdge /^ \X*/ contained nextgroup=plugSha + syn match plugSha /[0-9a-f]\{7,9}/ contained + syn match plugRelDate /([^)]*)$/ contained + syn match plugNotLoaded /(not loaded)$/ + syn match plugError /^x.*/ + syn region plugDeleted start=/^\~ .*/ end=/^\ze\S/ + syn match plugH2 /^.*:\n-\+$/ + syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean + hi def link plug1 Title + hi def link plug2 Repeat + hi def link plugH2 Type + hi def link plugX Exception + hi def link plugBracket Structure + hi def link plugNumber Number + + hi def link plugDash Special + hi def link plugPlus Constant + hi def link plugStar Boolean + + hi def link plugMessage Function + hi def link plugName Label + hi def link plugInstall Function + hi def link plugUpdate Type + + hi def link plugError Error + hi def link plugDeleted Ignore + hi def link plugRelDate Comment + hi def link plugEdge PreProc + hi def link plugSha Identifier + hi def link plugTag Constant + + hi def link plugNotLoaded Comment +endfunction + +function! s:lpad(str, len) + return a:str . repeat(' ', a:len - len(a:str)) +endfunction + +function! s:lines(msg) + return split(a:msg, "[\r\n]") +endfunction + +function! s:lastline(msg) + return get(s:lines(a:msg), -1, '') +endfunction + +function! s:new_window() + execute get(g:, 'plug_window', 'vertical topleft new') +endfunction + +function! s:plug_window_exists() + let buflist = tabpagebuflist(s:plug_tab) + return !empty(buflist) && index(buflist, s:plug_buf) >= 0 +endfunction + +function! s:switch_in() + if !s:plug_window_exists() + return 0 + endif + + if winbufnr(0) != s:plug_buf + let s:pos = [tabpagenr(), winnr(), winsaveview()] + execute 'normal!' s:plug_tab.'gt' + let winnr = bufwinnr(s:plug_buf) + execute winnr.'wincmd w' + call add(s:pos, winsaveview()) + else + let s:pos = [winsaveview()] + endif + + setlocal modifiable + return 1 +endfunction + +function! s:switch_out(...) + call winrestview(s:pos[-1]) + setlocal nomodifiable + if a:0 > 0 + execute a:1 + endif + + if len(s:pos) > 1 + execute 'normal!' s:pos[0].'gt' + execute s:pos[1] 'wincmd w' + call winrestview(s:pos[2]) + endif +endfunction + +function! s:finish_bindings() + nnoremap R :call retry() + nnoremap D :PlugDiff + nnoremap S :PlugStatus + nnoremap U :call status_update() + xnoremap U :call status_update() + nnoremap ]] :silent! call section('') + nnoremap [[ :silent! call section('b') +endfunction + +function! s:prepare(...) + if empty(getcwd()) + throw 'Invalid current working directory. Cannot proceed.' + endif + + for evar in ['$GIT_DIR', '$GIT_WORK_TREE'] + if exists(evar) + throw evar.' detected. Cannot proceed.' + endif + endfor + + call s:job_abort() + if s:switch_in() + if b:plug_preview == 1 + pc + endif + enew + else + call s:new_window() + endif + + nnoremap q :if b:plug_preview==1pcendifbd + if a:0 == 0 + call s:finish_bindings() + endif + let b:plug_preview = -1 + let s:plug_tab = tabpagenr() + let s:plug_buf = winbufnr(0) + call s:assign_name() + + for k in ['', 'L', 'o', 'X', 'd', 'dd'] + execute 'silent! unmap ' k + endfor + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline modifiable nospell + if exists('+colorcolumn') + setlocal colorcolumn= + endif + setf vim-plug + if exists('g:syntax_on') + call s:syntax() + endif +endfunction + +function! s:assign_name() + " Assign buffer name + let prefix = '[Plugins]' + let name = prefix + let idx = 2 + while bufexists(name) + let name = printf('%s (%s)', prefix, idx) + let idx = idx + 1 + endwhile + silent! execute 'f' fnameescape(name) +endfunction + +function! s:chsh(swap) + let prev = [&shell, &shellcmdflag, &shellredir] + if !s:is_win && a:swap + set shell=sh shellredir=>%s\ 2>&1 + endif + return prev +endfunction + +function! s:bang(cmd, ...) + try + let [sh, shellcmdflag, shrd] = s:chsh(a:0) + " FIXME: Escaping is incomplete. We could use shellescape with eval, + " but it won't work on Windows. + let cmd = a:0 ? s:with_cd(a:cmd, a:1) : a:cmd + if s:is_win + let batchfile = tempname().'.bat' + call writefile(["@echo off\r", cmd . "\r"], batchfile) + let cmd = s:shellesc(expand(batchfile)) + endif + let g:_plug_bang = (s:is_win && has('gui_running') ? 'silent ' : '').'!'.escape(cmd, '#!%') + execute "normal! :execute g:_plug_bang\\" + finally + unlet g:_plug_bang + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win + call delete(batchfile) + endif + endtry + return v:shell_error ? 'Exit status: ' . v:shell_error : '' +endfunction + +function! s:regress_bar() + let bar = substitute(getline(2)[1:-2], '.*\zs=', 'x', '') + call s:progress_bar(2, bar, len(bar)) +endfunction + +function! s:is_updated(dir) + return !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"', a:dir)) +endfunction + +function! s:do(pull, force, todo) + for [name, spec] in items(a:todo) + if !isdirectory(spec.dir) + continue + endif + let installed = has_key(s:update.new, name) + let updated = installed ? 0 : + \ (a:pull && index(s:update.errors, name) < 0 && s:is_updated(spec.dir)) + if a:force || installed || updated + execute 'cd' s:esc(spec.dir) + call append(3, '- Post-update hook for '. name .' ... ') + let error = '' + let type = type(spec.do) + if type == s:TYPE.string + if spec.do[0] == ':' + if !get(s:loaded, name, 0) + let s:loaded[name] = 1 + call s:reorg_rtp() + endif + call s:load_plugin(spec) + try + execute spec.do[1:] + catch + let error = v:exception + endtry + if !s:plug_window_exists() + cd - + throw 'Warning: vim-plug was terminated by the post-update hook of '.name + endif + else + let error = s:bang(spec.do) + endif + elseif type == s:TYPE.funcref + try + let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged') + call spec.do({ 'name': name, 'status': status, 'force': a:force }) + catch + let error = v:exception + endtry + else + let error = 'Invalid hook type' + endif + call s:switch_in() + call setline(4, empty(error) ? (getline(4) . 'OK') + \ : ('x' . getline(4)[1:] . error)) + if !empty(error) + call add(s:update.errors, name) + call s:regress_bar() + endif + cd - + endif + endfor +endfunction + +function! s:hash_match(a, b) + return stridx(a:a, a:b) == 0 || stridx(a:b, a:a) == 0 +endfunction + +function! s:checkout(spec) + let sha = a:spec.commit + let output = s:system('git rev-parse HEAD', a:spec.dir) + if !v:shell_error && !s:hash_match(sha, s:lines(output)[0]) + let output = s:system( + \ 'git fetch --depth 999999 && git checkout '.s:esc(sha).' --', a:spec.dir) + endif + return output +endfunction + +function! s:finish(pull) + let new_frozen = len(filter(keys(s:update.new), 'g:plugs[v:val].frozen')) + if new_frozen + let s = new_frozen > 1 ? 's' : '' + call append(3, printf('- Installed %d frozen plugin%s', new_frozen, s)) + endif + call append(3, '- Finishing ... ') | 4 + redraw + call plug#helptags() + call plug#end() + call setline(4, getline(4) . 'Done!') + redraw + let msgs = [] + if !empty(s:update.errors) + call add(msgs, "Press 'R' to retry.") + endif + if a:pull && len(s:update.new) < len(filter(getline(5, '$'), + \ "v:val =~ '^- ' && v:val !~# 'Already up.to.date'")) + call add(msgs, "Press 'D' to see the updated changes.") + endif + echo join(msgs, ' ') + call s:finish_bindings() +endfunction + +function! s:retry() + if empty(s:update.errors) + return + endif + echo + call s:update_impl(s:update.pull, s:update.force, + \ extend(copy(s:update.errors), [s:update.threads])) +endfunction + +function! s:is_managed(name) + return has_key(g:plugs[a:name], 'uri') +endfunction + +function! s:names(...) + return sort(filter(keys(g:plugs), 'stridx(v:val, a:1) == 0 && s:is_managed(v:val)')) +endfunction + +function! s:check_ruby() + silent! ruby require 'thread'; VIM::command("let g:plug_ruby = '#{RUBY_VERSION}'") + if !exists('g:plug_ruby') + redraw! + return s:warn('echom', 'Warning: Ruby interface is broken') + endif + let ruby_version = split(g:plug_ruby, '\.') + unlet g:plug_ruby + return s:version_requirement(ruby_version, [1, 8, 7]) +endfunction + +function! s:update_impl(pull, force, args) abort + let sync = index(a:args, '--sync') >= 0 || has('vim_starting') + let args = filter(copy(a:args), 'v:val != "--sync"') + let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ? + \ remove(args, -1) : get(g:, 'plug_threads', 16) + + let managed = filter(copy(g:plugs), 's:is_managed(v:key)') + let todo = empty(args) ? filter(managed, '!v:val.frozen || !isdirectory(v:val.dir)') : + \ filter(managed, 'index(args, v:key) >= 0') + + if empty(todo) + return s:warn('echo', 'No plugin to '. (a:pull ? 'update' : 'install')) + endif + + if !s:is_win && s:git_version_requirement(2, 3) + let s:git_terminal_prompt = exists('$GIT_TERMINAL_PROMPT') ? $GIT_TERMINAL_PROMPT : '' + let $GIT_TERMINAL_PROMPT = 0 + for plug in values(todo) + let plug.uri = substitute(plug.uri, + \ '^https://git::@github\.com', 'https://github.com', '') + endfor + endif + + if !isdirectory(g:plug_home) + try + call mkdir(g:plug_home, 'p') + catch + return s:err(printf('Invalid plug directory: %s. '. + \ 'Try to call plug#begin with a valid directory', g:plug_home)) + endtry + endif + + if has('nvim') && !exists('*jobwait') && threads > 1 + call s:warn('echom', '[vim-plug] Update Neovim for parallel installer') + endif + + let use_job = s:nvim || s:vim8 + let python = (has('python') || has('python3')) && !use_job + let ruby = has('ruby') && !use_job && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running')) && threads > 1 && s:check_ruby() + + let s:update = { + \ 'start': reltime(), + \ 'all': todo, + \ 'todo': copy(todo), + \ 'errors': [], + \ 'pull': a:pull, + \ 'force': a:force, + \ 'new': {}, + \ 'threads': (python || ruby || use_job) ? min([len(todo), threads]) : 1, + \ 'bar': '', + \ 'fin': 0 + \ } + + call s:prepare(1) + call append(0, ['', '']) + normal! 2G + silent! redraw + + let s:clone_opt = get(g:, 'plug_shallow', 1) ? + \ '--depth 1' . (s:git_version_requirement(1, 7, 10) ? ' --no-single-branch' : '') : '' + + if has('win32unix') + let s:clone_opt .= ' -c core.eol=lf -c core.autocrlf=input' + endif + + let s:submodule_opt = s:git_version_requirement(2, 8) ? ' --jobs='.threads : '' + + " Python version requirement (>= 2.7) + if python && !has('python3') && !ruby && !use_job && s:update.threads > 1 + redir => pyv + silent python import platform; print platform.python_version() + redir END + let python = s:version_requirement( + \ map(split(split(pyv)[0], '\.'), 'str2nr(v:val)'), [2, 6]) + endif + + if (python || ruby) && s:update.threads > 1 + try + let imd = &imd + if s:mac_gui + set noimd + endif + if ruby + call s:update_ruby() + else + call s:update_python() + endif + catch + let lines = getline(4, '$') + let printed = {} + silent! 4,$d _ + for line in lines + let name = s:extract_name(line, '.', '') + if empty(name) || !has_key(printed, name) + call append('$', line) + if !empty(name) + let printed[name] = 1 + if line[0] == 'x' && index(s:update.errors, name) < 0 + call add(s:update.errors, name) + end + endif + endif + endfor + finally + let &imd = imd + call s:update_finish() + endtry + else + call s:update_vim() + while use_job && sync + sleep 100m + if s:update.fin + break + endif + endwhile + endif +endfunction + +function! s:log4(name, msg) + call setline(4, printf('- %s (%s)', a:msg, a:name)) + redraw +endfunction + +function! s:update_finish() + if exists('s:git_terminal_prompt') + let $GIT_TERMINAL_PROMPT = s:git_terminal_prompt + endif + if s:switch_in() + call append(3, '- Updating ...') | 4 + for [name, spec] in items(filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && (s:update.force || s:update.pull || has_key(s:update.new, v:key))')) + let [pos, _] = s:logpos(name) + if !pos + continue + endif + if has_key(spec, 'commit') + call s:log4(name, 'Checking out '.spec.commit) + let out = s:checkout(spec) + elseif has_key(spec, 'tag') + let tag = spec.tag + if tag =~ '\*' + let tags = s:lines(s:system('git tag --list '.s:shellesc(tag).' --sort -version:refname 2>&1', spec.dir)) + if !v:shell_error && !empty(tags) + let tag = tags[0] + call s:log4(name, printf('Latest tag for %s -> %s', spec.tag, tag)) + call append(3, '') + endif + endif + call s:log4(name, 'Checking out '.tag) + let out = s:system('git checkout -q '.s:esc(tag).' -- 2>&1', spec.dir) + else + let branch = s:esc(get(spec, 'branch', 'master')) + call s:log4(name, 'Merging origin/'.branch) + let out = s:system('git checkout -q '.branch.' -- 2>&1' + \. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only origin/'.branch.' 2>&1')), spec.dir) + endif + if !v:shell_error && filereadable(spec.dir.'/.gitmodules') && + \ (s:update.force || has_key(s:update.new, name) || s:is_updated(spec.dir)) + call s:log4(name, 'Updating submodules. This may take a while.') + let out .= s:bang('git submodule update --init --recursive'.s:submodule_opt.' 2>&1', spec.dir) + endif + let msg = s:format_message(v:shell_error ? 'x': '-', name, out) + if v:shell_error + call add(s:update.errors, name) + call s:regress_bar() + silent execute pos 'd _' + call append(4, msg) | 4 + elseif !empty(out) + call setline(pos, msg[0]) + endif + redraw + endfor + silent 4 d _ + try + call s:do(s:update.pull, s:update.force, filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && has_key(v:val, "do")')) + catch + call s:warn('echom', v:exception) + call s:warn('echo', '') + return + endtry + call s:finish(s:update.pull) + call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(s:update.start)))[0] . ' sec.') + call s:switch_out('normal! gg') + endif +endfunction + +function! s:job_abort() + if (!s:nvim && !s:vim8) || !exists('s:jobs') + return + endif + + for [name, j] in items(s:jobs) + if s:nvim + silent! call jobstop(j.jobid) + elseif s:vim8 + silent! call job_stop(j.jobid) + endif + if j.new + call s:system('rm -rf ' . s:shellesc(g:plugs[name].dir)) + endif + endfor + let s:jobs = {} +endfunction + +function! s:last_non_empty_line(lines) + let len = len(a:lines) + for idx in range(len) + let line = a:lines[len-idx-1] + if !empty(line) + return line + endif + endfor + return '' +endfunction + +function! s:job_out_cb(self, data) abort + let self = a:self + let data = remove(self.lines, -1) . a:data + let lines = map(split(data, "\n", 1), 'split(v:val, "\r", 1)[-1]') + call extend(self.lines, lines) + " To reduce the number of buffer updates + let self.tick = get(self, 'tick', -1) + 1 + if !self.running || self.tick % len(s:jobs) == 0 + let bullet = self.running ? (self.new ? '+' : '*') : (self.error ? 'x' : '-') + let result = self.error ? join(self.lines, "\n") : s:last_non_empty_line(self.lines) + call s:log(bullet, self.name, result) + endif +endfunction + +function! s:job_exit_cb(self, data) abort + let a:self.running = 0 + let a:self.error = a:data != 0 + call s:reap(a:self.name) + call s:tick() +endfunction + +function! s:job_cb(fn, job, ch, data) + if !s:plug_window_exists() " plug window closed + return s:job_abort() + endif + call call(a:fn, [a:job, a:data]) +endfunction + +function! s:nvim_cb(job_id, data, event) dict abort + return a:event == 'stdout' ? + \ s:job_cb('s:job_out_cb', self, 0, join(a:data, "\n")) : + \ s:job_cb('s:job_exit_cb', self, 0, a:data) +endfunction + +function! s:spawn(name, cmd, opts) + let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [''], + \ 'batchfile': (s:is_win && (s:nvim || s:vim8)) ? tempname().'.bat' : '', + \ 'new': get(a:opts, 'new', 0) } + let s:jobs[a:name] = job + let cmd = has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd + if !empty(job.batchfile) + call writefile(["@echo off\r", cmd . "\r"], job.batchfile) + let cmd = s:shellesc(expand(job.batchfile)) + endif + let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], cmd) + + if s:nvim + call extend(job, { + \ 'on_stdout': function('s:nvim_cb'), + \ 'on_exit': function('s:nvim_cb'), + \ }) + let jid = jobstart(argv, job) + if jid > 0 + let job.jobid = jid + else + let job.running = 0 + let job.error = 1 + let job.lines = [jid < 0 ? argv[0].' is not executable' : + \ 'Invalid arguments (or job table is full)'] + endif + elseif s:vim8 + let jid = job_start(s:is_win ? join(argv, ' ') : argv, { + \ 'out_cb': function('s:job_cb', ['s:job_out_cb', job]), + \ 'exit_cb': function('s:job_cb', ['s:job_exit_cb', job]), + \ 'out_mode': 'raw' + \}) + if job_status(jid) == 'run' + let job.jobid = jid + else + let job.running = 0 + let job.error = 1 + let job.lines = ['Failed to start job'] + endif + else + let job.lines = s:lines(call('s:system', [cmd])) + let job.error = v:shell_error != 0 + let job.running = 0 + endif +endfunction + +function! s:reap(name) + let job = s:jobs[a:name] + if job.error + call add(s:update.errors, a:name) + elseif get(job, 'new', 0) + let s:update.new[a:name] = 1 + endif + let s:update.bar .= job.error ? 'x' : '=' + + let bullet = job.error ? 'x' : '-' + let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines) + call s:log(bullet, a:name, empty(result) ? 'OK' : result) + call s:bar() + + if has_key(job, 'batchfile') && !empty(job.batchfile) + call delete(job.batchfile) + endif + call remove(s:jobs, a:name) +endfunction + +function! s:bar() + if s:switch_in() + let total = len(s:update.all) + call setline(1, (s:update.pull ? 'Updating' : 'Installing'). + \ ' plugins ('.len(s:update.bar).'/'.total.')') + call s:progress_bar(2, s:update.bar, total) + call s:switch_out() + endif +endfunction + +function! s:logpos(name) + for i in range(4, line('$')) + if getline(i) =~# '^[-+x*] '.a:name.':' + for j in range(i + 1, line('$')) + if getline(j) !~ '^ ' + return [i, j - 1] + endif + endfor + return [i, i] + endif + endfor + return [0, 0] +endfunction + +function! s:log(bullet, name, lines) + if s:switch_in() + let [b, e] = s:logpos(a:name) + if b > 0 + silent execute printf('%d,%d d _', b, e) + if b > winheight('.') + let b = 4 + endif + else + let b = 4 + endif + " FIXME For some reason, nomodifiable is set after :d in vim8 + setlocal modifiable + call append(b - 1, s:format_message(a:bullet, a:name, a:lines)) + call s:switch_out() + endif +endfunction + +function! s:update_vim() + let s:jobs = {} + + call s:bar() + call s:tick() +endfunction + +function! s:tick() + let pull = s:update.pull + let prog = s:progress_opt(s:nvim || s:vim8) +while 1 " Without TCO, Vim stack is bound to explode + if empty(s:update.todo) + if empty(s:jobs) && !s:update.fin + call s:update_finish() + let s:update.fin = 1 + endif + return + endif + + let name = keys(s:update.todo)[0] + let spec = remove(s:update.todo, name) + let new = empty(globpath(spec.dir, '.git', 1)) + + call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...') + redraw + + let has_tag = has_key(spec, 'tag') + if !new + let [error, _] = s:git_validate(spec, 0) + if empty(error) + if pull + let fetch_opt = (has_tag && !empty(globpath(spec.dir, '.git/shallow'))) ? '--depth 99999999' : '' + call s:spawn(name, printf('git fetch %s %s 2>&1', fetch_opt, prog), { 'dir': spec.dir }) + else + let s:jobs[name] = { 'running': 0, 'lines': ['Already installed'], 'error': 0 } + endif + else + let s:jobs[name] = { 'running': 0, 'lines': s:lines(error), 'error': 1 } + endif + else + call s:spawn(name, + \ printf('git clone %s %s %s %s 2>&1', + \ has_tag ? '' : s:clone_opt, + \ prog, + \ s:shellesc(spec.uri), + \ s:shellesc(s:trim(spec.dir))), { 'new': 1 }) + endif + + if !s:jobs[name].running + call s:reap(name) + endif + if len(s:jobs) >= s:update.threads + break + endif +endwhile +endfunction + +function! s:update_python() +let py_exe = has('python') ? 'python' : 'python3' +execute py_exe "<< EOF" +import datetime +import functools +import os +try: + import queue +except ImportError: + import Queue as queue +import random +import re +import shutil +import signal +import subprocess +import tempfile +import threading as thr +import time +import traceback +import vim + +G_NVIM = vim.eval("has('nvim')") == '1' +G_PULL = vim.eval('s:update.pull') == '1' +G_RETRIES = int(vim.eval('get(g:, "plug_retries", 2)')) + 1 +G_TIMEOUT = int(vim.eval('get(g:, "plug_timeout", 60)')) +G_CLONE_OPT = vim.eval('s:clone_opt') +G_PROGRESS = vim.eval('s:progress_opt(1)') +G_LOG_PROB = 1.0 / int(vim.eval('s:update.threads')) +G_STOP = thr.Event() +G_IS_WIN = vim.eval('s:is_win') == '1' + +class PlugError(Exception): + def __init__(self, msg): + self.msg = msg +class CmdTimedOut(PlugError): + pass +class CmdFailed(PlugError): + pass +class InvalidURI(PlugError): + pass +class Action(object): + INSTALL, UPDATE, ERROR, DONE = ['+', '*', 'x', '-'] + +class Buffer(object): + def __init__(self, lock, num_plugs, is_pull): + self.bar = '' + self.event = 'Updating' if is_pull else 'Installing' + self.lock = lock + self.maxy = int(vim.eval('winheight(".")')) + self.num_plugs = num_plugs + + def __where(self, name): + """ Find first line with name in current buffer. Return line num. """ + found, lnum = False, 0 + matcher = re.compile('^[-+x*] {0}:'.format(name)) + for line in vim.current.buffer: + if matcher.search(line) is not None: + found = True + break + lnum += 1 + + if not found: + lnum = -1 + return lnum + + def header(self): + curbuf = vim.current.buffer + curbuf[0] = self.event + ' plugins ({0}/{1})'.format(len(self.bar), self.num_plugs) + + num_spaces = self.num_plugs - len(self.bar) + curbuf[1] = '[{0}{1}]'.format(self.bar, num_spaces * ' ') + + with self.lock: + vim.command('normal! 2G') + vim.command('redraw') + + def write(self, action, name, lines): + first, rest = lines[0], lines[1:] + msg = ['{0} {1}{2}{3}'.format(action, name, ': ' if first else '', first)] + msg.extend([' ' + line for line in rest]) + + try: + if action == Action.ERROR: + self.bar += 'x' + vim.command("call add(s:update.errors, '{0}')".format(name)) + elif action == Action.DONE: + self.bar += '=' + + curbuf = vim.current.buffer + lnum = self.__where(name) + if lnum != -1: # Found matching line num + del curbuf[lnum] + if lnum > self.maxy and action in set([Action.INSTALL, Action.UPDATE]): + lnum = 3 + else: + lnum = 3 + curbuf.append(msg, lnum) + + self.header() + except vim.error: + pass + +class Command(object): + CD = 'cd /d' if G_IS_WIN else 'cd' + + def __init__(self, cmd, cmd_dir=None, timeout=60, cb=None, clean=None): + self.cmd = cmd + if cmd_dir: + self.cmd = '{0} {1} && {2}'.format(Command.CD, cmd_dir, self.cmd) + self.timeout = timeout + self.callback = cb if cb else (lambda msg: None) + self.clean = clean if clean else (lambda: None) + self.proc = None + + @property + def alive(self): + """ Returns true only if command still running. """ + return self.proc and self.proc.poll() is None + + def execute(self, ntries=3): + """ Execute the command with ntries if CmdTimedOut. + Returns the output of the command if no Exception. + """ + attempt, finished, limit = 0, False, self.timeout + + while not finished: + try: + attempt += 1 + result = self.try_command() + finished = True + return result + except CmdTimedOut: + if attempt != ntries: + self.notify_retry() + self.timeout += limit + else: + raise + + def notify_retry(self): + """ Retry required for command, notify user. """ + for count in range(3, 0, -1): + if G_STOP.is_set(): + raise KeyboardInterrupt + msg = 'Timeout. Will retry in {0} second{1} ...'.format( + count, 's' if count != 1 else '') + self.callback([msg]) + time.sleep(1) + self.callback(['Retrying ...']) + + def try_command(self): + """ Execute a cmd & poll for callback. Returns list of output. + Raises CmdFailed -> return code for Popen isn't 0 + Raises CmdTimedOut -> command exceeded timeout without new output + """ + first_line = True + + try: + tfile = tempfile.NamedTemporaryFile(mode='w+b') + preexec_fn = not G_IS_WIN and os.setsid or None + self.proc = subprocess.Popen(self.cmd, stdout=tfile, + stderr=subprocess.STDOUT, + stdin=subprocess.PIPE, shell=True, + preexec_fn=preexec_fn) + thrd = thr.Thread(target=(lambda proc: proc.wait()), args=(self.proc,)) + thrd.start() + + thread_not_started = True + while thread_not_started: + try: + thrd.join(0.1) + thread_not_started = False + except RuntimeError: + pass + + while self.alive: + if G_STOP.is_set(): + raise KeyboardInterrupt + + if first_line or random.random() < G_LOG_PROB: + first_line = False + line = '' if G_IS_WIN else nonblock_read(tfile.name) + if line: + self.callback([line]) + + time_diff = time.time() - os.path.getmtime(tfile.name) + if time_diff > self.timeout: + raise CmdTimedOut(['Timeout!']) + + thrd.join(0.5) + + tfile.seek(0) + result = [line.decode('utf-8', 'replace').rstrip() for line in tfile] + + if self.proc.returncode != 0: + raise CmdFailed([''] + result) + + return result + except: + self.terminate() + raise + + def terminate(self): + """ Terminate process and cleanup. """ + if self.alive: + if G_IS_WIN: + os.kill(self.proc.pid, signal.SIGINT) + else: + os.killpg(self.proc.pid, signal.SIGTERM) + self.clean() + +class Plugin(object): + def __init__(self, name, args, buf_q, lock): + self.name = name + self.args = args + self.buf_q = buf_q + self.lock = lock + self.tag = args.get('tag', 0) + + def manage(self): + try: + if os.path.exists(self.args['dir']): + self.update() + else: + self.install() + with self.lock: + thread_vim_command("let s:update.new['{0}'] = 1".format(self.name)) + except PlugError as exc: + self.write(Action.ERROR, self.name, exc.msg) + except KeyboardInterrupt: + G_STOP.set() + self.write(Action.ERROR, self.name, ['Interrupted!']) + except: + # Any exception except those above print stack trace + msg = 'Trace:\n{0}'.format(traceback.format_exc().rstrip()) + self.write(Action.ERROR, self.name, msg.split('\n')) + raise + + def install(self): + target = self.args['dir'] + if target[-1] == '\\': + target = target[0:-1] + + def clean(target): + def _clean(): + try: + shutil.rmtree(target) + except OSError: + pass + return _clean + + self.write(Action.INSTALL, self.name, ['Installing ...']) + callback = functools.partial(self.write, Action.INSTALL, self.name) + cmd = 'git clone {0} {1} {2} {3} 2>&1'.format( + '' if self.tag else G_CLONE_OPT, G_PROGRESS, self.args['uri'], + esc(target)) + com = Command(cmd, None, G_TIMEOUT, callback, clean(target)) + result = com.execute(G_RETRIES) + self.write(Action.DONE, self.name, result[-1:]) + + def repo_uri(self): + cmd = 'git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url' + command = Command(cmd, self.args['dir'], G_TIMEOUT,) + result = command.execute(G_RETRIES) + return result[-1] + + def update(self): + actual_uri = self.repo_uri() + expect_uri = self.args['uri'] + regex = re.compile(r'^(?:\w+://)?(?:[^@/]*@)?([^:/]*(?::[0-9]*)?)[:/](.*?)(?:\.git)?/?$') + ma = regex.match(actual_uri) + mb = regex.match(expect_uri) + if ma is None or mb is None or ma.groups() != mb.groups(): + msg = ['', + 'Invalid URI: {0}'.format(actual_uri), + 'Expected {0}'.format(expect_uri), + 'PlugClean required.'] + raise InvalidURI(msg) + + if G_PULL: + self.write(Action.UPDATE, self.name, ['Updating ...']) + callback = functools.partial(self.write, Action.UPDATE, self.name) + fetch_opt = '--depth 99999999' if self.tag and os.path.isfile(os.path.join(self.args['dir'], '.git/shallow')) else '' + cmd = 'git fetch {0} {1} 2>&1'.format(fetch_opt, G_PROGRESS) + com = Command(cmd, self.args['dir'], G_TIMEOUT, callback) + result = com.execute(G_RETRIES) + self.write(Action.DONE, self.name, result[-1:]) + else: + self.write(Action.DONE, self.name, ['Already installed']) + + def write(self, action, name, msg): + self.buf_q.put((action, name, msg)) + +class PlugThread(thr.Thread): + def __init__(self, tname, args): + super(PlugThread, self).__init__() + self.tname = tname + self.args = args + + def run(self): + thr.current_thread().name = self.tname + buf_q, work_q, lock = self.args + + try: + while not G_STOP.is_set(): + name, args = work_q.get_nowait() + plug = Plugin(name, args, buf_q, lock) + plug.manage() + work_q.task_done() + except queue.Empty: + pass + +class RefreshThread(thr.Thread): + def __init__(self, lock): + super(RefreshThread, self).__init__() + self.lock = lock + self.running = True + + def run(self): + while self.running: + with self.lock: + thread_vim_command('noautocmd normal! a') + time.sleep(0.33) + + def stop(self): + self.running = False + +if G_NVIM: + def thread_vim_command(cmd): + vim.session.threadsafe_call(lambda: vim.command(cmd)) +else: + def thread_vim_command(cmd): + vim.command(cmd) + +def esc(name): + return '"' + name.replace('"', '\"') + '"' + +def nonblock_read(fname): + """ Read a file with nonblock flag. Return the last line. """ + fread = os.open(fname, os.O_RDONLY | os.O_NONBLOCK) + buf = os.read(fread, 100000).decode('utf-8', 'replace') + os.close(fread) + + line = buf.rstrip('\r\n') + left = max(line.rfind('\r'), line.rfind('\n')) + if left != -1: + left += 1 + line = line[left:] + + return line + +def main(): + thr.current_thread().name = 'main' + nthreads = int(vim.eval('s:update.threads')) + plugs = vim.eval('s:update.todo') + mac_gui = vim.eval('s:mac_gui') == '1' + + lock = thr.Lock() + buf = Buffer(lock, len(plugs), G_PULL) + buf_q, work_q = queue.Queue(), queue.Queue() + for work in plugs.items(): + work_q.put(work) + + start_cnt = thr.active_count() + for num in range(nthreads): + tname = 'PlugT-{0:02}'.format(num) + thread = PlugThread(tname, (buf_q, work_q, lock)) + thread.start() + if mac_gui: + rthread = RefreshThread(lock) + rthread.start() + + while not buf_q.empty() or thr.active_count() != start_cnt: + try: + action, name, msg = buf_q.get(True, 0.25) + buf.write(action, name, ['OK'] if not msg else msg) + buf_q.task_done() + except queue.Empty: + pass + except KeyboardInterrupt: + G_STOP.set() + + if mac_gui: + rthread.stop() + rthread.join() + +main() +EOF +endfunction + +function! s:update_ruby() + ruby << EOF + module PlugStream + SEP = ["\r", "\n", nil] + def get_line + buffer = '' + loop do + char = readchar rescue return + if SEP.include? char.chr + buffer << $/ + break + else + buffer << char + end + end + buffer + end + end unless defined?(PlugStream) + + def esc arg + %["#{arg.gsub('"', '\"')}"] + end + + def killall pid + pids = [pid] + if /mswin|mingw|bccwin/ =~ RUBY_PLATFORM + pids.each { |pid| Process.kill 'INT', pid.to_i rescue nil } + else + unless `which pgrep 2> /dev/null`.empty? + children = pids + until children.empty? + children = children.map { |pid| + `pgrep -P #{pid}`.lines.map { |l| l.chomp } + }.flatten + pids += children + end + end + pids.each { |pid| Process.kill 'TERM', pid.to_i rescue nil } + end + end + + def compare_git_uri a, b + regex = %r{^(?:\w+://)?(?:[^@/]*@)?([^:/]*(?::[0-9]*)?)[:/](.*?)(?:\.git)?/?$} + regex.match(a).to_a.drop(1) == regex.match(b).to_a.drop(1) + end + + require 'thread' + require 'fileutils' + require 'timeout' + running = true + iswin = VIM::evaluate('s:is_win').to_i == 1 + pull = VIM::evaluate('s:update.pull').to_i == 1 + base = VIM::evaluate('g:plug_home') + all = VIM::evaluate('s:update.todo') + limit = VIM::evaluate('get(g:, "plug_timeout", 60)') + tries = VIM::evaluate('get(g:, "plug_retries", 2)') + 1 + nthr = VIM::evaluate('s:update.threads').to_i + maxy = VIM::evaluate('winheight(".")').to_i + vim7 = VIM::evaluate('v:version').to_i <= 703 && RUBY_PLATFORM =~ /darwin/ + cd = iswin ? 'cd /d' : 'cd' + tot = VIM::evaluate('len(s:update.todo)') || 0 + bar = '' + skip = 'Already installed' + mtx = Mutex.new + take1 = proc { mtx.synchronize { running && all.shift } } + logh = proc { + cnt = bar.length + $curbuf[1] = "#{pull ? 'Updating' : 'Installing'} plugins (#{cnt}/#{tot})" + $curbuf[2] = '[' + bar.ljust(tot) + ']' + VIM::command('normal! 2G') + VIM::command('redraw') + } + where = proc { |name| (1..($curbuf.length)).find { |l| $curbuf[l] =~ /^[-+x*] #{name}:/ } } + log = proc { |name, result, type| + mtx.synchronize do + ing = ![true, false].include?(type) + bar += type ? '=' : 'x' unless ing + b = case type + when :install then '+' when :update then '*' + when true, nil then '-' else + VIM::command("call add(s:update.errors, '#{name}')") + 'x' + end + result = + if type || type.nil? + ["#{b} #{name}: #{result.lines.to_a.last || 'OK'}"] + elsif result =~ /^Interrupted|^Timeout/ + ["#{b} #{name}: #{result}"] + else + ["#{b} #{name}"] + result.lines.map { |l| " " << l } + end + if lnum = where.call(name) + $curbuf.delete lnum + lnum = 4 if ing && lnum > maxy + end + result.each_with_index do |line, offset| + $curbuf.append((lnum || 4) - 1 + offset, line.gsub(/\e\[./, '').chomp) + end + logh.call + end + } + bt = proc { |cmd, name, type, cleanup| + tried = timeout = 0 + begin + tried += 1 + timeout += limit + fd = nil + data = '' + if iswin + Timeout::timeout(timeout) do + tmp = VIM::evaluate('tempname()') + system("(#{cmd}) > #{tmp}") + data = File.read(tmp).chomp + File.unlink tmp rescue nil + end + else + fd = IO.popen(cmd).extend(PlugStream) + first_line = true + log_prob = 1.0 / nthr + while line = Timeout::timeout(timeout) { fd.get_line } + data << line + log.call name, line.chomp, type if name && (first_line || rand < log_prob) + first_line = false + end + fd.close + end + [$? == 0, data.chomp] + rescue Timeout::Error, Interrupt => e + if fd && !fd.closed? + killall fd.pid + fd.close + end + cleanup.call if cleanup + if e.is_a?(Timeout::Error) && tried < tries + 3.downto(1) do |countdown| + s = countdown > 1 ? 's' : '' + log.call name, "Timeout. Will retry in #{countdown} second#{s} ...", type + sleep 1 + end + log.call name, 'Retrying ...', type + retry + end + [false, e.is_a?(Interrupt) ? "Interrupted!" : "Timeout!"] + end + } + main = Thread.current + threads = [] + watcher = Thread.new { + if vim7 + while VIM::evaluate('getchar(1)') + sleep 0.1 + end + else + require 'io/console' # >= Ruby 1.9 + nil until IO.console.getch == 3.chr + end + mtx.synchronize do + running = false + threads.each { |t| t.raise Interrupt } unless vim7 + end + threads.each { |t| t.join rescue nil } + main.kill + } + refresh = Thread.new { + while true + mtx.synchronize do + break unless running + VIM::command('noautocmd normal! a') + end + sleep 0.2 + end + } if VIM::evaluate('s:mac_gui') == 1 + + clone_opt = VIM::evaluate('s:clone_opt') + progress = VIM::evaluate('s:progress_opt(1)') + nthr.times do + mtx.synchronize do + threads << Thread.new { + while pair = take1.call + name = pair.first + dir, uri, tag = pair.last.values_at *%w[dir uri tag] + exists = File.directory? dir + ok, result = + if exists + chdir = "#{cd} #{iswin ? dir : esc(dir)}" + ret, data = bt.call "#{chdir} && git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url", nil, nil, nil + current_uri = data.lines.to_a.last + if !ret + if data =~ /^Interrupted|^Timeout/ + [false, data] + else + [false, [data.chomp, "PlugClean required."].join($/)] + end + elsif !compare_git_uri(current_uri, uri) + [false, ["Invalid URI: #{current_uri}", + "Expected: #{uri}", + "PlugClean required."].join($/)] + else + if pull + log.call name, 'Updating ...', :update + fetch_opt = (tag && File.exist?(File.join(dir, '.git/shallow'))) ? '--depth 99999999' : '' + bt.call "#{chdir} && git fetch #{fetch_opt} #{progress} 2>&1", name, :update, nil + else + [true, skip] + end + end + else + d = esc dir.sub(%r{[\\/]+$}, '') + log.call name, 'Installing ...', :install + bt.call "git clone #{clone_opt unless tag} #{progress} #{uri} #{d} 2>&1", name, :install, proc { + FileUtils.rm_rf dir + } + end + mtx.synchronize { VIM::command("let s:update.new['#{name}'] = 1") } if !exists && ok + log.call name, result, ok + end + } if running + end + end + threads.each { |t| t.join rescue nil } + logh.call + refresh.kill if refresh + watcher.kill +EOF +endfunction + +function! s:shellesc_cmd(arg) + let escaped = substitute(a:arg, '[&|<>()@^]', '^&', 'g') + let escaped = substitute(escaped, '%', '%%', 'g') + let escaped = substitute(escaped, '"', '\\^&', 'g') + let escaped = substitute(escaped, '\(\\\+\)\(\\^\)', '\1\1\2', 'g') + return '^"'.substitute(escaped, '\(\\\+\)$', '\1\1', '').'^"' +endfunction + +function! s:shellesc(arg) + if &shell =~# 'cmd.exe$' + return s:shellesc_cmd(a:arg) + endif + return shellescape(a:arg) +endfunction + +function! s:glob_dir(path) + return map(filter(s:glob(a:path, '**'), 'isdirectory(v:val)'), 's:dirpath(v:val)') +endfunction + +function! s:progress_bar(line, bar, total) + call setline(a:line, '[' . s:lpad(a:bar, a:total) . ']') +endfunction + +function! s:compare_git_uri(a, b) + " See `git help clone' + " https:// [user@] github.com[:port] / junegunn/vim-plug [.git] + " [git@] github.com[:port] : junegunn/vim-plug [.git] + " file:// / junegunn/vim-plug [/] + " / junegunn/vim-plug [/] + let pat = '^\%(\w\+://\)\='.'\%([^@/]*@\)\='.'\([^:/]*\%(:[0-9]*\)\=\)'.'[:/]'.'\(.\{-}\)'.'\%(\.git\)\=/\?$' + let ma = matchlist(a:a, pat) + let mb = matchlist(a:b, pat) + return ma[1:2] ==# mb[1:2] +endfunction + +function! s:format_message(bullet, name, message) + if a:bullet != 'x' + return [printf('%s %s: %s', a:bullet, a:name, s:lastline(a:message))] + else + let lines = map(s:lines(a:message), '" ".v:val') + return extend([printf('x %s:', a:name)], lines) + endif +endfunction + +function! s:with_cd(cmd, dir) + return printf('cd%s %s && %s', s:is_win ? ' /d' : '', s:shellesc(a:dir), a:cmd) +endfunction + +function! s:system(cmd, ...) + try + let [sh, shellcmdflag, shrd] = s:chsh(1) + let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd + if s:is_win + let batchfile = tempname().'.bat' + call writefile(["@echo off\r", cmd . "\r"], batchfile) + let cmd = s:shellesc(expand(batchfile)) + endif + return system(cmd) + finally + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win + call delete(batchfile) + endif + endtry +endfunction + +function! s:system_chomp(...) + let ret = call('s:system', a:000) + return v:shell_error ? '' : substitute(ret, '\n$', '', '') +endfunction + +function! s:git_validate(spec, check_branch) + let err = '' + if isdirectory(a:spec.dir) + let result = s:lines(s:system('git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url', a:spec.dir)) + let remote = result[-1] + if v:shell_error + let err = join([remote, 'PlugClean required.'], "\n") + elseif !s:compare_git_uri(remote, a:spec.uri) + let err = join(['Invalid URI: '.remote, + \ 'Expected: '.a:spec.uri, + \ 'PlugClean required.'], "\n") + elseif a:check_branch && has_key(a:spec, 'commit') + let result = s:lines(s:system('git rev-parse HEAD 2>&1', a:spec.dir)) + let sha = result[-1] + if v:shell_error + let err = join(add(result, 'PlugClean required.'), "\n") + elseif !s:hash_match(sha, a:spec.commit) + let err = join([printf('Invalid HEAD (expected: %s, actual: %s)', + \ a:spec.commit[:6], sha[:6]), + \ 'PlugUpdate required.'], "\n") + endif + elseif a:check_branch + let branch = result[0] + " Check tag + if has_key(a:spec, 'tag') + let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir) + if a:spec.tag !=# tag && a:spec.tag !~ '\*' + let err = printf('Invalid tag: %s (expected: %s). Try PlugUpdate.', + \ (empty(tag) ? 'N/A' : tag), a:spec.tag) + endif + " Check branch + elseif a:spec.branch !=# branch + let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.', + \ branch, a:spec.branch) + endif + if empty(err) + let [ahead, behind] = split(s:lastline(s:system(printf( + \ 'git rev-list --count --left-right HEAD...origin/%s', + \ a:spec.branch), a:spec.dir)), '\t') + if !v:shell_error && ahead + if behind + " Only mention PlugClean if diverged, otherwise it's likely to be + " pushable (and probably not that messed up). + let err = printf( + \ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n" + \ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', a:spec.branch, ahead, behind) + else + let err = printf("Ahead of origin/%s by %d commit(s).\n" + \ .'Cannot update until local changes are pushed.', + \ a:spec.branch, ahead) + endif + endif + endif + endif + else + let err = 'Not found' + endif + return [err, err =~# 'PlugClean'] +endfunction + +function! s:rm_rf(dir) + if isdirectory(a:dir) + call s:system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . s:shellesc(a:dir)) + endif +endfunction + +function! s:clean(force) + call s:prepare() + call append(0, 'Searching for invalid plugins in '.g:plug_home) + call append(1, '') + + " List of valid directories + let dirs = [] + let errs = {} + let [cnt, total] = [0, len(g:plugs)] + for [name, spec] in items(g:plugs) + if !s:is_managed(name) + call add(dirs, spec.dir) + else + let [err, clean] = s:git_validate(spec, 1) + if clean + let errs[spec.dir] = s:lines(err)[0] + else + call add(dirs, spec.dir) + endif + endif + let cnt += 1 + call s:progress_bar(2, repeat('=', cnt), total) + normal! 2G + redraw + endfor + + let allowed = {} + for dir in dirs + let allowed[s:dirpath(fnamemodify(dir, ':h:h'))] = 1 + let allowed[dir] = 1 + for child in s:glob_dir(dir) + let allowed[child] = 1 + endfor + endfor + + let todo = [] + let found = sort(s:glob_dir(g:plug_home)) + while !empty(found) + let f = remove(found, 0) + if !has_key(allowed, f) && isdirectory(f) + call add(todo, f) + call append(line('$'), '- ' . f) + if has_key(errs, f) + call append(line('$'), ' ' . errs[f]) + endif + let found = filter(found, 'stridx(v:val, f) != 0') + end + endwhile + + 4 + redraw + if empty(todo) + call append(line('$'), 'Already clean.') + else + let s:clean_count = 0 + call append(3, ['Directories to delete:', '']) + redraw! + if a:force || s:ask_no_interrupt('Delete all directories?') + call s:delete([6, line('$')], 1) + else + call setline(4, 'Cancelled.') + nnoremap d :set opfunc=delete_opg@ + nmap dd d_ + xnoremap d :call delete_op(visualmode(), 1) + echo 'Delete the lines (d{motion}) to delete the corresponding directories' + endif + endif + 4 + setlocal nomodifiable +endfunction + +function! s:delete_op(type, ...) + call s:delete(a:0 ? [line("'<"), line("'>")] : [line("'["), line("']")], 0) +endfunction + +function! s:delete(range, force) + let [l1, l2] = a:range + let force = a:force + while l1 <= l2 + let line = getline(l1) + if line =~ '^- ' && isdirectory(line[2:]) + execute l1 + redraw! + let answer = force ? 1 : s:ask('Delete '.line[2:].'?', 1) + let force = force || answer > 1 + if answer + call s:rm_rf(line[2:]) + setlocal modifiable + call setline(l1, '~'.line[1:]) + let s:clean_count += 1 + call setline(4, printf('Removed %d directories.', s:clean_count)) + setlocal nomodifiable + endif + endif + let l1 += 1 + endwhile +endfunction + +function! s:upgrade() + echo 'Downloading the latest version of vim-plug' + redraw + let tmp = tempname() + let new = tmp . '/plug.vim' + + try + let out = s:system(printf('git clone --depth 1 %s %s', s:shellesc(s:plug_src), s:shellesc(tmp))) + if v:shell_error + return s:err('Error upgrading vim-plug: '. out) + endif + + if readfile(s:me) ==# readfile(new) + echo 'vim-plug is already up-to-date' + return 0 + else + call rename(s:me, s:me . '.old') + call rename(new, s:me) + unlet g:loaded_plug + echo 'vim-plug has been upgraded' + return 1 + endif + finally + silent! call s:rm_rf(tmp) + endtry +endfunction + +function! s:upgrade_specs() + for spec in values(g:plugs) + let spec.frozen = get(spec, 'frozen', 0) + endfor +endfunction + +function! s:status() + call s:prepare() + call append(0, 'Checking plugins') + call append(1, '') + + let ecnt = 0 + let unloaded = 0 + let [cnt, total] = [0, len(g:plugs)] + for [name, spec] in items(g:plugs) + let is_dir = isdirectory(spec.dir) + if has_key(spec, 'uri') + if is_dir + let [err, _] = s:git_validate(spec, 1) + let [valid, msg] = [empty(err), empty(err) ? 'OK' : err] + else + let [valid, msg] = [0, 'Not found. Try PlugInstall.'] + endif + else + if is_dir + let [valid, msg] = [1, 'OK'] + else + let [valid, msg] = [0, 'Not found.'] + endif + endif + let cnt += 1 + let ecnt += !valid + " `s:loaded` entry can be missing if PlugUpgraded + if is_dir && get(s:loaded, name, -1) == 0 + let unloaded = 1 + let msg .= ' (not loaded)' + endif + call s:progress_bar(2, repeat('=', cnt), total) + call append(3, s:format_message(valid ? '-' : 'x', name, msg)) + normal! 2G + redraw + endfor + call setline(1, 'Finished. '.ecnt.' error(s).') + normal! gg + setlocal nomodifiable + if unloaded + echo "Press 'L' on each line to load plugin, or 'U' to update" + nnoremap L :call status_load(line('.')) + xnoremap L :call status_load(line('.')) + end +endfunction + +function! s:extract_name(str, prefix, suffix) + return matchstr(a:str, '^'.a:prefix.' \zs[^:]\+\ze:.*'.a:suffix.'$') +endfunction + +function! s:status_load(lnum) + let line = getline(a:lnum) + let name = s:extract_name(line, '-', '(not loaded)') + if !empty(name) + call plug#load(name) + setlocal modifiable + call setline(a:lnum, substitute(line, ' (not loaded)$', '', '')) + setlocal nomodifiable + endif +endfunction + +function! s:status_update() range + let lines = getline(a:firstline, a:lastline) + let names = filter(map(lines, 's:extract_name(v:val, "[x-]", "")'), '!empty(v:val)') + if !empty(names) + echo + execute 'PlugUpdate' join(names) + endif +endfunction + +function! s:is_preview_window_open() + silent! wincmd P + if &previewwindow + wincmd p + return 1 + endif +endfunction + +function! s:find_name(lnum) + for lnum in reverse(range(1, a:lnum)) + let line = getline(lnum) + if empty(line) + return '' + endif + let name = s:extract_name(line, '-', '') + if !empty(name) + return name + endif + endfor + return '' +endfunction + +function! s:preview_commit() + if b:plug_preview < 0 + let b:plug_preview = !s:is_preview_window_open() + endif + + let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}') + if empty(sha) + return + endif + + let name = s:find_name(line('.')) + if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir) + return + endif + + if exists('g:plug_pwindow') && !s:is_preview_window_open() + execute g:plug_pwindow + execute 'e' sha + else + execute 'pedit' sha + wincmd P + endif + setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable + try + let [sh, shellcmdflag, shrd] = s:chsh(1) + let cmd = 'cd '.s:shellesc(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha + if s:is_win + let batchfile = tempname().'.bat' + call writefile(["@echo off\r", cmd . "\r"], batchfile) + let cmd = expand(batchfile) + endif + execute 'silent %!' cmd + finally + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win + call delete(batchfile) + endif + endtry + setlocal nomodifiable + nnoremap q :q + wincmd p +endfunction + +function! s:section(flags) + call search('\(^[x-] \)\@<=[^:]\+:', a:flags) +endfunction + +function! s:format_git_log(line) + let indent = ' ' + let tokens = split(a:line, nr2char(1)) + if len(tokens) != 5 + return indent.substitute(a:line, '\s*$', '', '') + endif + let [graph, sha, refs, subject, date] = tokens + let tag = matchstr(refs, 'tag: [^,)]\+') + let tag = empty(tag) ? ' ' : ' ('.tag.') ' + return printf('%s%s%s%s%s (%s)', indent, graph, sha, tag, subject, date) +endfunction + +function! s:append_ul(lnum, text) + call append(a:lnum, ['', a:text, repeat('-', len(a:text))]) +endfunction + +function! s:diff() + call s:prepare() + call append(0, ['Collecting changes ...', '']) + let cnts = [0, 0] + let bar = '' + let total = filter(copy(g:plugs), 's:is_managed(v:key) && isdirectory(v:val.dir)') + call s:progress_bar(2, bar, len(total)) + for origin in [1, 0] + let plugs = reverse(sort(items(filter(copy(total), (origin ? '' : '!').'(has_key(v:val, "commit") || has_key(v:val, "tag"))')))) + if empty(plugs) + continue + endif + call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:') + for [k, v] in plugs + let range = origin ? '..origin/'.v.branch : 'HEAD@{1}..' + let cmd = 'git log --graph --color=never '.join(map(['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range], 's:shellesc(v:val)')) + if has_key(v, 'rtp') + let cmd .= ' -- '.s:shellesc(v.rtp) + endif + let diff = s:system_chomp(cmd, v.dir) + if !empty(diff) + let ref = has_key(v, 'tag') ? (' (tag: '.v.tag.')') : has_key(v, 'commit') ? (' '.v.commit) : '' + call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)'))) + let cnts[origin] += 1 + endif + let bar .= '=' + call s:progress_bar(2, bar, len(total)) + normal! 2G + redraw + endfor + if !cnts[origin] + call append(5, ['', 'N/A']) + endif + endfor + call setline(1, printf('%d plugin(s) updated.', cnts[0]) + \ . (cnts[1] ? printf(' %d plugin(s) have pending updates.', cnts[1]) : '')) + + if cnts[0] || cnts[1] + nnoremap (plug-preview) :silent! call preview_commit() + if empty(maparg("\", 'n')) + nmap (plug-preview) + endif + if empty(maparg('o', 'n')) + nmap o (plug-preview) + endif + endif + if cnts[0] + nnoremap X :call revert() + echo "Press 'X' on each block to revert the update" + endif + normal! gg + setlocal nomodifiable +endfunction + +function! s:revert() + if search('^Pending updates', 'bnW') + return + endif + + let name = s:find_name(line('.')) + if empty(name) || !has_key(g:plugs, name) || + \ input(printf('Revert the update of %s? (y/N) ', name)) !~? '^y' + return + endif + + call s:system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch).' --', g:plugs[name].dir) + setlocal modifiable + normal! "_dap + setlocal nomodifiable + echo 'Reverted' +endfunction + +function! s:snapshot(force, ...) abort + call s:prepare() + setf vim + call append(0, ['" Generated by vim-plug', + \ '" '.strftime("%c"), + \ '" :source this file in vim to restore the snapshot', + \ '" or execute: vim -S snapshot.vim', + \ '', '', 'PlugUpdate!']) + 1 + let anchor = line('$') - 3 + let names = sort(keys(filter(copy(g:plugs), + \'has_key(v:val, "uri") && !has_key(v:val, "commit") && isdirectory(v:val.dir)'))) + for name in reverse(names) + let sha = s:system_chomp('git rev-parse --short HEAD', g:plugs[name].dir) + if !empty(sha) + call append(anchor, printf("silent! let g:plugs['%s'].commit = '%s'", name, sha)) + redraw + endif + endfor + + if a:0 > 0 + let fn = expand(a:1) + if filereadable(fn) && !(a:force || s:ask(a:1.' already exists. Overwrite?')) + return + endif + call writefile(getline(1, '$'), fn) + echo 'Saved as '.a:1 + silent execute 'e' s:esc(fn) + setf vim + endif +endfunction + +function! s:split_rtp() + return split(&rtp, '\\\@`-mappings | +"| `for` | On-demand loading: File types | +"| `frozen` | Do not update unless explicitly specified | +" +" More information: https://github.com/junegunn/vim-plug +" +" +" Copyright (c) 2017 Junegunn Choi +" +" MIT License +" +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be +" included in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +if exists('g:loaded_plug') + finish +endif +let g:loaded_plug = 1 + +let s:cpo_save = &cpo +set cpo&vim + +let s:plug_src = 'https://github.com/junegunn/vim-plug.git' +let s:plug_tab = get(s:, 'plug_tab', -1) +let s:plug_buf = get(s:, 'plug_buf', -1) +let s:mac_gui = has('gui_macvim') && has('gui_running') +let s:is_win = has('win32') +let s:nvim = has('nvim-0.2') || (has('nvim') && exists('*jobwait') && !s:is_win) +let s:vim8 = has('patch-8.0.0039') && exists('*job_start') +let s:me = resolve(expand(':p')) +let s:base_spec = { 'branch': 'master', 'frozen': 0 } +let s:TYPE = { +\ 'string': type(''), +\ 'list': type([]), +\ 'dict': type({}), +\ 'funcref': type(function('call')) +\ } +let s:loaded = get(s:, 'loaded', {}) +let s:triggers = get(s:, 'triggers', {}) + +function! plug#begin(...) + if a:0 > 0 + let s:plug_home_org = a:1 + let home = s:path(fnamemodify(expand(a:1), ':p')) + elseif exists('g:plug_home') + let home = s:path(g:plug_home) + elseif !empty(&rtp) + let home = s:path(split(&rtp, ',')[0]) . '/plugged' + else + return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.') + endif + if fnamemodify(home, ':t') ==# 'plugin' && fnamemodify(home, ':h') ==# s:first_rtp + return s:err('Invalid plug home. '.home.' is a standard Vim runtime path and is not allowed.') + endif + + let g:plug_home = home + let g:plugs = {} + let g:plugs_order = [] + let s:triggers = {} + + call s:define_commands() + return 1 +endfunction + +function! s:define_commands() + command! -nargs=+ -bar Plug call plug#() + if !executable('git') + return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.') + endif + command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install(0, []) + command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update(0, []) + command! -nargs=0 -bar -bang PlugClean call s:clean(0) + command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source' s:esc(s:me) | endif + command! -nargs=0 -bar PlugStatus call s:status() + command! -nargs=0 -bar PlugDiff call s:diff() + command! -nargs=? -bar -bang -complete=file PlugSnapshot call s:snapshot(0, ) +endfunction + +function! s:to_a(v) + return type(a:v) == s:TYPE.list ? a:v : [a:v] +endfunction + +function! s:to_s(v) + return type(a:v) == s:TYPE.string ? a:v : join(a:v, "\n") . "\n" +endfunction + +function! s:glob(from, pattern) + return s:lines(globpath(a:from, a:pattern)) +endfunction + +function! s:source(from, ...) + let found = 0 + for pattern in a:000 + for vim in s:glob(a:from, pattern) + execute 'source' s:esc(vim) + let found = 1 + endfor + endfor + return found +endfunction + +function! s:assoc(dict, key, val) + let a:dict[a:key] = add(get(a:dict, a:key, []), a:val) +endfunction + +function! s:ask(message, ...) + call inputsave() + echohl WarningMsg + let answer = input(a:message.(a:0 ? ' (y/N/a) ' : ' (y/N) ')) + echohl None + call inputrestore() + echo "\r" + return (a:0 && answer =~? '^a') ? 2 : (answer =~? '^y') ? 1 : 0 +endfunction + +function! s:ask_no_interrupt(...) + try + return call('s:ask', a:000) + catch + return 0 + endtry +endfunction + +function! s:lazy(plug, opt) + return has_key(a:plug, a:opt) && + \ (empty(s:to_a(a:plug[a:opt])) || + \ !isdirectory(a:plug.dir) || + \ len(s:glob(s:rtp(a:plug), 'plugin')) || + \ len(s:glob(s:rtp(a:plug), 'after/plugin'))) +endfunction + +function! plug#end() + if !exists('g:plugs') + return s:err('Call plug#begin() first') + endif + + if exists('#PlugLOD') + augroup PlugLOD + autocmd! + augroup END + augroup! PlugLOD + endif + let lod = { 'ft': {}, 'map': {}, 'cmd': {} } + + if exists('g:did_load_filetypes') + filetype off + endif + for name in g:plugs_order + if !has_key(g:plugs, name) + continue + endif + let plug = g:plugs[name] + if get(s:loaded, name, 0) || !s:lazy(plug, 'on') && !s:lazy(plug, 'for') + let s:loaded[name] = 1 + continue + endif + + if has_key(plug, 'on') + let s:triggers[name] = { 'map': [], 'cmd': [] } + for cmd in s:to_a(plug.on) + if cmd =~? '^.\+' + if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i')) + call s:assoc(lod.map, cmd, name) + endif + call add(s:triggers[name].map, cmd) + elseif cmd =~# '^[A-Z]' + let cmd = substitute(cmd, '!*$', '', '') + if exists(':'.cmd) != 2 + call s:assoc(lod.cmd, cmd, name) + endif + call add(s:triggers[name].cmd, cmd) + else + call s:err('Invalid `on` option: '.cmd. + \ '. Should start with an uppercase letter or ``.') + endif + endfor + endif + + if has_key(plug, 'for') + let types = s:to_a(plug.for) + if !empty(types) + augroup filetypedetect + call s:source(s:rtp(plug), 'ftdetect/**/*.vim', 'after/ftdetect/**/*.vim') + augroup END + endif + for type in types + call s:assoc(lod.ft, type, name) + endfor + endif + endfor + + for [cmd, names] in items(lod.cmd) + execute printf( + \ 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "", , , , %s)', + \ cmd, string(cmd), string(names)) + endfor + + for [map, names] in items(lod.map) + for [mode, map_prefix, key_prefix] in + \ [['i', '', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']] + execute printf( + \ '%snoremap %s %s:call lod_map(%s, %s, %s, "%s")', + \ mode, map, map_prefix, string(map), string(names), mode != 'i', key_prefix) + endfor + endfor + + for [ft, names] in items(lod.ft) + augroup PlugLOD + execute printf('autocmd FileType %s call lod_ft(%s, %s)', + \ ft, string(ft), string(names)) + augroup END + endfor + + call s:reorg_rtp() + filetype plugin indent on + if has('vim_starting') + if has('syntax') && !exists('g:syntax_on') + syntax enable + end + else + call s:reload_plugins() + endif +endfunction + +function! s:loaded_names() + return filter(copy(g:plugs_order), 'get(s:loaded, v:val, 0)') +endfunction + +function! s:load_plugin(spec) + call s:source(s:rtp(a:spec), 'plugin/**/*.vim', 'after/plugin/**/*.vim') +endfunction + +function! s:reload_plugins() + for name in s:loaded_names() + call s:load_plugin(g:plugs[name]) + endfor +endfunction + +function! s:trim(str) + return substitute(a:str, '[\/]\+$', '', '') +endfunction + +function! s:version_requirement(val, min) + for idx in range(0, len(a:min) - 1) + let v = get(a:val, idx, 0) + if v < a:min[idx] | return 0 + elseif v > a:min[idx] | return 1 + endif + endfor + return 1 +endfunction + +function! s:git_version_requirement(...) + if !exists('s:git_version') + let s:git_version = map(split(split(s:system('git --version'))[2], '\.'), 'str2nr(v:val)') + endif + return s:version_requirement(s:git_version, a:000) +endfunction + +function! s:progress_opt(base) + return a:base && !s:is_win && + \ s:git_version_requirement(1, 7, 1) ? '--progress' : '' +endfunction + +if s:is_win + function! s:rtp(spec) + return s:path(a:spec.dir . get(a:spec, 'rtp', '')) + endfunction + + function! s:path(path) + return s:trim(substitute(a:path, '/', '\', 'g')) + endfunction + + function! s:dirpath(path) + return s:path(a:path) . '\' + endfunction + + function! s:is_local_plug(repo) + return a:repo =~? '^[a-z]:\|^[%~]' + endfunction +else + function! s:rtp(spec) + return s:dirpath(a:spec.dir . get(a:spec, 'rtp', '')) + endfunction + + function! s:path(path) + return s:trim(a:path) + endfunction + + function! s:dirpath(path) + return substitute(a:path, '[/\\]*$', '/', '') + endfunction + + function! s:is_local_plug(repo) + return a:repo[0] =~ '[/$~]' + endfunction +endif + +function! s:err(msg) + echohl ErrorMsg + echom '[vim-plug] '.a:msg + echohl None +endfunction + +function! s:warn(cmd, msg) + echohl WarningMsg + execute a:cmd 'a:msg' + echohl None +endfunction + +function! s:esc(path) + return escape(a:path, ' ') +endfunction + +function! s:escrtp(path) + return escape(a:path, ' ,') +endfunction + +function! s:remove_rtp() + for name in s:loaded_names() + let rtp = s:rtp(g:plugs[name]) + execute 'set rtp-='.s:escrtp(rtp) + let after = globpath(rtp, 'after') + if isdirectory(after) + execute 'set rtp-='.s:escrtp(after) + endif + endfor +endfunction + +function! s:reorg_rtp() + if !empty(s:first_rtp) + execute 'set rtp-='.s:first_rtp + execute 'set rtp-='.s:last_rtp + endif + + " &rtp is modified from outside + if exists('s:prtp') && s:prtp !=# &rtp + call s:remove_rtp() + unlet! s:middle + endif + + let s:middle = get(s:, 'middle', &rtp) + let rtps = map(s:loaded_names(), 's:rtp(g:plugs[v:val])') + let afters = filter(map(copy(rtps), 'globpath(v:val, "after")'), '!empty(v:val)') + let rtp = join(map(rtps, 'escape(v:val, ",")'), ',') + \ . ','.s:middle.',' + \ . join(map(afters, 'escape(v:val, ",")'), ',') + let &rtp = substitute(substitute(rtp, ',,*', ',', 'g'), '^,\|,$', '', 'g') + let s:prtp = &rtp + + if !empty(s:first_rtp) + execute 'set rtp^='.s:first_rtp + execute 'set rtp+='.s:last_rtp + endif +endfunction + +function! s:doautocmd(...) + if exists('#'.join(a:000, '#')) + execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '' : '') join(a:000) + endif +endfunction + +function! s:dobufread(names) + for name in a:names + let path = s:rtp(g:plugs[name]).'/**' + for dir in ['ftdetect', 'ftplugin'] + if len(finddir(dir, path)) + if exists('#BufRead') + doautocmd BufRead + endif + return + endif + endfor + endfor +endfunction + +function! plug#load(...) + if a:0 == 0 + return s:err('Argument missing: plugin name(s) required') + endif + if !exists('g:plugs') + return s:err('plug#begin was not called') + endif + let names = a:0 == 1 && type(a:1) == s:TYPE.list ? a:1 : a:000 + let unknowns = filter(copy(names), '!has_key(g:plugs, v:val)') + if !empty(unknowns) + let s = len(unknowns) > 1 ? 's' : '' + return s:err(printf('Unknown plugin%s: %s', s, join(unknowns, ', '))) + end + let unloaded = filter(copy(names), '!get(s:loaded, v:val, 0)') + if !empty(unloaded) + for name in unloaded + call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + endfor + call s:dobufread(unloaded) + return 1 + end + return 0 +endfunction + +function! s:remove_triggers(name) + if !has_key(s:triggers, a:name) + return + endif + for cmd in s:triggers[a:name].cmd + execute 'silent! delc' cmd + endfor + for map in s:triggers[a:name].map + execute 'silent! unmap' map + execute 'silent! iunmap' map + endfor + call remove(s:triggers, a:name) +endfunction + +function! s:lod(names, types, ...) + for name in a:names + call s:remove_triggers(name) + let s:loaded[name] = 1 + endfor + call s:reorg_rtp() + + for name in a:names + let rtp = s:rtp(g:plugs[name]) + for dir in a:types + call s:source(rtp, dir.'/**/*.vim') + endfor + if a:0 + if !s:source(rtp, a:1) && !empty(s:glob(rtp, a:2)) + execute 'runtime' a:1 + endif + call s:source(rtp, a:2) + endif + call s:doautocmd('User', name) + endfor +endfunction + +function! s:lod_ft(pat, names) + let syn = 'syntax/'.a:pat.'.vim' + call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn) + execute 'autocmd! PlugLOD FileType' a:pat + call s:doautocmd('filetypeplugin', 'FileType') + call s:doautocmd('filetypeindent', 'FileType') +endfunction + +function! s:lod_cmd(cmd, bang, l1, l2, args, names) + call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + call s:dobufread(a:names) + execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args) +endfunction + +function! s:lod_map(map, names, with_prefix, prefix) + call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + call s:dobufread(a:names) + let extra = '' + while 1 + let c = getchar(0) + if c == 0 + break + endif + let extra .= nr2char(c) + endwhile + + if a:with_prefix + let prefix = v:count ? v:count : '' + let prefix .= '"'.v:register.a:prefix + if mode(1) == 'no' + if v:operator == 'c' + let prefix = "\" . prefix + endif + let prefix .= v:operator + endif + call feedkeys(prefix, 'n') + endif + call feedkeys(substitute(a:map, '^', "\", '') . extra) +endfunction + +function! plug#(repo, ...) + if a:0 > 1 + return s:err('Invalid number of arguments (1..2)') + endif + + try + let repo = s:trim(a:repo) + let opts = a:0 == 1 ? s:parse_options(a:1) : s:base_spec + let name = get(opts, 'as', fnamemodify(repo, ':t:s?\.git$??')) + let spec = extend(s:infer_properties(name, repo), opts) + if !has_key(g:plugs, name) + call add(g:plugs_order, name) + endif + let g:plugs[name] = spec + let s:loaded[name] = get(s:loaded, name, 0) + catch + return s:err(v:exception) + endtry +endfunction + +function! s:parse_options(arg) + let opts = copy(s:base_spec) + let type = type(a:arg) + if type == s:TYPE.string + let opts.tag = a:arg + elseif type == s:TYPE.dict + call extend(opts, a:arg) + if has_key(opts, 'dir') + let opts.dir = s:dirpath(expand(opts.dir)) + endif + else + throw 'Invalid argument type (expected: string or dictionary)' + endif + return opts +endfunction + +function! s:infer_properties(name, repo) + let repo = a:repo + if s:is_local_plug(repo) + return { 'dir': s:dirpath(expand(repo)) } + else + if repo =~ ':' + let uri = repo + else + if repo !~ '/' + throw printf('Invalid argument: %s (implicit `vim-scripts'' expansion is deprecated)', repo) + endif + let fmt = get(g:, 'plug_url_format', 'https://git::@github.com/%s.git') + let uri = printf(fmt, repo) + endif + return { 'dir': s:dirpath(g:plug_home.'/'.a:name), 'uri': uri } + endif +endfunction + +function! s:install(force, names) + call s:update_impl(0, a:force, a:names) +endfunction + +function! s:update(force, names) + call s:update_impl(1, a:force, a:names) +endfunction + +function! plug#helptags() + if !exists('g:plugs') + return s:err('plug#begin was not called') + endif + for spec in values(g:plugs) + let docd = join([s:rtp(spec), 'doc'], '/') + if isdirectory(docd) + silent! execute 'helptags' s:esc(docd) + endif + endfor + return 1 +endfunction + +function! s:syntax() + syntax clear + syntax region plug1 start=/\%1l/ end=/\%2l/ contains=plugNumber + syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX + syn match plugNumber /[0-9]\+[0-9.]*/ contained + syn match plugBracket /[[\]]/ contained + syn match plugX /x/ contained + syn match plugDash /^-/ + syn match plugPlus /^+/ + syn match plugStar /^*/ + syn match plugMessage /\(^- \)\@<=.*/ + syn match plugName /\(^- \)\@<=[^ ]*:/ + syn match plugSha /\%(: \)\@<=[0-9a-f]\{4,}$/ + syn match plugTag /(tag: [^)]\+)/ + syn match plugInstall /\(^+ \)\@<=[^:]*/ + syn match plugUpdate /\(^* \)\@<=[^:]*/ + syn match plugCommit /^ \X*[0-9a-f]\{7,9} .*/ contains=plugRelDate,plugEdge,plugTag + syn match plugEdge /^ \X\+$/ + syn match plugEdge /^ \X*/ contained nextgroup=plugSha + syn match plugSha /[0-9a-f]\{7,9}/ contained + syn match plugRelDate /([^)]*)$/ contained + syn match plugNotLoaded /(not loaded)$/ + syn match plugError /^x.*/ + syn region plugDeleted start=/^\~ .*/ end=/^\ze\S/ + syn match plugH2 /^.*:\n-\+$/ + syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean + hi def link plug1 Title + hi def link plug2 Repeat + hi def link plugH2 Type + hi def link plugX Exception + hi def link plugBracket Structure + hi def link plugNumber Number + + hi def link plugDash Special + hi def link plugPlus Constant + hi def link plugStar Boolean + + hi def link plugMessage Function + hi def link plugName Label + hi def link plugInstall Function + hi def link plugUpdate Type + + hi def link plugError Error + hi def link plugDeleted Ignore + hi def link plugRelDate Comment + hi def link plugEdge PreProc + hi def link plugSha Identifier + hi def link plugTag Constant + + hi def link plugNotLoaded Comment +endfunction + +function! s:lpad(str, len) + return a:str . repeat(' ', a:len - len(a:str)) +endfunction + +function! s:lines(msg) + return split(a:msg, "[\r\n]") +endfunction + +function! s:lastline(msg) + return get(s:lines(a:msg), -1, '') +endfunction + +function! s:new_window() + execute get(g:, 'plug_window', 'vertical topleft new') +endfunction + +function! s:plug_window_exists() + let buflist = tabpagebuflist(s:plug_tab) + return !empty(buflist) && index(buflist, s:plug_buf) >= 0 +endfunction + +function! s:switch_in() + if !s:plug_window_exists() + return 0 + endif + + if winbufnr(0) != s:plug_buf + let s:pos = [tabpagenr(), winnr(), winsaveview()] + execute 'normal!' s:plug_tab.'gt' + let winnr = bufwinnr(s:plug_buf) + execute winnr.'wincmd w' + call add(s:pos, winsaveview()) + else + let s:pos = [winsaveview()] + endif + + setlocal modifiable + return 1 +endfunction + +function! s:switch_out(...) + call winrestview(s:pos[-1]) + setlocal nomodifiable + if a:0 > 0 + execute a:1 + endif + + if len(s:pos) > 1 + execute 'normal!' s:pos[0].'gt' + execute s:pos[1] 'wincmd w' + call winrestview(s:pos[2]) + endif +endfunction + +function! s:finish_bindings() + nnoremap R :call retry() + nnoremap D :PlugDiff + nnoremap S :PlugStatus + nnoremap U :call status_update() + xnoremap U :call status_update() + nnoremap ]] :silent! call section('') + nnoremap [[ :silent! call section('b') +endfunction + +function! s:prepare(...) + if empty(getcwd()) + throw 'Invalid current working directory. Cannot proceed.' + endif + + for evar in ['$GIT_DIR', '$GIT_WORK_TREE'] + if exists(evar) + throw evar.' detected. Cannot proceed.' + endif + endfor + + call s:job_abort() + if s:switch_in() + if b:plug_preview == 1 + pc + endif + enew + else + call s:new_window() + endif + + nnoremap q :if b:plug_preview==1pcendifbd + if a:0 == 0 + call s:finish_bindings() + endif + let b:plug_preview = -1 + let s:plug_tab = tabpagenr() + let s:plug_buf = winbufnr(0) + call s:assign_name() + + for k in ['', 'L', 'o', 'X', 'd', 'dd'] + execute 'silent! unmap ' k + endfor + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline modifiable nospell + if exists('+colorcolumn') + setlocal colorcolumn= + endif + setf vim-plug + if exists('g:syntax_on') + call s:syntax() + endif +endfunction + +function! s:assign_name() + " Assign buffer name + let prefix = '[Plugins]' + let name = prefix + let idx = 2 + while bufexists(name) + let name = printf('%s (%s)', prefix, idx) + let idx = idx + 1 + endwhile + silent! execute 'f' fnameescape(name) +endfunction + +function! s:chsh(swap) + let prev = [&shell, &shellcmdflag, &shellredir] + if s:is_win + set shell=cmd.exe shellcmdflag=/c shellredir=>%s\ 2>&1 + elseif a:swap + set shell=sh shellredir=>%s\ 2>&1 + endif + return prev +endfunction + +function! s:bang(cmd, ...) + try + let [sh, shellcmdflag, shrd] = s:chsh(a:0) + " FIXME: Escaping is incomplete. We could use shellescape with eval, + " but it won't work on Windows. + let cmd = a:0 ? s:with_cd(a:cmd, a:1) : a:cmd + if s:is_win + let batchfile = tempname().'.bat' + call writefile(["@echo off\r", cmd . "\r"], batchfile) + let cmd = batchfile + endif + let g:_plug_bang = (s:is_win && has('gui_running') ? 'silent ' : '').'!'.escape(cmd, '#!%') + execute "normal! :execute g:_plug_bang\\" + finally + unlet g:_plug_bang + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win + call delete(batchfile) + endif + endtry + return v:shell_error ? 'Exit status: ' . v:shell_error : '' +endfunction + +function! s:regress_bar() + let bar = substitute(getline(2)[1:-2], '.*\zs=', 'x', '') + call s:progress_bar(2, bar, len(bar)) +endfunction + +function! s:is_updated(dir) + return !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"', a:dir)) +endfunction + +function! s:do(pull, force, todo) + for [name, spec] in items(a:todo) + if !isdirectory(spec.dir) + continue + endif + let installed = has_key(s:update.new, name) + let updated = installed ? 0 : + \ (a:pull && index(s:update.errors, name) < 0 && s:is_updated(spec.dir)) + if a:force || installed || updated + execute 'cd' s:esc(spec.dir) + call append(3, '- Post-update hook for '. name .' ... ') + let error = '' + let type = type(spec.do) + if type == s:TYPE.string + if spec.do[0] == ':' + if !get(s:loaded, name, 0) + let s:loaded[name] = 1 + call s:reorg_rtp() + endif + call s:load_plugin(spec) + try + execute spec.do[1:] + catch + let error = v:exception + endtry + if !s:plug_window_exists() + cd - + throw 'Warning: vim-plug was terminated by the post-update hook of '.name + endif + else + let error = s:bang(spec.do) + endif + elseif type == s:TYPE.funcref + try + let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged') + call spec.do({ 'name': name, 'status': status, 'force': a:force }) + catch + let error = v:exception + endtry + else + let error = 'Invalid hook type' + endif + call s:switch_in() + call setline(4, empty(error) ? (getline(4) . 'OK') + \ : ('x' . getline(4)[1:] . error)) + if !empty(error) + call add(s:update.errors, name) + call s:regress_bar() + endif + cd - + endif + endfor +endfunction + +function! s:hash_match(a, b) + return stridx(a:a, a:b) == 0 || stridx(a:b, a:a) == 0 +endfunction + +function! s:checkout(spec) + let sha = a:spec.commit + let output = s:system('git rev-parse HEAD', a:spec.dir) + if !v:shell_error && !s:hash_match(sha, s:lines(output)[0]) + let output = s:system( + \ 'git fetch --depth 999999 && git checkout '.s:esc(sha).' --', a:spec.dir) + endif + return output +endfunction + +function! s:finish(pull) + let new_frozen = len(filter(keys(s:update.new), 'g:plugs[v:val].frozen')) + if new_frozen + let s = new_frozen > 1 ? 's' : '' + call append(3, printf('- Installed %d frozen plugin%s', new_frozen, s)) + endif + call append(3, '- Finishing ... ') | 4 + redraw + call plug#helptags() + call plug#end() + call setline(4, getline(4) . 'Done!') + redraw + let msgs = [] + if !empty(s:update.errors) + call add(msgs, "Press 'R' to retry.") + endif + if a:pull && len(s:update.new) < len(filter(getline(5, '$'), + \ "v:val =~ '^- ' && v:val !~# 'Already up.to.date'")) + call add(msgs, "Press 'D' to see the updated changes.") + endif + echo join(msgs, ' ') + call s:finish_bindings() +endfunction + +function! s:retry() + if empty(s:update.errors) + return + endif + echo + call s:update_impl(s:update.pull, s:update.force, + \ extend(copy(s:update.errors), [s:update.threads])) +endfunction + +function! s:is_managed(name) + return has_key(g:plugs[a:name], 'uri') +endfunction + +function! s:names(...) + return sort(filter(keys(g:plugs), 'stridx(v:val, a:1) == 0 && s:is_managed(v:val)')) +endfunction + +function! s:check_ruby() + silent! ruby require 'thread'; VIM::command("let g:plug_ruby = '#{RUBY_VERSION}'") + if !exists('g:plug_ruby') + redraw! + return s:warn('echom', 'Warning: Ruby interface is broken') + endif + let ruby_version = split(g:plug_ruby, '\.') + unlet g:plug_ruby + return s:version_requirement(ruby_version, [1, 8, 7]) +endfunction + +function! s:update_impl(pull, force, args) abort + let sync = index(a:args, '--sync') >= 0 || has('vim_starting') + let args = filter(copy(a:args), 'v:val != "--sync"') + let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ? + \ remove(args, -1) : get(g:, 'plug_threads', 16) + + let managed = filter(copy(g:plugs), 's:is_managed(v:key)') + let todo = empty(args) ? filter(managed, '!v:val.frozen || !isdirectory(v:val.dir)') : + \ filter(managed, 'index(args, v:key) >= 0') + + if empty(todo) + return s:warn('echo', 'No plugin to '. (a:pull ? 'update' : 'install')) + endif + + if !s:is_win && s:git_version_requirement(2, 3) + let s:git_terminal_prompt = exists('$GIT_TERMINAL_PROMPT') ? $GIT_TERMINAL_PROMPT : '' + let $GIT_TERMINAL_PROMPT = 0 + for plug in values(todo) + let plug.uri = substitute(plug.uri, + \ '^https://git::@github\.com', 'https://github.com', '') + endfor + endif + + if !isdirectory(g:plug_home) + try + call mkdir(g:plug_home, 'p') + catch + return s:err(printf('Invalid plug directory: %s. '. + \ 'Try to call plug#begin with a valid directory', g:plug_home)) + endtry + endif + + if has('nvim') && !exists('*jobwait') && threads > 1 + call s:warn('echom', '[vim-plug] Update Neovim for parallel installer') + endif + + let use_job = s:nvim || s:vim8 + let python = (has('python') || has('python3')) && !use_job + let ruby = has('ruby') && !use_job && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running')) && threads > 1 && s:check_ruby() + + let s:update = { + \ 'start': reltime(), + \ 'all': todo, + \ 'todo': copy(todo), + \ 'errors': [], + \ 'pull': a:pull, + \ 'force': a:force, + \ 'new': {}, + \ 'threads': (python || ruby || use_job) ? min([len(todo), threads]) : 1, + \ 'bar': '', + \ 'fin': 0 + \ } + + call s:prepare(1) + call append(0, ['', '']) + normal! 2G + silent! redraw + + let s:clone_opt = get(g:, 'plug_shallow', 1) ? + \ '--depth 1' . (s:git_version_requirement(1, 7, 10) ? ' --no-single-branch' : '') : '' + + if has('win32unix') + let s:clone_opt .= ' -c core.eol=lf -c core.autocrlf=input' + endif + + let s:submodule_opt = s:git_version_requirement(2, 8) ? ' --jobs='.threads : '' + + " Python version requirement (>= 2.7) + if python && !has('python3') && !ruby && !use_job && s:update.threads > 1 + redir => pyv + silent python import platform; print platform.python_version() + redir END + let python = s:version_requirement( + \ map(split(split(pyv)[0], '\.'), 'str2nr(v:val)'), [2, 6]) + endif + + if (python || ruby) && s:update.threads > 1 + try + let imd = &imd + if s:mac_gui + set noimd + endif + if ruby + call s:update_ruby() + else + call s:update_python() + endif + catch + let lines = getline(4, '$') + let printed = {} + silent! 4,$d _ + for line in lines + let name = s:extract_name(line, '.', '') + if empty(name) || !has_key(printed, name) + call append('$', line) + if !empty(name) + let printed[name] = 1 + if line[0] == 'x' && index(s:update.errors, name) < 0 + call add(s:update.errors, name) + end + endif + endif + endfor + finally + let &imd = imd + call s:update_finish() + endtry + else + call s:update_vim() + while use_job && sync + sleep 100m + if s:update.fin + break + endif + endwhile + endif +endfunction + +function! s:log4(name, msg) + call setline(4, printf('- %s (%s)', a:msg, a:name)) + redraw +endfunction + +function! s:update_finish() + if exists('s:git_terminal_prompt') + let $GIT_TERMINAL_PROMPT = s:git_terminal_prompt + endif + if s:switch_in() + call append(3, '- Updating ...') | 4 + for [name, spec] in items(filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && (s:update.force || s:update.pull || has_key(s:update.new, v:key))')) + let [pos, _] = s:logpos(name) + if !pos + continue + endif + if has_key(spec, 'commit') + call s:log4(name, 'Checking out '.spec.commit) + let out = s:checkout(spec) + elseif has_key(spec, 'tag') + let tag = spec.tag + if tag =~ '\*' + let tags = s:lines(s:system('git tag --list '.s:shellesc(tag).' --sort -version:refname 2>&1', spec.dir)) + if !v:shell_error && !empty(tags) + let tag = tags[0] + call s:log4(name, printf('Latest tag for %s -> %s', spec.tag, tag)) + call append(3, '') + endif + endif + call s:log4(name, 'Checking out '.tag) + let out = s:system('git checkout -q '.s:esc(tag).' -- 2>&1', spec.dir) + else + let branch = s:esc(get(spec, 'branch', 'master')) + call s:log4(name, 'Merging origin/'.branch) + let out = s:system('git checkout -q '.branch.' -- 2>&1' + \. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only origin/'.branch.' 2>&1')), spec.dir) + endif + if !v:shell_error && filereadable(spec.dir.'/.gitmodules') && + \ (s:update.force || has_key(s:update.new, name) || s:is_updated(spec.dir)) + call s:log4(name, 'Updating submodules. This may take a while.') + let out .= s:bang('git submodule update --init --recursive'.s:submodule_opt.' 2>&1', spec.dir) + endif + let msg = s:format_message(v:shell_error ? 'x': '-', name, out) + if v:shell_error + call add(s:update.errors, name) + call s:regress_bar() + silent execute pos 'd _' + call append(4, msg) | 4 + elseif !empty(out) + call setline(pos, msg[0]) + endif + redraw + endfor + silent 4 d _ + try + call s:do(s:update.pull, s:update.force, filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && has_key(v:val, "do")')) + catch + call s:warn('echom', v:exception) + call s:warn('echo', '') + return + endtry + call s:finish(s:update.pull) + call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(s:update.start)))[0] . ' sec.') + call s:switch_out('normal! gg') + endif +endfunction + +function! s:job_abort() + if (!s:nvim && !s:vim8) || !exists('s:jobs') + return + endif + + for [name, j] in items(s:jobs) + if s:nvim + silent! call jobstop(j.jobid) + elseif s:vim8 + silent! call job_stop(j.jobid) + endif + if j.new + call s:system('rm -rf ' . s:shellesc(g:plugs[name].dir)) + endif + endfor + let s:jobs = {} +endfunction + +function! s:last_non_empty_line(lines) + let len = len(a:lines) + for idx in range(len) + let line = a:lines[len-idx-1] + if !empty(line) + return line + endif + endfor + return '' +endfunction + +function! s:job_out_cb(self, data) abort + let self = a:self + let data = remove(self.lines, -1) . a:data + let lines = map(split(data, "\n", 1), 'split(v:val, "\r", 1)[-1]') + call extend(self.lines, lines) + " To reduce the number of buffer updates + let self.tick = get(self, 'tick', -1) + 1 + if !self.running || self.tick % len(s:jobs) == 0 + let bullet = self.running ? (self.new ? '+' : '*') : (self.error ? 'x' : '-') + let result = self.error ? join(self.lines, "\n") : s:last_non_empty_line(self.lines) + call s:log(bullet, self.name, result) + endif +endfunction + +function! s:job_exit_cb(self, data) abort + let a:self.running = 0 + let a:self.error = a:data != 0 + call s:reap(a:self.name) + call s:tick() +endfunction + +function! s:job_cb(fn, job, ch, data) + if !s:plug_window_exists() " plug window closed + return s:job_abort() + endif + call call(a:fn, [a:job, a:data]) +endfunction + +function! s:nvim_cb(job_id, data, event) dict abort + return a:event == 'stdout' ? + \ s:job_cb('s:job_out_cb', self, 0, join(a:data, "\n")) : + \ s:job_cb('s:job_exit_cb', self, 0, a:data) +endfunction + +function! s:spawn(name, cmd, opts) + let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [''], + \ 'batchfile': (s:is_win && (s:nvim || s:vim8)) ? tempname().'.bat' : '', + \ 'new': get(a:opts, 'new', 0) } + let s:jobs[a:name] = job + let cmd = has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd + if !empty(job.batchfile) + call writefile(["@echo off\r", cmd . "\r"], job.batchfile) + let cmd = job.batchfile + endif + let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], cmd) + + if s:nvim + call extend(job, { + \ 'on_stdout': function('s:nvim_cb'), + \ 'on_exit': function('s:nvim_cb'), + \ }) + let jid = jobstart(argv, job) + if jid > 0 + let job.jobid = jid + else + let job.running = 0 + let job.error = 1 + let job.lines = [jid < 0 ? argv[0].' is not executable' : + \ 'Invalid arguments (or job table is full)'] + endif + elseif s:vim8 + let jid = job_start(s:is_win ? join(argv, ' ') : argv, { + \ 'out_cb': function('s:job_cb', ['s:job_out_cb', job]), + \ 'exit_cb': function('s:job_cb', ['s:job_exit_cb', job]), + \ 'out_mode': 'raw' + \}) + if job_status(jid) == 'run' + let job.jobid = jid + else + let job.running = 0 + let job.error = 1 + let job.lines = ['Failed to start job'] + endif + else + let job.lines = s:lines(call('s:system', [cmd])) + let job.error = v:shell_error != 0 + let job.running = 0 + endif +endfunction + +function! s:reap(name) + let job = s:jobs[a:name] + if job.error + call add(s:update.errors, a:name) + elseif get(job, 'new', 0) + let s:update.new[a:name] = 1 + endif + let s:update.bar .= job.error ? 'x' : '=' + + let bullet = job.error ? 'x' : '-' + let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines) + call s:log(bullet, a:name, empty(result) ? 'OK' : result) + call s:bar() + + if has_key(job, 'batchfile') && !empty(job.batchfile) + call delete(job.batchfile) + endif + call remove(s:jobs, a:name) +endfunction + +function! s:bar() + if s:switch_in() + let total = len(s:update.all) + call setline(1, (s:update.pull ? 'Updating' : 'Installing'). + \ ' plugins ('.len(s:update.bar).'/'.total.')') + call s:progress_bar(2, s:update.bar, total) + call s:switch_out() + endif +endfunction + +function! s:logpos(name) + for i in range(4, line('$')) + if getline(i) =~# '^[-+x*] '.a:name.':' + for j in range(i + 1, line('$')) + if getline(j) !~ '^ ' + return [i, j - 1] + endif + endfor + return [i, i] + endif + endfor + return [0, 0] +endfunction + +function! s:log(bullet, name, lines) + if s:switch_in() + let [b, e] = s:logpos(a:name) + if b > 0 + silent execute printf('%d,%d d _', b, e) + if b > winheight('.') + let b = 4 + endif + else + let b = 4 + endif + " FIXME For some reason, nomodifiable is set after :d in vim8 + setlocal modifiable + call append(b - 1, s:format_message(a:bullet, a:name, a:lines)) + call s:switch_out() + endif +endfunction + +function! s:update_vim() + let s:jobs = {} + + call s:bar() + call s:tick() +endfunction + +function! s:tick() + let pull = s:update.pull + let prog = s:progress_opt(s:nvim || s:vim8) +while 1 " Without TCO, Vim stack is bound to explode + if empty(s:update.todo) + if empty(s:jobs) && !s:update.fin + call s:update_finish() + let s:update.fin = 1 + endif + return + endif + + let name = keys(s:update.todo)[0] + let spec = remove(s:update.todo, name) + let new = empty(globpath(spec.dir, '.git', 1)) + + call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...') + redraw + + let has_tag = has_key(spec, 'tag') + if !new + let [error, _] = s:git_validate(spec, 0) + if empty(error) + if pull + let fetch_opt = (has_tag && !empty(globpath(spec.dir, '.git/shallow'))) ? '--depth 99999999' : '' + call s:spawn(name, printf('git fetch %s %s 2>&1', fetch_opt, prog), { 'dir': spec.dir }) + else + let s:jobs[name] = { 'running': 0, 'lines': ['Already installed'], 'error': 0 } + endif + else + let s:jobs[name] = { 'running': 0, 'lines': s:lines(error), 'error': 1 } + endif + else + call s:spawn(name, + \ printf('git clone %s %s %s %s 2>&1', + \ has_tag ? '' : s:clone_opt, + \ prog, + \ s:shellesc(spec.uri), + \ s:shellesc(s:trim(spec.dir))), { 'new': 1 }) + endif + + if !s:jobs[name].running + call s:reap(name) + endif + if len(s:jobs) >= s:update.threads + break + endif +endwhile +endfunction + +function! s:update_python() +let py_exe = has('python') ? 'python' : 'python3' +execute py_exe "<< EOF" +import datetime +import functools +import os +try: + import queue +except ImportError: + import Queue as queue +import random +import re +import shutil +import signal +import subprocess +import tempfile +import threading as thr +import time +import traceback +import vim + +G_NVIM = vim.eval("has('nvim')") == '1' +G_PULL = vim.eval('s:update.pull') == '1' +G_RETRIES = int(vim.eval('get(g:, "plug_retries", 2)')) + 1 +G_TIMEOUT = int(vim.eval('get(g:, "plug_timeout", 60)')) +G_CLONE_OPT = vim.eval('s:clone_opt') +G_PROGRESS = vim.eval('s:progress_opt(1)') +G_LOG_PROB = 1.0 / int(vim.eval('s:update.threads')) +G_STOP = thr.Event() +G_IS_WIN = vim.eval('s:is_win') == '1' + +class PlugError(Exception): + def __init__(self, msg): + self.msg = msg +class CmdTimedOut(PlugError): + pass +class CmdFailed(PlugError): + pass +class InvalidURI(PlugError): + pass +class Action(object): + INSTALL, UPDATE, ERROR, DONE = ['+', '*', 'x', '-'] + +class Buffer(object): + def __init__(self, lock, num_plugs, is_pull): + self.bar = '' + self.event = 'Updating' if is_pull else 'Installing' + self.lock = lock + self.maxy = int(vim.eval('winheight(".")')) + self.num_plugs = num_plugs + + def __where(self, name): + """ Find first line with name in current buffer. Return line num. """ + found, lnum = False, 0 + matcher = re.compile('^[-+x*] {0}:'.format(name)) + for line in vim.current.buffer: + if matcher.search(line) is not None: + found = True + break + lnum += 1 + + if not found: + lnum = -1 + return lnum + + def header(self): + curbuf = vim.current.buffer + curbuf[0] = self.event + ' plugins ({0}/{1})'.format(len(self.bar), self.num_plugs) + + num_spaces = self.num_plugs - len(self.bar) + curbuf[1] = '[{0}{1}]'.format(self.bar, num_spaces * ' ') + + with self.lock: + vim.command('normal! 2G') + vim.command('redraw') + + def write(self, action, name, lines): + first, rest = lines[0], lines[1:] + msg = ['{0} {1}{2}{3}'.format(action, name, ': ' if first else '', first)] + msg.extend([' ' + line for line in rest]) + + try: + if action == Action.ERROR: + self.bar += 'x' + vim.command("call add(s:update.errors, '{0}')".format(name)) + elif action == Action.DONE: + self.bar += '=' + + curbuf = vim.current.buffer + lnum = self.__where(name) + if lnum != -1: # Found matching line num + del curbuf[lnum] + if lnum > self.maxy and action in set([Action.INSTALL, Action.UPDATE]): + lnum = 3 + else: + lnum = 3 + curbuf.append(msg, lnum) + + self.header() + except vim.error: + pass + +class Command(object): + CD = 'cd /d' if G_IS_WIN else 'cd' + + def __init__(self, cmd, cmd_dir=None, timeout=60, cb=None, clean=None): + self.cmd = cmd + if cmd_dir: + self.cmd = '{0} {1} && {2}'.format(Command.CD, cmd_dir, self.cmd) + self.timeout = timeout + self.callback = cb if cb else (lambda msg: None) + self.clean = clean if clean else (lambda: None) + self.proc = None + + @property + def alive(self): + """ Returns true only if command still running. """ + return self.proc and self.proc.poll() is None + + def execute(self, ntries=3): + """ Execute the command with ntries if CmdTimedOut. + Returns the output of the command if no Exception. + """ + attempt, finished, limit = 0, False, self.timeout + + while not finished: + try: + attempt += 1 + result = self.try_command() + finished = True + return result + except CmdTimedOut: + if attempt != ntries: + self.notify_retry() + self.timeout += limit + else: + raise + + def notify_retry(self): + """ Retry required for command, notify user. """ + for count in range(3, 0, -1): + if G_STOP.is_set(): + raise KeyboardInterrupt + msg = 'Timeout. Will retry in {0} second{1} ...'.format( + count, 's' if count != 1 else '') + self.callback([msg]) + time.sleep(1) + self.callback(['Retrying ...']) + + def try_command(self): + """ Execute a cmd & poll for callback. Returns list of output. + Raises CmdFailed -> return code for Popen isn't 0 + Raises CmdTimedOut -> command exceeded timeout without new output + """ + first_line = True + + try: + tfile = tempfile.NamedTemporaryFile(mode='w+b') + preexec_fn = not G_IS_WIN and os.setsid or None + self.proc = subprocess.Popen(self.cmd, stdout=tfile, + stderr=subprocess.STDOUT, + stdin=subprocess.PIPE, shell=True, + preexec_fn=preexec_fn) + thrd = thr.Thread(target=(lambda proc: proc.wait()), args=(self.proc,)) + thrd.start() + + thread_not_started = True + while thread_not_started: + try: + thrd.join(0.1) + thread_not_started = False + except RuntimeError: + pass + + while self.alive: + if G_STOP.is_set(): + raise KeyboardInterrupt + + if first_line or random.random() < G_LOG_PROB: + first_line = False + line = '' if G_IS_WIN else nonblock_read(tfile.name) + if line: + self.callback([line]) + + time_diff = time.time() - os.path.getmtime(tfile.name) + if time_diff > self.timeout: + raise CmdTimedOut(['Timeout!']) + + thrd.join(0.5) + + tfile.seek(0) + result = [line.decode('utf-8', 'replace').rstrip() for line in tfile] + + if self.proc.returncode != 0: + raise CmdFailed([''] + result) + + return result + except: + self.terminate() + raise + + def terminate(self): + """ Terminate process and cleanup. """ + if self.alive: + if G_IS_WIN: + os.kill(self.proc.pid, signal.SIGINT) + else: + os.killpg(self.proc.pid, signal.SIGTERM) + self.clean() + +class Plugin(object): + def __init__(self, name, args, buf_q, lock): + self.name = name + self.args = args + self.buf_q = buf_q + self.lock = lock + self.tag = args.get('tag', 0) + + def manage(self): + try: + if os.path.exists(self.args['dir']): + self.update() + else: + self.install() + with self.lock: + thread_vim_command("let s:update.new['{0}'] = 1".format(self.name)) + except PlugError as exc: + self.write(Action.ERROR, self.name, exc.msg) + except KeyboardInterrupt: + G_STOP.set() + self.write(Action.ERROR, self.name, ['Interrupted!']) + except: + # Any exception except those above print stack trace + msg = 'Trace:\n{0}'.format(traceback.format_exc().rstrip()) + self.write(Action.ERROR, self.name, msg.split('\n')) + raise + + def install(self): + target = self.args['dir'] + if target[-1] == '\\': + target = target[0:-1] + + def clean(target): + def _clean(): + try: + shutil.rmtree(target) + except OSError: + pass + return _clean + + self.write(Action.INSTALL, self.name, ['Installing ...']) + callback = functools.partial(self.write, Action.INSTALL, self.name) + cmd = 'git clone {0} {1} {2} {3} 2>&1'.format( + '' if self.tag else G_CLONE_OPT, G_PROGRESS, self.args['uri'], + esc(target)) + com = Command(cmd, None, G_TIMEOUT, callback, clean(target)) + result = com.execute(G_RETRIES) + self.write(Action.DONE, self.name, result[-1:]) + + def repo_uri(self): + cmd = 'git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url' + command = Command(cmd, self.args['dir'], G_TIMEOUT,) + result = command.execute(G_RETRIES) + return result[-1] + + def update(self): + actual_uri = self.repo_uri() + expect_uri = self.args['uri'] + regex = re.compile(r'^(?:\w+://)?(?:[^@/]*@)?([^:/]*(?::[0-9]*)?)[:/](.*?)(?:\.git)?/?$') + ma = regex.match(actual_uri) + mb = regex.match(expect_uri) + if ma is None or mb is None or ma.groups() != mb.groups(): + msg = ['', + 'Invalid URI: {0}'.format(actual_uri), + 'Expected {0}'.format(expect_uri), + 'PlugClean required.'] + raise InvalidURI(msg) + + if G_PULL: + self.write(Action.UPDATE, self.name, ['Updating ...']) + callback = functools.partial(self.write, Action.UPDATE, self.name) + fetch_opt = '--depth 99999999' if self.tag and os.path.isfile(os.path.join(self.args['dir'], '.git/shallow')) else '' + cmd = 'git fetch {0} {1} 2>&1'.format(fetch_opt, G_PROGRESS) + com = Command(cmd, self.args['dir'], G_TIMEOUT, callback) + result = com.execute(G_RETRIES) + self.write(Action.DONE, self.name, result[-1:]) + else: + self.write(Action.DONE, self.name, ['Already installed']) + + def write(self, action, name, msg): + self.buf_q.put((action, name, msg)) + +class PlugThread(thr.Thread): + def __init__(self, tname, args): + super(PlugThread, self).__init__() + self.tname = tname + self.args = args + + def run(self): + thr.current_thread().name = self.tname + buf_q, work_q, lock = self.args + + try: + while not G_STOP.is_set(): + name, args = work_q.get_nowait() + plug = Plugin(name, args, buf_q, lock) + plug.manage() + work_q.task_done() + except queue.Empty: + pass + +class RefreshThread(thr.Thread): + def __init__(self, lock): + super(RefreshThread, self).__init__() + self.lock = lock + self.running = True + + def run(self): + while self.running: + with self.lock: + thread_vim_command('noautocmd normal! a') + time.sleep(0.33) + + def stop(self): + self.running = False + +if G_NVIM: + def thread_vim_command(cmd): + vim.session.threadsafe_call(lambda: vim.command(cmd)) +else: + def thread_vim_command(cmd): + vim.command(cmd) + +def esc(name): + return '"' + name.replace('"', '\"') + '"' + +def nonblock_read(fname): + """ Read a file with nonblock flag. Return the last line. """ + fread = os.open(fname, os.O_RDONLY | os.O_NONBLOCK) + buf = os.read(fread, 100000).decode('utf-8', 'replace') + os.close(fread) + + line = buf.rstrip('\r\n') + left = max(line.rfind('\r'), line.rfind('\n')) + if left != -1: + left += 1 + line = line[left:] + + return line + +def main(): + thr.current_thread().name = 'main' + nthreads = int(vim.eval('s:update.threads')) + plugs = vim.eval('s:update.todo') + mac_gui = vim.eval('s:mac_gui') == '1' + + lock = thr.Lock() + buf = Buffer(lock, len(plugs), G_PULL) + buf_q, work_q = queue.Queue(), queue.Queue() + for work in plugs.items(): + work_q.put(work) + + start_cnt = thr.active_count() + for num in range(nthreads): + tname = 'PlugT-{0:02}'.format(num) + thread = PlugThread(tname, (buf_q, work_q, lock)) + thread.start() + if mac_gui: + rthread = RefreshThread(lock) + rthread.start() + + while not buf_q.empty() or thr.active_count() != start_cnt: + try: + action, name, msg = buf_q.get(True, 0.25) + buf.write(action, name, ['OK'] if not msg else msg) + buf_q.task_done() + except queue.Empty: + pass + except KeyboardInterrupt: + G_STOP.set() + + if mac_gui: + rthread.stop() + rthread.join() + +main() +EOF +endfunction + +function! s:update_ruby() + ruby << EOF + module PlugStream + SEP = ["\r", "\n", nil] + def get_line + buffer = '' + loop do + char = readchar rescue return + if SEP.include? char.chr + buffer << $/ + break + else + buffer << char + end + end + buffer + end + end unless defined?(PlugStream) + + def esc arg + %["#{arg.gsub('"', '\"')}"] + end + + def killall pid + pids = [pid] + if /mswin|mingw|bccwin/ =~ RUBY_PLATFORM + pids.each { |pid| Process.kill 'INT', pid.to_i rescue nil } + else + unless `which pgrep 2> /dev/null`.empty? + children = pids + until children.empty? + children = children.map { |pid| + `pgrep -P #{pid}`.lines.map { |l| l.chomp } + }.flatten + pids += children + end + end + pids.each { |pid| Process.kill 'TERM', pid.to_i rescue nil } + end + end + + def compare_git_uri a, b + regex = %r{^(?:\w+://)?(?:[^@/]*@)?([^:/]*(?::[0-9]*)?)[:/](.*?)(?:\.git)?/?$} + regex.match(a).to_a.drop(1) == regex.match(b).to_a.drop(1) + end + + require 'thread' + require 'fileutils' + require 'timeout' + running = true + iswin = VIM::evaluate('s:is_win').to_i == 1 + pull = VIM::evaluate('s:update.pull').to_i == 1 + base = VIM::evaluate('g:plug_home') + all = VIM::evaluate('s:update.todo') + limit = VIM::evaluate('get(g:, "plug_timeout", 60)') + tries = VIM::evaluate('get(g:, "plug_retries", 2)') + 1 + nthr = VIM::evaluate('s:update.threads').to_i + maxy = VIM::evaluate('winheight(".")').to_i + vim7 = VIM::evaluate('v:version').to_i <= 703 && RUBY_PLATFORM =~ /darwin/ + cd = iswin ? 'cd /d' : 'cd' + tot = VIM::evaluate('len(s:update.todo)') || 0 + bar = '' + skip = 'Already installed' + mtx = Mutex.new + take1 = proc { mtx.synchronize { running && all.shift } } + logh = proc { + cnt = bar.length + $curbuf[1] = "#{pull ? 'Updating' : 'Installing'} plugins (#{cnt}/#{tot})" + $curbuf[2] = '[' + bar.ljust(tot) + ']' + VIM::command('normal! 2G') + VIM::command('redraw') + } + where = proc { |name| (1..($curbuf.length)).find { |l| $curbuf[l] =~ /^[-+x*] #{name}:/ } } + log = proc { |name, result, type| + mtx.synchronize do + ing = ![true, false].include?(type) + bar += type ? '=' : 'x' unless ing + b = case type + when :install then '+' when :update then '*' + when true, nil then '-' else + VIM::command("call add(s:update.errors, '#{name}')") + 'x' + end + result = + if type || type.nil? + ["#{b} #{name}: #{result.lines.to_a.last || 'OK'}"] + elsif result =~ /^Interrupted|^Timeout/ + ["#{b} #{name}: #{result}"] + else + ["#{b} #{name}"] + result.lines.map { |l| " " << l } + end + if lnum = where.call(name) + $curbuf.delete lnum + lnum = 4 if ing && lnum > maxy + end + result.each_with_index do |line, offset| + $curbuf.append((lnum || 4) - 1 + offset, line.gsub(/\e\[./, '').chomp) + end + logh.call + end + } + bt = proc { |cmd, name, type, cleanup| + tried = timeout = 0 + begin + tried += 1 + timeout += limit + fd = nil + data = '' + if iswin + Timeout::timeout(timeout) do + tmp = VIM::evaluate('tempname()') + system("(#{cmd}) > #{tmp}") + data = File.read(tmp).chomp + File.unlink tmp rescue nil + end + else + fd = IO.popen(cmd).extend(PlugStream) + first_line = true + log_prob = 1.0 / nthr + while line = Timeout::timeout(timeout) { fd.get_line } + data << line + log.call name, line.chomp, type if name && (first_line || rand < log_prob) + first_line = false + end + fd.close + end + [$? == 0, data.chomp] + rescue Timeout::Error, Interrupt => e + if fd && !fd.closed? + killall fd.pid + fd.close + end + cleanup.call if cleanup + if e.is_a?(Timeout::Error) && tried < tries + 3.downto(1) do |countdown| + s = countdown > 1 ? 's' : '' + log.call name, "Timeout. Will retry in #{countdown} second#{s} ...", type + sleep 1 + end + log.call name, 'Retrying ...', type + retry + end + [false, e.is_a?(Interrupt) ? "Interrupted!" : "Timeout!"] + end + } + main = Thread.current + threads = [] + watcher = Thread.new { + if vim7 + while VIM::evaluate('getchar(1)') + sleep 0.1 + end + else + require 'io/console' # >= Ruby 1.9 + nil until IO.console.getch == 3.chr + end + mtx.synchronize do + running = false + threads.each { |t| t.raise Interrupt } unless vim7 + end + threads.each { |t| t.join rescue nil } + main.kill + } + refresh = Thread.new { + while true + mtx.synchronize do + break unless running + VIM::command('noautocmd normal! a') + end + sleep 0.2 + end + } if VIM::evaluate('s:mac_gui') == 1 + + clone_opt = VIM::evaluate('s:clone_opt') + progress = VIM::evaluate('s:progress_opt(1)') + nthr.times do + mtx.synchronize do + threads << Thread.new { + while pair = take1.call + name = pair.first + dir, uri, tag = pair.last.values_at *%w[dir uri tag] + exists = File.directory? dir + ok, result = + if exists + chdir = "#{cd} #{iswin ? dir : esc(dir)}" + ret, data = bt.call "#{chdir} && git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url", nil, nil, nil + current_uri = data.lines.to_a.last + if !ret + if data =~ /^Interrupted|^Timeout/ + [false, data] + else + [false, [data.chomp, "PlugClean required."].join($/)] + end + elsif !compare_git_uri(current_uri, uri) + [false, ["Invalid URI: #{current_uri}", + "Expected: #{uri}", + "PlugClean required."].join($/)] + else + if pull + log.call name, 'Updating ...', :update + fetch_opt = (tag && File.exist?(File.join(dir, '.git/shallow'))) ? '--depth 99999999' : '' + bt.call "#{chdir} && git fetch #{fetch_opt} #{progress} 2>&1", name, :update, nil + else + [true, skip] + end + end + else + d = esc dir.sub(%r{[\\/]+$}, '') + log.call name, 'Installing ...', :install + bt.call "git clone #{clone_opt unless tag} #{progress} #{uri} #{d} 2>&1", name, :install, proc { + FileUtils.rm_rf dir + } + end + mtx.synchronize { VIM::command("let s:update.new['#{name}'] = 1") } if !exists && ok + log.call name, result, ok + end + } if running + end + end + threads.each { |t| t.join rescue nil } + logh.call + refresh.kill if refresh + watcher.kill +EOF +endfunction + +function! s:shellesc_cmd(arg) + let escaped = substitute(a:arg, '[&|<>()@^]', '^&', 'g') + let escaped = substitute(escaped, '%', '%%', 'g') + let escaped = substitute(escaped, '"', '\\^&', 'g') + let escaped = substitute(escaped, '\(\\\+\)\(\\^\)', '\1\1\2', 'g') + return '^"'.substitute(escaped, '\(\\\+\)$', '\1\1', '').'^"' +endfunction + +function! s:shellesc(arg) + if &shell =~# 'cmd.exe$' + return s:shellesc_cmd(a:arg) + endif + return shellescape(a:arg) +endfunction + +function! s:glob_dir(path) + return map(filter(s:glob(a:path, '**'), 'isdirectory(v:val)'), 's:dirpath(v:val)') +endfunction + +function! s:progress_bar(line, bar, total) + call setline(a:line, '[' . s:lpad(a:bar, a:total) . ']') +endfunction + +function! s:compare_git_uri(a, b) + " See `git help clone' + " https:// [user@] github.com[:port] / junegunn/vim-plug [.git] + " [git@] github.com[:port] : junegunn/vim-plug [.git] + " file:// / junegunn/vim-plug [/] + " / junegunn/vim-plug [/] + let pat = '^\%(\w\+://\)\='.'\%([^@/]*@\)\='.'\([^:/]*\%(:[0-9]*\)\=\)'.'[:/]'.'\(.\{-}\)'.'\%(\.git\)\=/\?$' + let ma = matchlist(a:a, pat) + let mb = matchlist(a:b, pat) + return ma[1:2] ==# mb[1:2] +endfunction + +function! s:format_message(bullet, name, message) + if a:bullet != 'x' + return [printf('%s %s: %s', a:bullet, a:name, s:lastline(a:message))] + else + let lines = map(s:lines(a:message), '" ".v:val') + return extend([printf('x %s:', a:name)], lines) + endif +endfunction + +function! s:with_cd(cmd, dir) + return printf('cd%s %s && %s', s:is_win ? ' /d' : '', s:shellesc(a:dir), a:cmd) +endfunction + +function! s:system(cmd, ...) + try + let [sh, shellcmdflag, shrd] = s:chsh(1) + let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd + if s:is_win + let batchfile = tempname().'.bat' + call writefile(["@echo off\r", cmd . "\r"], batchfile) + let cmd = batchfile + endif + return system(s:is_win ? '('.cmd.')' : cmd) + finally + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win + call delete(batchfile) + endif + endtry +endfunction + +function! s:system_chomp(...) + let ret = call('s:system', a:000) + return v:shell_error ? '' : substitute(ret, '\n$', '', '') +endfunction + +function! s:git_validate(spec, check_branch) + let err = '' + if isdirectory(a:spec.dir) + let result = s:lines(s:system('git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url', a:spec.dir)) + let remote = result[-1] + if v:shell_error + let err = join([remote, 'PlugClean required.'], "\n") + elseif !s:compare_git_uri(remote, a:spec.uri) + let err = join(['Invalid URI: '.remote, + \ 'Expected: '.a:spec.uri, + \ 'PlugClean required.'], "\n") + elseif a:check_branch && has_key(a:spec, 'commit') + let result = s:lines(s:system('git rev-parse HEAD 2>&1', a:spec.dir)) + let sha = result[-1] + if v:shell_error + let err = join(add(result, 'PlugClean required.'), "\n") + elseif !s:hash_match(sha, a:spec.commit) + let err = join([printf('Invalid HEAD (expected: %s, actual: %s)', + \ a:spec.commit[:6], sha[:6]), + \ 'PlugUpdate required.'], "\n") + endif + elseif a:check_branch + let branch = result[0] + " Check tag + if has_key(a:spec, 'tag') + let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir) + if a:spec.tag !=# tag && a:spec.tag !~ '\*' + let err = printf('Invalid tag: %s (expected: %s). Try PlugUpdate.', + \ (empty(tag) ? 'N/A' : tag), a:spec.tag) + endif + " Check branch + elseif a:spec.branch !=# branch + let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.', + \ branch, a:spec.branch) + endif + if empty(err) + let [ahead, behind] = split(s:lastline(s:system(printf( + \ 'git rev-list --count --left-right HEAD...origin/%s', + \ a:spec.branch), a:spec.dir)), '\t') + if !v:shell_error && ahead + if behind + " Only mention PlugClean if diverged, otherwise it's likely to be + " pushable (and probably not that messed up). + let err = printf( + \ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n" + \ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', a:spec.branch, ahead, behind) + else + let err = printf("Ahead of origin/%s by %d commit(s).\n" + \ .'Cannot update until local changes are pushed.', + \ a:spec.branch, ahead) + endif + endif + endif + endif + else + let err = 'Not found' + endif + return [err, err =~# 'PlugClean'] +endfunction + +function! s:rm_rf(dir) + if isdirectory(a:dir) + call s:system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . s:shellesc(a:dir)) + endif +endfunction + +function! s:clean(force) + call s:prepare() + call append(0, 'Searching for invalid plugins in '.g:plug_home) + call append(1, '') + + " List of valid directories + let dirs = [] + let errs = {} + let [cnt, total] = [0, len(g:plugs)] + for [name, spec] in items(g:plugs) + if !s:is_managed(name) + call add(dirs, spec.dir) + else + let [err, clean] = s:git_validate(spec, 1) + if clean + let errs[spec.dir] = s:lines(err)[0] + else + call add(dirs, spec.dir) + endif + endif + let cnt += 1 + call s:progress_bar(2, repeat('=', cnt), total) + normal! 2G + redraw + endfor + + let allowed = {} + for dir in dirs + let allowed[s:dirpath(fnamemodify(dir, ':h:h'))] = 1 + let allowed[dir] = 1 + for child in s:glob_dir(dir) + let allowed[child] = 1 + endfor + endfor + + let todo = [] + let found = sort(s:glob_dir(g:plug_home)) + while !empty(found) + let f = remove(found, 0) + if !has_key(allowed, f) && isdirectory(f) + call add(todo, f) + call append(line('$'), '- ' . f) + if has_key(errs, f) + call append(line('$'), ' ' . errs[f]) + endif + let found = filter(found, 'stridx(v:val, f) != 0') + end + endwhile + + 4 + redraw + if empty(todo) + call append(line('$'), 'Already clean.') + else + let s:clean_count = 0 + call append(3, ['Directories to delete:', '']) + redraw! + if a:force || s:ask_no_interrupt('Delete all directories?') + call s:delete([6, line('$')], 1) + else + call setline(4, 'Cancelled.') + nnoremap d :set opfunc=delete_opg@ + nmap dd d_ + xnoremap d :call delete_op(visualmode(), 1) + echo 'Delete the lines (d{motion}) to delete the corresponding directories' + endif + endif + 4 + setlocal nomodifiable +endfunction + +function! s:delete_op(type, ...) + call s:delete(a:0 ? [line("'<"), line("'>")] : [line("'["), line("']")], 0) +endfunction + +function! s:delete(range, force) + let [l1, l2] = a:range + let force = a:force + while l1 <= l2 + let line = getline(l1) + if line =~ '^- ' && isdirectory(line[2:]) + execute l1 + redraw! + let answer = force ? 1 : s:ask('Delete '.line[2:].'?', 1) + let force = force || answer > 1 + if answer + call s:rm_rf(line[2:]) + setlocal modifiable + call setline(l1, '~'.line[1:]) + let s:clean_count += 1 + call setline(4, printf('Removed %d directories.', s:clean_count)) + setlocal nomodifiable + endif + endif + let l1 += 1 + endwhile +endfunction + +function! s:upgrade() + echo 'Downloading the latest version of vim-plug' + redraw + let tmp = tempname() + let new = tmp . '/plug.vim' + + try + let out = s:system(printf('git clone --depth 1 %s %s', s:shellesc(s:plug_src), s:shellesc(tmp))) + if v:shell_error + return s:err('Error upgrading vim-plug: '. out) + endif + + if readfile(s:me) ==# readfile(new) + echo 'vim-plug is already up-to-date' + return 0 + else + call rename(s:me, s:me . '.old') + call rename(new, s:me) + unlet g:loaded_plug + echo 'vim-plug has been upgraded' + return 1 + endif + finally + silent! call s:rm_rf(tmp) + endtry +endfunction + +function! s:upgrade_specs() + for spec in values(g:plugs) + let spec.frozen = get(spec, 'frozen', 0) + endfor +endfunction + +function! s:status() + call s:prepare() + call append(0, 'Checking plugins') + call append(1, '') + + let ecnt = 0 + let unloaded = 0 + let [cnt, total] = [0, len(g:plugs)] + for [name, spec] in items(g:plugs) + let is_dir = isdirectory(spec.dir) + if has_key(spec, 'uri') + if is_dir + let [err, _] = s:git_validate(spec, 1) + let [valid, msg] = [empty(err), empty(err) ? 'OK' : err] + else + let [valid, msg] = [0, 'Not found. Try PlugInstall.'] + endif + else + if is_dir + let [valid, msg] = [1, 'OK'] + else + let [valid, msg] = [0, 'Not found.'] + endif + endif + let cnt += 1 + let ecnt += !valid + " `s:loaded` entry can be missing if PlugUpgraded + if is_dir && get(s:loaded, name, -1) == 0 + let unloaded = 1 + let msg .= ' (not loaded)' + endif + call s:progress_bar(2, repeat('=', cnt), total) + call append(3, s:format_message(valid ? '-' : 'x', name, msg)) + normal! 2G + redraw + endfor + call setline(1, 'Finished. '.ecnt.' error(s).') + normal! gg + setlocal nomodifiable + if unloaded + echo "Press 'L' on each line to load plugin, or 'U' to update" + nnoremap L :call status_load(line('.')) + xnoremap L :call status_load(line('.')) + end +endfunction + +function! s:extract_name(str, prefix, suffix) + return matchstr(a:str, '^'.a:prefix.' \zs[^:]\+\ze:.*'.a:suffix.'$') +endfunction + +function! s:status_load(lnum) + let line = getline(a:lnum) + let name = s:extract_name(line, '-', '(not loaded)') + if !empty(name) + call plug#load(name) + setlocal modifiable + call setline(a:lnum, substitute(line, ' (not loaded)$', '', '')) + setlocal nomodifiable + endif +endfunction + +function! s:status_update() range + let lines = getline(a:firstline, a:lastline) + let names = filter(map(lines, 's:extract_name(v:val, "[x-]", "")'), '!empty(v:val)') + if !empty(names) + echo + execute 'PlugUpdate' join(names) + endif +endfunction + +function! s:is_preview_window_open() + silent! wincmd P + if &previewwindow + wincmd p + return 1 + endif +endfunction + +function! s:find_name(lnum) + for lnum in reverse(range(1, a:lnum)) + let line = getline(lnum) + if empty(line) + return '' + endif + let name = s:extract_name(line, '-', '') + if !empty(name) + return name + endif + endfor + return '' +endfunction + +function! s:preview_commit() + if b:plug_preview < 0 + let b:plug_preview = !s:is_preview_window_open() + endif + + let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}') + if empty(sha) + return + endif + + let name = s:find_name(line('.')) + if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir) + return + endif + + if exists('g:plug_pwindow') && !s:is_preview_window_open() + execute g:plug_pwindow + execute 'e' sha + else + execute 'pedit' sha + wincmd P + endif + setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable + try + let [sh, shellcmdflag, shrd] = s:chsh(1) + let cmd = 'cd '.s:shellesc(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha + if s:is_win + let batchfile = tempname().'.bat' + call writefile(["@echo off\r", cmd . "\r"], batchfile) + let cmd = batchfile + endif + execute 'silent %!' cmd + finally + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win + call delete(batchfile) + endif + endtry + setlocal nomodifiable + nnoremap q :q + wincmd p +endfunction + +function! s:section(flags) + call search('\(^[x-] \)\@<=[^:]\+:', a:flags) +endfunction + +function! s:format_git_log(line) + let indent = ' ' + let tokens = split(a:line, nr2char(1)) + if len(tokens) != 5 + return indent.substitute(a:line, '\s*$', '', '') + endif + let [graph, sha, refs, subject, date] = tokens + let tag = matchstr(refs, 'tag: [^,)]\+') + let tag = empty(tag) ? ' ' : ' ('.tag.') ' + return printf('%s%s%s%s%s (%s)', indent, graph, sha, tag, subject, date) +endfunction + +function! s:append_ul(lnum, text) + call append(a:lnum, ['', a:text, repeat('-', len(a:text))]) +endfunction + +function! s:diff() + call s:prepare() + call append(0, ['Collecting changes ...', '']) + let cnts = [0, 0] + let bar = '' + let total = filter(copy(g:plugs), 's:is_managed(v:key) && isdirectory(v:val.dir)') + call s:progress_bar(2, bar, len(total)) + for origin in [1, 0] + let plugs = reverse(sort(items(filter(copy(total), (origin ? '' : '!').'(has_key(v:val, "commit") || has_key(v:val, "tag"))')))) + if empty(plugs) + continue + endif + call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:') + for [k, v] in plugs + let range = origin ? '..origin/'.v.branch : 'HEAD@{1}..' + let cmd = 'git log --graph --color=never '.join(map(['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range], 's:shellesc(v:val)')) + if has_key(v, 'rtp') + let cmd .= ' -- '.s:shellesc(v.rtp) + endif + let diff = s:system_chomp(cmd, v.dir) + if !empty(diff) + let ref = has_key(v, 'tag') ? (' (tag: '.v.tag.')') : has_key(v, 'commit') ? (' '.v.commit) : '' + call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)'))) + let cnts[origin] += 1 + endif + let bar .= '=' + call s:progress_bar(2, bar, len(total)) + normal! 2G + redraw + endfor + if !cnts[origin] + call append(5, ['', 'N/A']) + endif + endfor + call setline(1, printf('%d plugin(s) updated.', cnts[0]) + \ . (cnts[1] ? printf(' %d plugin(s) have pending updates.', cnts[1]) : '')) + + if cnts[0] || cnts[1] + nnoremap (plug-preview) :silent! call preview_commit() + if empty(maparg("\", 'n')) + nmap (plug-preview) + endif + if empty(maparg('o', 'n')) + nmap o (plug-preview) + endif + endif + if cnts[0] + nnoremap X :call revert() + echo "Press 'X' on each block to revert the update" + endif + normal! gg + setlocal nomodifiable +endfunction + +function! s:revert() + if search('^Pending updates', 'bnW') + return + endif + + let name = s:find_name(line('.')) + if empty(name) || !has_key(g:plugs, name) || + \ input(printf('Revert the update of %s? (y/N) ', name)) !~? '^y' + return + endif + + call s:system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch).' --', g:plugs[name].dir) + setlocal modifiable + normal! "_dap + setlocal nomodifiable + echo 'Reverted' +endfunction + +function! s:snapshot(force, ...) abort + call s:prepare() + setf vim + call append(0, ['" Generated by vim-plug', + \ '" '.strftime("%c"), + \ '" :source this file in vim to restore the snapshot', + \ '" or execute: vim -S snapshot.vim', + \ '', '', 'PlugUpdate!']) + 1 + let anchor = line('$') - 3 + let names = sort(keys(filter(copy(g:plugs), + \'has_key(v:val, "uri") && !has_key(v:val, "commit") && isdirectory(v:val.dir)'))) + for name in reverse(names) + let sha = s:system_chomp('git rev-parse --short HEAD', g:plugs[name].dir) + if !empty(sha) + call append(anchor, printf("silent! let g:plugs['%s'].commit = '%s'", name, sha)) + redraw + endif + endfor + + if a:0 > 0 + let fn = expand(a:1) + if filereadable(fn) && !(a:force || s:ask(a:1.' already exists. Overwrite?')) + return + endif + call writefile(getline(1, '$'), fn) + echo 'Saved as '.a:1 + silent execute 'e' s:esc(fn) + setf vim + endif +endfunction + +function! s:split_rtp() + return split(&rtp, '\\\@'`. NeoBundle assumes Github as the default location for plugins, so +for most plugins you can simply use `NeoBundle 'username/plugin'` rather than +using the absolute URL of the plugin. These calls should be made in your +.vimrc file. Once you have defined these, you must call `NeoBundleInstall`, +and NeoBundle will clone all of the repos into the desired folder (generally +`~/.vim/bundle`) and load them into Vim. If you want to update these +repositories, simply call `NeoBundleUpdate`. + +A few other useful commands: +- `:NeoBundleList` - list configured bundles +- `:NeoBundleInstall(!)` - install (update) bundles + +Refer to `:help neobundle` for more examples and for a full list of commands. + +## Quick start + +### 1. Install NeoBundle + +#### If you are using Unix/Linux or Mac OS X. + +1. Run below script. + + ``` + $ curl https://raw.githubusercontent.com/Shougo/neobundle.vim/master/bin/install.sh > install.sh + $ sh ./install.sh + ``` +Complete. + +#### If you want to install manually or you are using Windows. + +1. Setup NeoBundle: + + ``` + $ mkdir ~/.vim/bundle + $ git clone https://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim + ``` + +2. Configure bundles: + + Sample `.vimrc`: + + ```vim + " Note: Skip initialization for vim-tiny or vim-small. + if 0 | endif + + if &compatible + set nocompatible " Be iMproved + endif + + " Required: + set runtimepath+=~/.vim/bundle/neobundle.vim/ + + " Required: + call neobundle#begin(expand('~/.vim/bundle/')) + + " Let NeoBundle manage NeoBundle + " Required: + NeoBundleFetch 'Shougo/neobundle.vim' + + " My Bundles here: + " Refer to |:NeoBundle-examples|. + " Note: You don't set neobundle setting in .gvimrc! + + call neobundle#end() + + " Required: + filetype plugin indent on + + " If there are uninstalled bundles found on startup, + " this will conveniently prompt you to install them. + NeoBundleCheck + ``` + +### 2. Install configured bundles + +Launch `vim`, run `:NeoBundleInstall` or `:Unite neobundle/install` (required +unite.vim) Or Command run `bin/neoinstall` or `vim +NeoBundleInstall +qall` + + +## How to test + +Run `make test` command in command line(required vim-themis). + +https://github.com/thinca/vim-themis + + +## Advantages over Vundle + +1. Plugin prefixed command name (:Bundle vs :NeoBundle). +2. Support for vimproc (asynchronous update/install). +3. Support for unite.vim interface (update/install/search). +4. Support for revision locking. +5. Support for multiple version control systems (Subversion/Git). +6. Support for lazy initialization for optimizing startup time. +7. and so on... + +## Tips + +If you use a single .vimrc across systems where build programs are +named differently (e.g. GNU Make is often `gmake` on non-GNU +systems), the following pattern is useful: + +```vim +let g:make = 'gmake' +if system('uname -o') =~ '^GNU/' + let g:make = 'make' +endif +NeoBundle 'Shougo/vimproc.vim', {'build': {'unix': g:make}} +``` diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle.vim new file mode 100644 index 0000000..337b3c4 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle.vim @@ -0,0 +1,448 @@ +"============================================================================= +" FILE: neobundle.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +" Check 'term' option value. +if exists('g:loaded_neobundle') && &term ==# 'builtin_gui' + echoerr 'neobundle is initialized in .gvimrc!' + \' neobundle must be initialized in .vimrc.' +endif + +if v:version < 702 + echoerr 'neobundle does not work this version of Vim (' . v:version . ').' + finish +endif + +" Global options definition." "{{{ +call neobundle#util#set_default( + \ 'g:neobundle#log_filename', '', 'g:neobundle_log_filename') +call neobundle#util#set_default( + \ 'g:neobundle#default_site', 'github', 'g:neobundle_default_site') +call neobundle#util#set_default( + \ 'g:neobundle#enable_name_conversion', 0) +call neobundle#util#set_default( + \ 'g:neobundle#default_options', {}) +call neobundle#util#set_default( + \ 'g:neobundle#install_max_processes', 8, + \ 'g:unite_source_neobundle_install_max_processes') +call neobundle#util#set_default( + \ 'g:neobundle#install_process_timeout', 120) +"}}} + +let g:neobundle#tapped = {} +let g:neobundle#hooks = {} +let s:neobundle_dir = '' +let s:neobundle_runtime_dir = neobundle#util#substitute_path_separator( + \ fnamemodify(expand(''), ':p:h:h')) + +command! -nargs=+ + \ NeoBundle + \ call neobundle#parser#bundle( + \ substitute(, '\s"[^"]\+$', '', '')) + +command! -bar + \ NeoBundleCheck + \ call neobundle#commands#check() + +command! -nargs=? -bar + \ -complete=customlist,neobundle#commands#complete_bundles + \ NeoBundleCheckUpdate + \ call neobundle#commands#check_update() + +command! -nargs=+ + \ NeoBundleLazy + \ call neobundle#parser#lazy( + \ substitute(, '\s"[^"]\+$', '', '')) + +command! -nargs=+ + \ NeoBundleFetch + \ call neobundle#parser#fetch( + \ substitute(, '\s"[^"]\+$', '', '')) + +command! -nargs=1 -complete=dir -bar + \ NeoBundleLocal + \ call neobundle#local(, {}) + +command! -nargs=+ -bar + \ NeoBundleDirectInstall + \ call neobundle#parser#direct( + \ substitute(, '\s"[^"]\+$', '', '')) + +command! -nargs=* -bar + \ -complete=customlist,neobundle#commands#complete_lazy_bundles + \ NeoBundleSource + \ call neobundle#commands#source([]) + +command! -nargs=+ -bar + \ -complete=customlist,neobundle#commands#complete_bundles + \ NeoBundleDisable + \ call neobundle#config#disable() + +command! -nargs=? -bang -bar + \ -complete=customlist,neobundle#commands#complete_bundles + \ NeoBundleInstall + \ call neobundle#commands#install( + \ '!' == '', ) +command! -nargs=? -bang -bar + \ -complete=customlist,neobundle#commands#complete_bundles + \ NeoBundleUpdate + \ call neobundle#commands#install( + \ ('!' == '' ? 2 : 1), ) + +command! -nargs=+ -bang -bar + \ -complete=customlist,neobundle#commands#complete_bundles + \ NeoBundleReinstall + \ call neobundle#commands#reinstall() + +command! -nargs=? -bar + \ -complete=customlist,neobundle#commands#complete_bundles + \ NeoBundleGC + \ call neobundle#commands#gc() + +command! -nargs=? -bang -bar + \ NeoBundleList + \ call neobundle#commands#list() + +command! -bar + \ NeoBundleDocs + \ call neobundle#commands#helptags( + \ neobundle#config#get_enabled_bundles()) + +command! -bar + \ NeoBundleLog + \ echo join(neobundle#installer#get_log(), "\n") + +command! -bar + \ NeoBundleUpdatesLog + \ echo join(neobundle#installer#get_updates_log(), "\n") + +command! -bar + \ NeoBundleExtraEdit + \ execute 'edit' fnameescape( + \ neobundle#get_neobundle_dir()).'/extra_bundles.vim' + +command! -bar + \ NeoBundleCount + \ echo len(neobundle#config#get_neobundles()) + +command! -bar + \ NeoBundleSaveCache + \ call neobundle#commands#save_cache() +command! -bar + \ NeoBundleLoadCache + \ call neobundle#util#print_error( + \ 'NeoBundleLoadCache is deprecated command.') | + \ call neobundle#util#print_error( + \ 'It will be removed in the next version.') | + \ call neobundle#util#print_error( + \ 'Please use neobundle#load_cache() instead.') | + \ call neobundle#commands#load_cache([$MYVIMRC]) +command! -bar + \ NeoBundleClearCache + \ call neobundle#commands#clear_cache() + +command! -nargs=1 -bar + \ -complete=customlist,neobundle#commands#complete_bundles + \ NeoBundleRollback + \ call neobundle#commands#rollback() + +command! -nargs=+ -bar + \ NeoBundleLock + \ call neobundle#commands#lock() + +command! -bar + \ NeoBundleRemotePlugins + \ call neobundle#commands#remote_plugins() + +function! neobundle#rc(...) abort "{{{ + call neobundle#util#print_error( + \ 'neobundle#rc() is removed function.') + call neobundle#util#print_error( + \ 'Please use neobundle#begin()/neobundle#end() instead.') + return 1 +endfunction"}}} + +function! neobundle#begin(...) abort "{{{ + if a:0 > 0 + let path = a:1 + else + " Use default path + let paths = filter(split(globpath(&runtimepath, + \ 'bundle', 1), '\n'), 'isdirectory(v:val)') + if empty(paths) + let rtps = neobundle#util#split_rtp(&runtimepath) + if empty(rtps) + call neobundle#util#print_error( + \ 'Invalid runtimepath is detected.') + call neobundle#util#print_error( + \ 'Please check your .vimrc.') + return 1 + endif + + let paths = [rtps[0].'/bundle'] + endif + + let path = paths[0] + endif + + return neobundle#init#_rc(path) +endfunction"}}} +function! neobundle#append() abort "{{{ + call neobundle#config#append() +endfunction"}}} +function! neobundle#end() abort "{{{ + call neobundle#config#final() +endfunction"}}} + +function! neobundle#add(repository, ...) abort "{{{ + let options = get(a:000, 0, {}) + let bundle = neobundle#parser#_init_bundle( + \ a:repository, [options]) + if empty(bundle) + return {} + endif + + let bundle.orig_arg = [a:repository, options] + call neobundle#config#add(bundle) + + return bundle +endfunction"}}} +function! neobundle#add_meta(name, ...) abort "{{{ + let metadata = neobundle#metadata#get(a:name) + if empty(metadata) + call neobundle#util#print_error( + \ 'Plugin name "' . a:name . '" is not found.') + return {} + endif + + let repository = substitute(metadata.url, '^git://', 'https://', '') + let options = { 'name' : a:name } + if has_key(metadata, 'addon-info') + \ && has_key(metadata['addon-info'], 'dependencies') + let options.depends = map(keys(metadata['addon-info'].dependencies), + \ "substitute(neobundle#metadata#get(v:val).url, + \ '^git://', 'https://', '')") + endif + call extend(options, get(a:000, 0, {})) + + return neobundle#add(repository, options) +endfunction"}}} + +function! neobundle#set_neobundle_dir(path) abort "{{{ + let s:neobundle_dir = a:path +endfunction"}}} + +function! neobundle#get_neobundle_dir() abort "{{{ + if s:neobundle_dir == '' + call neobundle#util#print_error( + \ 'neobundle directory is empty.') + return '' + endif + + let dir = s:neobundle_dir + if !isdirectory(dir) + call mkdir(dir, 'p') + endif + return dir +endfunction"}}} + +function! neobundle#get_runtime_dir() abort "{{{ + return s:neobundle_runtime_dir +endfunction"}}} + +function! neobundle#get_tags_dir() abort "{{{ + if s:neobundle_dir == '' + return '' + endif + + let dir = s:neobundle_dir . '/.neobundle/doc' + if !isdirectory(dir) + call mkdir(dir, 'p') + endif + return dir +endfunction"}}} + +function! neobundle#get_rtp_dir() abort "{{{ + if s:neobundle_dir == '' + return '' + endif + + let dir = s:neobundle_dir . '/.neobundle' + if !isdirectory(dir) + call mkdir(dir, 'p') + endif + return dir +endfunction"}}} + +function! neobundle#source(bundle_names) abort "{{{ + return neobundle#config#source(a:bundle_names) +endfunction"}}} + +function! neobundle#local(localdir, ...) abort "{{{ + return neobundle#parser#local( + \ a:localdir, get(a:000, 0, {}), get(a:000, 1, ['*'])) +endfunction"}}} + +function! neobundle#exists_not_installed_bundles() abort "{{{ + return !empty(neobundle#get_not_installed_bundles([])) +endfunction"}}} + +function! neobundle#is_installed(...) abort "{{{ + return type(get(a:000, 0, [])) == type([]) ? + \ !empty(neobundle#_get_installed_bundles(get(a:000, 0, []))) : + \ neobundle#config#is_installed(a:1) +endfunction"}}} + +function! neobundle#is_sourced(name) abort "{{{ + return neobundle#config#is_sourced(a:name) +endfunction"}}} + +function! neobundle#has_cache() abort "{{{ + call neobundle#util#print_error( + \ 'neobundle#has_cache() is deprecated function.') + call neobundle#util#print_error( + \ 'It will be removed in the next version.') + call neobundle#util#print_error( + \ 'Please use neobundle#load_cache() instead.') + + return filereadable(neobundle#commands#get_cache_file()) +endfunction"}}} + +function! neobundle#load_cache(...) abort "{{{ + let vimrcs = len(a:000) == 0 ? [$MYVIMRC] : a:000 + return neobundle#commands#load_cache(vimrcs) +endfunction"}}} + +function! neobundle#get_not_installed_bundle_names() abort "{{{ + return map(neobundle#get_not_installed_bundles([]), 'v:val.name') +endfunction"}}} + +function! neobundle#get_not_installed_bundles(bundle_names) abort "{{{ + let bundles = empty(a:bundle_names) ? + \ neobundle#config#get_neobundles() : + \ neobundle#config#fuzzy_search(a:bundle_names) + + call neobundle#installer#_load_install_info(bundles) + + return filter(copy(bundles), " + \ !v:val.disabled && v:val.path != '' && !v:val.local + \ && !isdirectory(neobundle#util#expand(v:val.path)) + \") +endfunction"}}} + +function! neobundle#get_force_not_installed_bundles(bundle_names) abort "{{{ + let bundles = empty(a:bundle_names) ? + \ neobundle#config#get_neobundles() : + \ neobundle#config#fuzzy_search(a:bundle_names) + + call neobundle#installer#_load_install_info(bundles) + + return filter(copy(bundles), " + \ !v:val.disabled && v:val.path != '' && !v:val.local + \ && (!isdirectory(neobundle#util#expand(v:val.path)) + \ || v:val.install_rev !=# + \ neobundle#installer#get_revision_number(v:val)) + \") +endfunction"}}} + +function! neobundle#get(name) abort "{{{ + return neobundle#config#get(a:name) +endfunction"}}} +function! neobundle#get_hooks(name) abort "{{{ + return get(neobundle#config#get(a:name), 'hooks', {}) +endfunction"}}} + +function! neobundle#tap(name) abort "{{{ + let g:neobundle#tapped = neobundle#get(a:name) + let g:neobundle#hooks = get(neobundle#get(a:name), 'hooks', {}) + return !empty(g:neobundle#tapped) && !g:neobundle#tapped.disabled +endfunction"}}} +function! neobundle#untap() abort "{{{ + let g:neobundle#tapped = {} + let g:neobundle#hooks = {} +endfunction"}}} + +function! neobundle#bundle(arg, ...) abort "{{{ + let opts = get(a:000, 0, {}) + call map(neobundle#util#convert2list(a:arg), + \ "neobundle#config#add(neobundle#parser#_init_bundle( + \ v:val, [deepcopy(opts)]))") +endfunction"}}} + +function! neobundle#config(arg, ...) abort "{{{ + " Use neobundle#tapped or name. + return type(a:arg) == type({}) ? + \ neobundle#config#set(g:neobundle#tapped.name, a:arg) : + \ type(a:arg) == type('') ? + \ neobundle#config#set(a:arg, a:1) : + \ map(copy(a:arg), "neobundle#config#set(v:val, deepcopy(a:1))") +endfunction"}}} + +function! neobundle#call_hook(hook_name, ...) abort "{{{ + let bundles = neobundle#util#convert2list( + \ (empty(a:000) ? neobundle#config#get_neobundles() : a:1)) + let bundles = filter(copy(bundles), + \ 'has_key(v:val.hooks, a:hook_name)') + + if a:hook_name ==# 'on_source' || a:hook_name ==# 'on_post_source' + let bundles = filter(neobundle#config#tsort(filter(bundles, + \ 'neobundle#config#is_sourced(v:val.name) && + \ neobundle#config#is_installed(v:val.name)')), + \ 'has_key(v:val.hooks, a:hook_name)') + endif + + for bundle in bundles + if type(bundle.hooks[a:hook_name]) == type('') + execute 'source' fnameescape(bundle.hooks[a:hook_name]) + else + call call(bundle.hooks[a:hook_name], [bundle], bundle) + endif + endfor +endfunction"}}} + +function! neobundle#_get_installed_bundles(bundle_names) abort "{{{ + let bundles = empty(a:bundle_names) ? + \ neobundle#config#get_neobundles() : + \ neobundle#config#search(a:bundle_names) + + return filter(copy(bundles), + \ 'neobundle#config#is_installed(v:val.name)') +endfunction"}}} + +function! neobundle#load_toml(filename, ...) abort "{{{ + let opts = get(a:000, 0, {}) + return neobundle#parser#load_toml(a:filename, opts) +endfunction"}}} + +let s:init_vim_path = fnamemodify(expand(''), ':h') + \ . '/neobundle/init.vim' +function! neobundle#get_cache_version() abort "{{{ + return getftime(s:init_vim_path) +endfunction "}}} + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle/TOML.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle/TOML.vim new file mode 100644 index 0000000..18c1eb0 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle/TOML.vim @@ -0,0 +1,332 @@ +let s:save_cpo = &cpo +set cpo&vim + +" +" public api +" +function! neobundle#TOML#parse(text) abort + let input = { + \ 'text': a:text, + \ 'p': 0, + \ 'length': strlen(a:text), + \} + return s:_parse(input) +endfunction + +function! neobundle#TOML#parse_file(filename) abort + if !filereadable(a:filename) + throw printf("vital: Text.TOML: No such file `%s'.", a:filename) + endif + + let text = join(readfile(a:filename), "\n") + " fileencoding is always utf8 + return neobundle#TOML#parse(iconv(text, 'utf8', &encoding)) +endfunction + +" +" private api +" +" work around: '[^\r\n]*' doesn't work well in old-vim, but "[^\r\n]*" works well +let s:skip_pattern = '\C^\%(\_s\+\|' . "#[^\r\n]*" . '\)' +let s:table_name_pattern = '\%([^ [:tab:]#.[\]=]\+\)' +let s:table_key_pattern = s:table_name_pattern + +function! s:_skip(input) abort + while s:_match(a:input, '\%(\_s\|#\)') + let a:input.p = matchend(a:input.text, s:skip_pattern, a:input.p) + endwhile +endfunction + +function! s:_consume(input, pattern) abort + call s:_skip(a:input) + let end = matchend(a:input.text, '\C^' . a:pattern, a:input.p) + + if end == -1 + call s:_error(a:input) + elseif end == a:input.p + return '' + endif + + let matched = strpart(a:input.text, a:input.p, end - a:input.p) + let a:input.p = end + return matched +endfunction + +function! s:_match(input, pattern) abort + return match(a:input.text, '\C^' . a:pattern, a:input.p) != -1 +endfunction + +function! s:_eof(input) abort + return a:input.p >= a:input.length +endfunction + +function! s:_error(input) abort + let buf = [] + let offset = 0 + while (a:input.p + offset) < a:input.length && a:input.text[a:input.p + offset] !~# "[\r\n]" + let buf += [a:input.text[a:input.p + offset]] + let offset += 1 + endwhile + + throw printf("vital: Text.TOML: Illegal toml format at `%s'.", join(buf, '')) +endfunction + +function! s:_parse(input) abort + let data = {} + + call s:_skip(a:input) + while !s:_eof(a:input) + if s:_match(a:input, '[^ [:tab:]#.[\]]') + let key = s:_key(a:input) + call s:_equals(a:input) + let value = s:_value(a:input) + + call s:_put_dict(data, key, value) + + unlet value + elseif s:_match(a:input, '\[\[') + let [key, value] = s:_array_of_tables(a:input) + + call s:_put_array(data, key, value) + + unlet value + elseif s:_match(a:input, '\[') + let [key, value] = s:_table(a:input) + + call s:_put_dict(data, key, value) + + unlet value + else + call s:_error(a:input) + endif + call s:_skip(a:input) + endwhile + + return data +endfunction + +function! s:_key(input) abort + let s = s:_consume(a:input, s:table_key_pattern) + return s +endfunction + +function! s:_equals(input) abort + call s:_consume(a:input, '=') + return '=' +endfunction + +function! s:_value(input) abort + call s:_skip(a:input) + + if s:_match(a:input, '"\{3}') + return s:_multiline_basic_string(a:input) + elseif s:_match(a:input, '"\{1}') + return s:_basic_string(a:input) + elseif s:_match(a:input, "'\\{3}") + return s:_multiline_literal(a:input) + elseif s:_match(a:input, "'\\{1}") + return s:_literal(a:input) + elseif s:_match(a:input, '\[') + return s:_array(a:input) + elseif s:_match(a:input, '\%(true\|false\)') + return s:_boolean(a:input) + elseif s:_match(a:input, '\d\{4}-') + return s:_datetime(a:input) + elseif s:_match(a:input, '[+-]\?\%(\d\+\.\d\|\d\+\%(\.\d\+\)\?[eE]\)') + return s:_float(a:input) + else + return s:_integer(a:input) + endif +endfunction + +" +" String +" +function! s:_basic_string(input) abort + let s = s:_consume(a:input, '"\%(\\"\|[^"]\)*"') + let s = s[1 : -2] + return s:_unescape(s) +endfunction + +function! s:_multiline_basic_string(input) abort + let s = s:_consume(a:input, '"\{3}\_.\{-}"\{3}') + let s = s[3 : -4] + let s = substitute(s, "^\n", '', '') + let s = substitute(s, '\\' . "\n" . '\_s*', '', 'g') + return s:_unescape(s) +endfunction + +function! s:_literal(input) abort + let s = s:_consume(a:input, "'[^']*'") + return s[1 : -2] +endfunction + +function! s:_multiline_literal(input) abort + let s = s:_consume(a:input, "'\\{3}.\\{-}'\\{3}") + let s = s[3 : -4] + let s = substitute(s, "^\n", '', '') + return s +endfunction + +" +" Integer +" +function! s:_integer(input) abort + let s = s:_consume(a:input, '[+-]\?\d\+') + return str2nr(s) +endfunction + +" +" Float +" +function! s:_float(input) abort + if s:_match(a:input, '[+-]\?[0-9.]\+[eE][+-]\?\d\+') + return s:_exponent(a:input) + else + return s:_fractional(a:input) + endif +endfunction + +function! s:_fractional(input) abort + let s = s:_consume(a:input, '[+-]\?[0-9.]\+') + return str2float(s) +endfunction + +function! s:_exponent(input) abort + let s = s:_consume(a:input, '[+-]\?[0-9.]\+[eE][+-]\?\d\+') + return str2float(s) +endfunction + +" +" Boolean +" +function! s:_boolean(input) abort + let s = s:_consume(a:input, '\%(true\|false\)') + return (s ==# 'true') ? 1 : 0 +endfunction + +" +" Datetime +" +function! s:_datetime(input) abort + let s = s:_consume(a:input, '\d\{4}-\d\{2}-\d\{2}T\d\{2}:\d\{2}:\d\{2}\%(Z\|-\?\d\{2}:\d\{2}\|\.\d\+-\d\{2}:\d\{2}\)') + return s +endfunction + +" +" Array +" +function! s:_array(input) abort + let ary = [] + let _ = s:_consume(a:input, '\[') + call s:_skip(a:input) + while !s:_eof(a:input) && !s:_match(a:input, '\]') + let ary += [s:_value(a:input)] + call s:_consume(a:input, ',\?') + call s:_skip(a:input) + endwhile + let _ = s:_consume(a:input, '\]') + return ary +endfunction + +" +" Table +" +function! s:_table(input) abort + let tbl = {} + let name = s:_consume(a:input, '\[\s*' . s:table_name_pattern . '\%(\s*\.\s*' . s:table_name_pattern . '\)*\s*\]') + let name = name[1 : -2] + call s:_skip(a:input) + " while !s:_eof(a:input) && !s:_match(a:input, '\[\{1,2}[a-zA-Z0-9.]\+\]\{1,2}') + while !s:_eof(a:input) && !s:_match(a:input, '\[') + let key = s:_key(a:input) + call s:_equals(a:input) + let value = s:_value(a:input) + + let tbl[key] = value + + unlet value + call s:_skip(a:input) + endwhile + return [name, tbl] +endfunction + +" +" Array of tables +" +function! s:_array_of_tables(input) abort + let tbl = {} + let name = s:_consume(a:input, '\[\[\s*' . s:table_name_pattern . '\%(\s*\.\s*' . s:table_name_pattern . '\)*\s*\]\]') + let name = name[2 : -3] + call s:_skip(a:input) + " while !s:_eof(a:input) && !s:_match(a:input, '\[\{1,2}[a-zA-Z0-9.]\+\]\{1,2}') + while !s:_eof(a:input) && !s:_match(a:input, '\[') + let key = s:_key(a:input) + call s:_equals(a:input) + let value = s:_value(a:input) + + let tbl[key] = value + + unlet value + call s:_skip(a:input) + endwhile + return [name, [tbl]] +endfunction + +function! s:_unescape(text) abort + let text = a:text + let text = substitute(text, '\\"', '"', 'g') + let text = substitute(text, '\\b', "\b", 'g') + let text = substitute(text, '\\t', "\t", 'g') + let text = substitute(text, '\\n', "\n", 'g') + let text = substitute(text, '\\f', "\f", 'g') + let text = substitute(text, '\\r', "\r", 'g') + let text = substitute(text, '\\/', "/", 'g') + let text = substitute(text, '\\\\', '\', 'g') + let text = substitute(text, '\C\\u\(\x\{4}\)', '\=s:_nr2char("0x" . submatch(1))', 'g') + let text = substitute(text, '\C\\U\(\x\{8}\)', '\=s:_nr2char("0x" . submatch(1))', 'g') + return text +endfunction + +function! s:_nr2char(nr) abort + return iconv(nr2char(a:nr), &encoding, 'utf8') +endfunction + +function! s:_put_dict(dict, key, value) abort + let keys = split(a:key, '\.') + + let ref = a:dict + for key in keys[ : -2] + if has_key(ref, key) && type(ref[key]) == type({}) + let ref = ref[key] + elseif has_key(ref, key) && type(ref[key]) == type([]) + let ref = ref[key][-1] + else + let ref[key] = {} + let ref = ref[key] + endif + endfor + + let ref[keys[-1]] = a:value +endfunction + +function! s:_put_array(dict, key, value) abort + let keys = split(a:key, '\.') + + let ref = a:dict + for key in keys[ : -2] + let ref[key] = get(ref, key, {}) + + if type(ref[key]) == type([]) + let ref = ref[key][-1] + else + let ref = ref[key] + endif + endfor + + let ref[keys[-1]] = get(ref, keys[-1], []) + a:value +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo +" vim:set et ts=2 sts=2 sw=2 tw=0: diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle/autoload.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle/autoload.vim new file mode 100644 index 0000000..fc0e7f0 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle/autoload.vim @@ -0,0 +1,275 @@ +"============================================================================= +" FILE: autoload.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +function! neobundle#autoload#init() abort "{{{ + let s:active_auto_source = 0 + let s:loaded_path = 0 + + augroup neobundle + autocmd FileType * + \ call s:on_filetype() + autocmd FuncUndefined * + \ call s:on_function() + autocmd InsertEnter * + \ call s:on_insert() + augroup END + + if has('patch-7.4.414') + autocmd neobundle CmdUndefined * + \ call s:on_command_prefix() + endif + + augroup neobundle-path + autocmd! + augroup END + for event in [ + \ 'BufRead', 'BufCreate', 'BufEnter', + \ 'BufWinEnter', 'BufNew', 'VimEnter', 'BufNewFile' + \ ] + execute 'autocmd neobundle-path' event + \ "* call s:on_path(expand(''), ".string(event) . ")" + endfor + + augroup neobundle-focus + autocmd! + autocmd CursorHold * if s:active_auto_source + \ | call s:source_focus() + \ | endif + autocmd FocusLost * let s:active_auto_source = 1 | call s:source_focus() + autocmd FocusGained * let s:active_auto_source = 0 + augroup END +endfunction"}}} + +function! neobundle#autoload#_command(command, name, args, bang, line1, line2) abort "{{{ + call neobundle#config#source(a:name) + + if !exists(':' . a:command) + call neobundle#util#print_error( + \ printf('command %s is not found.', a:command)) + return + endif + + let range = (a:line1 == a:line2) ? '' : + \ (a:line1==line("'<") && a:line2==line("'>")) ? + \ "'<,'>" : a:line1.",".a:line2 + + try + execute range.a:command.a:bang a:args + catch /^Vim\%((\a\+)\)\=:E481/ + " E481: No range allowed + execute a:command.a:bang a:args + endtry +endfunction"}}} + +function! neobundle#autoload#_command_dummy_complete(arglead, cmdline, cursorpos) abort "{{{ + " Load plugins + let command = tolower(matchstr(a:cmdline, '\a\S*')) + + let bundles = filter(neobundle#config#get_autoload_bundles(), + \ "!empty(filter(map(copy(v:val.pre_cmd), 'tolower(v:val)'), + \ 'stridx(command, v:val) == 0'))") + call neobundle#config#source_bundles(bundles) + + " Print the candidates + call feedkeys("\", 'n') + return [''] +endfunction"}}} + +function! neobundle#autoload#_mapping(mapping, name, mode) abort "{{{ + let cnt = v:count > 0 ? v:count : '' + + let input = s:get_input() + + call neobundle#config#source(a:name) + + if a:mode ==# 'v' || a:mode ==# 'x' + call feedkeys('gv', 'n') + elseif a:mode ==# 'o' + " TODO: omap + " v:prevcount? + " Cancel waiting operator mode. + call feedkeys(v:operator, 'm') + endif + + call feedkeys(cnt, 'n') + + let mapping = a:mapping + while mapping =~ '<[[:alnum:]-]\+>' + let mapping = substitute(mapping, '\c', + \ get(g:, 'mapleader', '\'), 'g') + let mapping = substitute(mapping, '\c', + \ get(g:, 'maplocalleader', '\'), 'g') + let ctrl = matchstr(mapping, '<\zs[[:alnum:]-]\+\ze>') + execute 'let mapping = substitute( + \ mapping, "<' . ctrl . '>", "\<' . ctrl . '>", "")' + endwhile + call feedkeys(mapping . input, 'm') + + return '' +endfunction"}}} + +function! neobundle#autoload#_source(bundle_name) abort "{{{ + let bundles = filter(neobundle#config#get_autoload_bundles(), + \ "index(v:val.on_source, a:bundle_name) >= 0") + if !empty(bundles) + call neobundle#config#source_bundles(bundles) + endif +endfunction"}}} + +function! neobundle#autoload#_set_function_prefixes(bundles) abort "{{{ + for bundle in filter(copy(a:bundles), "empty(v:val.pre_func)") + let bundle.pre_func = + \ neobundle#util#uniq(map(split(globpath( + \ bundle.path, 'autoload/**/*.vim', 1), "\n"), + \ "substitute(matchstr( + \ neobundle#util#substitute_path_separator( + \ fnamemodify(v:val, ':r')), + \ '/autoload/\\zs.*$'), '/', '#', 'g').'#'")) + endfor +endfunction"}}} + +function! s:on_filetype() abort "{{{ + let bundles = filter(neobundle#config#get_autoload_bundles(), + \ "!empty(v:val.on_ft)") + for filetype in add(neobundle#util#get_filetypes(), 'all') + call neobundle#config#source_bundles(filter(copy(bundles)," + \ index(v:val.on_ft, filetype) >= 0")) + endfor +endfunction"}}} + +function! s:on_insert() abort "{{{ + let bundles = filter(neobundle#config#get_autoload_bundles(), + \ "v:val.on_i") + if !empty(bundles) + call neobundle#config#source_bundles(bundles) + doautocmd InsertEnter + endif +endfunction"}}} + +function! s:on_function() abort "{{{ + let function = expand('') + let function_prefix = substitute(function, '[^#]*$', '', '') + if function_prefix =~# '^neobundle#' + \ || function_prefix ==# 'vital#' + \ || has('vim_starting') + return + endif + + let bundles = neobundle#config#get_autoload_bundles() + call neobundle#autoload#_set_function_prefixes(bundles) + + let bundles = filter(bundles, + \ "index(v:val.pre_func, function_prefix) >= 0 + \ || (index(v:val.on_func, function) >= 0)") + call neobundle#config#source_bundles(bundles) +endfunction"}}} + +function! s:on_command_prefix() abort "{{{ + let command = tolower(expand('')) + + let bundles = filter(neobundle#config#get_autoload_bundles(), + \ "!empty(filter(map(copy(v:val.pre_cmd), 'tolower(v:val)'), + \ 'stridx(command, v:val) == 0'))") + call neobundle#config#source_bundles(bundles) +endfunction"}}} + +function! s:on_path(path, event) abort "{{{ + if a:path == '' + return + endif + + let path = a:path + " For ":edit ~". + if fnamemodify(path, ':t') ==# '~' + let path = '~' + endif + + let path = neobundle#util#expand(path) + let bundles = filter(neobundle#config#get_autoload_bundles(), + \ "len(filter(copy(v:val.on_path), + \ 'path =~? v:val')) > 0")") + if !empty(bundles) + call neobundle#config#source_bundles(bundles) + execute 'doautocmd' a:event + + if !s:loaded_path && has('vim_starting') + \ && neobundle#util#redir('filetype') =~# 'detection:ON' + " Force enable auto detection if path bundles are loaded + autocmd neobundle VimEnter * filetype detect + endif + let s:loaded_path = 1 + endif +endfunction"}}} + +function! s:source_focus() abort "{{{ + let bundles = neobundle#util#sort_by(filter( + \ neobundle#config#get_autoload_bundles(), + \ "v:val.focus > 0"), 'v:val.focus') + if empty(bundles) + augroup neobundle-focus + autocmd! + augroup END + return + endif + + call neobundle#config#source_bundles([bundles[0]]) + call feedkeys("g\", 'n') +endfunction"}}} + +function! s:get_input() abort "{{{ + let input = '' + let termstr = "" + + call feedkeys(termstr, 'n') + + let type_num = type(0) + while 1 + let char = getchar() + let input .= (type(char) == type_num) ? nr2char(char) : char + + let idx = stridx(input, termstr) + if idx >= 1 + let input = input[: idx - 1] + break + elseif idx == 0 + let input = '' + break + endif + endwhile + + return input +endfunction"}}} + +function! s:get_lazy_bundles() abort "{{{ + return filter(neobundle#config#get_neobundles(), + \ "!v:val.sourced && v:val.rtp != '' && v:val.lazy") +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle/cache.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle/cache.vim new file mode 100644 index 0000000..d04ae6f --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle/cache.vim @@ -0,0 +1,79 @@ +" Utilities for output cache. + +let s:save_cpo = &cpo +set cpo&vim + +function! neobundle#cache#getfilename(cache_dir, filename) abort + return s:_encode_name(a:cache_dir, a:filename) +endfunction + +function! neobundle#cache#filereadable(cache_dir, filename) abort + let cache_name = s:_encode_name(a:cache_dir, a:filename) + return filereadable(cache_name) +endfunction + +function! neobundle#cache#readfile(cache_dir, filename) abort + let cache_name = s:_encode_name(a:cache_dir, a:filename) + return filereadable(cache_name) ? readfile(cache_name) : [] +endfunction + +function! neobundle#cache#writefile(cache_dir, filename, list) abort + let cache_name = s:_encode_name(a:cache_dir, a:filename) + + call writefile(a:list, cache_name) +endfunction + +function! neobundle#cache#deletefile(cache_dir, filename) abort + let cache_name = s:_encode_name(a:cache_dir, a:filename) + return delete(cache_name) +endfunction + +function! s:_encode_name(cache_dir, filename) abort + " Check cache directory. + if !isdirectory(a:cache_dir) + call mkdir(a:cache_dir, 'p') + endif + let cache_dir = a:cache_dir + if cache_dir !~ '/$' + let cache_dir .= '/' + endif + + return cache_dir . s:_create_hash(cache_dir, a:filename) +endfunction + +function! neobundle#cache#check_old_cache(cache_dir, filename) abort + " Check old cache file. + let cache_name = s:_encode_name(a:cache_dir, a:filename) + let ret = getftime(cache_name) == -1 + \ || getftime(cache_name) <= getftime(a:filename) + if ret && filereadable(cache_name) + " Delete old cache. + call delete(cache_name) + endif + + return ret +endfunction + +function! s:_create_hash(dir, str) abort + if len(a:dir) + len(a:str) < 150 + let hash = substitute(substitute( + \ a:str, ':', '=-', 'g'), '[/\\]', '=+', 'g') + elseif exists('*sha256') + let hash = sha256(a:str) + else + " Use simple hash. + let sum = 0 + for i in range(len(a:str)) + let sum += char2nr(a:str[i]) * (i + 1) + endfor + + let hash = printf('%x', sum) + endif + + return hash +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim:set et ts=2 sts=2 sw=2 tw=0: diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle/commands.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle/commands.vim new file mode 100644 index 0000000..01c3e1a --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle/commands.vim @@ -0,0 +1,757 @@ +"============================================================================= +" FILE: commands.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +" Version: 3.0, for Vim 7.2 +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +call neobundle#util#set_default( + \ 'g:neobundle#rm_command', + \ (neobundle#util#is_windows() ? 'rmdir /S /Q' : 'rm -rf'), + \ 'g:neobundle_rm_command') + +let s:vimrcs = [] + +function! neobundle#commands#install(bang, bundle_names) abort "{{{ + if neobundle#util#is_sudo() + call neobundle#util#print_error( + \ '"sudo vim" is detected. This feature is disabled.') + return + endif + + let bundle_names = split(a:bundle_names) + + let bundles = !a:bang ? + \ neobundle#get_force_not_installed_bundles(bundle_names) : + \ empty(bundle_names) ? + \ neobundle#config#get_enabled_bundles() : + \ neobundle#config#fuzzy_search(bundle_names) + + let reinstall_bundles = + \ neobundle#installer#get_reinstall_bundles(bundles) + if !empty(reinstall_bundles) + call neobundle#installer#reinstall(reinstall_bundles) + endif + + if empty(bundles) + call neobundle#installer#error( + \ 'Target bundles not found.') + call neobundle#installer#error( + \ 'You may have used the wrong bundle name,'. + \ ' or all of the bundles are already installed.') + return + endif + + call sort(bundles, 's:cmp_vimproc') + + call neobundle#installer#_load_install_info(bundles) + + call neobundle#installer#clear_log() + + call neobundle#installer#echomsg( + \ 'Update started: ' . + \ strftime('(%Y/%m/%d %H:%M:%S)')) + + let [installed, errored] = s:install(a:bang, bundles) + if !has('vim_starting') + redraw! + endif + + call neobundle#installer#update(installed) + + call neobundle#installer#echomsg( + \ neobundle#installer#get_updated_bundles_message(installed)) + + call neobundle#installer#echomsg( + \ neobundle#installer#get_errored_bundles_message(errored)) + + call neobundle#installer#echomsg( + \ 'Update done: ' . strftime('(%Y/%m/%d %H:%M:%S)')) +endfunction"}}} + +function! neobundle#commands#helptags(bundles) abort "{{{ + if neobundle#util#is_sudo() + call neobundle#util#print_error( + \ '"sudo vim" is detected. This feature is disabled.') + return + endif + + let help_dirs = filter(copy(a:bundles), 's:has_doc(v:val.rtp)') + + if !empty(help_dirs) + try + call s:update_tags() + if !has('vim_starting') + call neobundle#installer#echomsg( + \ 'Helptags: done. ' + \ .len(help_dirs).' bundles processed') + endif + catch + call neobundle#installer#error('Error generating helptags:') + call neobundle#installer#error(v:exception) + endtry + endif + + return help_dirs +endfunction"}}} + +function! neobundle#commands#check() abort "{{{ + if neobundle#installer#get_tags_info() !=# + \ sort(map(neobundle#config#get_enabled_bundles(), 'v:val.name')) + " Recache automatically. + NeoBundleDocs + endif + + let reinstall_bundles = neobundle#installer#get_reinstall_bundles( + \ neobundle#config#get_neobundles()) + if !empty(reinstall_bundles) + call neobundle#installer#reinstall(reinstall_bundles) + endif + + if !neobundle#exists_not_installed_bundles() + return + endif + + " Defer call during Vim startup. + " This is required for 'gui_running' and fixes issues otherwise. + if has('vim_starting') + autocmd neobundle VimEnter * NeoBundleCheck + else + echomsg 'Not installed bundles: ' + \ string(neobundle#get_not_installed_bundle_names()) + if confirm('Install bundles now?', "yes\nNo", 2) == 1 + call neobundle#commands#install(0, + \ join(neobundle#get_not_installed_bundle_names())) + endif + echo '' + endif +endfunction"}}} + +function! neobundle#commands#check_update(bundle_names) abort "{{{ + let bundle_names = split(a:bundle_names) + + " Set context. + let context = {} + let context.source__updated_bundles = [] + let context.source__processes = [] + let context.source__number = 0 + let context.source__bundles = empty(bundle_names) ? + \ neobundle#config#get_neobundles() : + \ neobundle#config#fuzzy_search(bundle_names) + + let context.source__max_bundles = + \ len(context.source__bundles) + let statusline_save = &l:statusline + try + while 1 + while context.source__number < context.source__max_bundles + \ && len(context.source__processes) < + \ g:neobundle#install_max_processes + + let bundle = context.source__bundles[context.source__number] + call s:check_update_init(bundle, context, 0) + call s:print_message( + \ neobundle#installer#get_progress_message(bundle, + \ context.source__number, + \ context.source__max_bundles)) + endwhile + + for process in context.source__processes + call s:check_update_process(context, process, 0) + endfor + + " Filter eof processes. + call filter(context.source__processes, '!v:val.eof') + + if empty(context.source__processes) + \ && context.source__number == context.source__max_bundles + break + endif + endwhile + finally + let &l:statusline = statusline_save + endtry + + let bundles = context.source__updated_bundles + redraw! + + if !empty(bundles) + echomsg 'Updates available bundles: ' + \ string(map(copy(bundles), 'v:val.name')) + echomsg ' ' + + for bundle in bundles + let cwd = getcwd() + try + call neobundle#util#cd(bundle.path) + + let type = neobundle#config#get_types(bundle.type) + let rev = neobundle#installer#get_revision_number(bundle) + let fetch_command = has_key(type, 'get_fetch_remote_command') ? + \ type.get_fetch_remote_command(bundle) : '' + let log_command = has_key(type, 'get_log_command') ? + \ type.get_log_command(bundle, bundle.remote_rev, rev) : '' + if log_command != '' + echomsg bundle.name + call neobundle#util#system(fetch_command) + for output in split(neobundle#util#system(log_command), '\n') + echomsg output + endfor + echomsg ' ' + endif + finally + call neobundle#util#cd(cwd) + endtry + endfor + + if confirm('Update bundles now?', "yes\nNo", 2) == 1 + call neobundle#commands#install(1, + \ join(map(copy(bundles), 'v:val.name'))) + endif + endif +endfunction"}}} + +function! neobundle#commands#clean(bang, ...) abort "{{{ + if neobundle#util#is_sudo() + call neobundle#util#print_error( + \ '"sudo vim" is detected. This feature is disabled.') + return + endif + + if a:0 == 0 + let all_dirs = filter(split(neobundle#util#substitute_path_separator( + \ globpath(neobundle#get_neobundle_dir(), '*', 1)), "\n"), + \ 'isdirectory(v:val)') + let bundle_dirs = map(copy(neobundle#config#get_enabled_bundles()), + \ "(v:val.script_type != '') ? + \ v:val.base . '/' . v:val.directory : v:val.path") + let x_dirs = filter(all_dirs, + \ "neobundle#config#is_disabled(fnamemodify(v:val, ':t')) + \ && index(bundle_dirs, v:val) < 0 && v:val !~ '/neobundle.vim$'") + else + let x_dirs = map(neobundle#config#search_simple(a:000), 'v:val.path') + if len(x_dirs) > len(a:000) + " Check bug. + call neobundle#util#print_error('Bug: x_dirs = %s but arguments is %s', + \ string(x_dirs), map(copy(a:000), 'v:val.path')) + return + endif + endif + + if empty(x_dirs) + let message = a:0 == 0 ? + \ 'All clean!' : + \ string(a:000) . ' is not found.' + call neobundle#installer#log(message) + return + end + + if !a:bang && !s:check_really_clean(x_dirs) + return + endif + + let cwd = getcwd() + try + " x_dirs may contain current directory. + call neobundle#util#cd(neobundle#get_neobundle_dir()) + + if !has('vim_starting') + redraw + endif + + for dir in x_dirs + call neobundle#util#rmdir(dir) + call neobundle#config#rmdir(dir) + endfor + + try + call s:update_tags() + catch + call neobundle#installer#error('Error generating helptags:') + call neobundle#installer#error(v:exception) + endtry + finally + call neobundle#util#cd(cwd) + endtry +endfunction"}}} + +function! neobundle#commands#reinstall(bundle_names) abort "{{{ + let bundles = neobundle#config#search_simple(split(a:bundle_names)) + + if empty(bundles) + call neobundle#installer#error( + \ 'Target bundles not found.') + call neobundle#installer#error( + \ 'You may have used the wrong bundle name.') + return + endif + + call neobundle#installer#reinstall(bundles) +endfunction"}}} + +function! neobundle#commands#gc(bundle_names) abort "{{{ + let bundle_names = split(a:bundle_names) + let number = 0 + let bundles = empty(bundle_names) ? + \ neobundle#config#get_enabled_bundles() : + \ neobundle#config#search_simple(bundle_names) + let max = len(bundles) + for bundle in bundles + + let number += 1 + + let type = neobundle#config#get_types(bundle.type) + if empty(type) || !has_key(type, 'get_gc_command') + continue + endif + + let cmd = type.get_gc_command(bundle) + + let cwd = getcwd() + try + " Cd to bundle path. + call neobundle#util#cd(bundle.path) + + redraw + call neobundle#util#redraw_echo( + \ printf('(%'.len(max).'d/%d): |%s| %s', + \ number, max, bundle.name, cmd)) + let result = neobundle#util#system(cmd) + redraw + call neobundle#util#redraw_echo(result) + let status = neobundle#util#get_last_status() + finally + call neobundle#util#cd(cwd) + endtry + + if status + call neobundle#installer#error(bundle.path) + call neobundle#installer#error(result) + endif + endfor +endfunction"}}} + +function! neobundle#commands#rollback(bundle_name) abort "{{{ + let bundle = get(neobundle#config#search_simple([a:bundle_name]), 0, {}) + if empty(bundle) || !isdirectory(bundle.path) + call neobundle#util#print_error(a:bundle_name . ' is not found.') + return + endif + + call neobundle#installer#_load_install_info([bundle]) + + if len(bundle.revisions) <= 1 + call neobundle#util#print_error('No revision information.') + return + endif + + let cnt = 1 + let selections = [] + let revisions = neobundle#util#sort_by( + \ items(bundle.revisions), 'v:val[0]') + for [date, revision] in revisions + call add(selections, cnt . strftime( + \ '. %Y/%D/%m %H:%M:%S ', date) . ' ' . revision) + let cnt += 1 + endfor + + let select = inputlist(['Select revision:'] + selections) + if select == '' + return + endif + + redraw + + let revision = revisions[select-1][1] + call neobundle#installer#log('[neobundle] ' . a:bundle_name . + \ ' rollbacked to ' . revision) + + let cwd = getcwd() + let revision_save = bundle.rev + try + let bundle.rev = revision + let type = neobundle#config#get_types(bundle.type) + if !has_key(type, 'get_revision_lock_command') + call neobundle#util#print_error( + \ a:bundle_name . ' is not supported this feature.') + return + endif + + let cmd = type.get_revision_lock_command(bundle) + + call neobundle#util#cd(bundle.path) + call neobundle#util#system(cmd) + finally + call neobundle#util#cd(cwd) + let bundle.rev = revision_save + endtry +endfunction"}}} + +function! neobundle#commands#list() abort "{{{ + call neobundle#util#redraw_echo('#: not sourced, X: not installed') + for bundle in neobundle#util#sort_by( + \ neobundle#config#get_neobundles(), 'tolower(v:val.name)') + echo (bundle.sourced ? ' ' : + \ neobundle#is_installed(bundle.name) ? '#' : 'X') + \ . ' ' . bundle.name + endfor +endfunction"}}} + +function! neobundle#commands#lock(name, rev) abort "{{{ + let bundle = neobundle#config#get(a:name) + if empty(bundle) + return + endif + + let bundle.install_rev = a:rev +endfunction"}}} + +function! neobundle#commands#remote_plugins() abort "{{{ + if !has('nvim') + return + endif + + " Load not loaded neovim remote plugins + call neobundle#config#source(map(filter( + \ neobundle#config#get_autoload_bundles(), + \ "isdirectory(v:val.rtp . '/rplugin')"), 'v:val.name')) + + UpdateRemotePlugins +endfunction"}}} + +function! neobundle#commands#source(names, ...) abort "{{{ + let is_force = get(a:000, 0, 1) + + let names = neobundle#util#convert2list(a:names) + if empty(names) + let bundles = [] + for bundle in neobundle#config#get_neobundles() + let bundles += neobundle#config#search([bundle.name]) + endfor + let names = neobundle#util#uniq(map(bundles, 'v:val.name')) + endif + + call neobundle#config#source(names, is_force) +endfunction "}}} + +function! neobundle#commands#complete_bundles(arglead, cmdline, cursorpos) abort "{{{ + return filter(map(neobundle#config#get_neobundles(), 'v:val.name'), + \ 'stridx(tolower(v:val), tolower(a:arglead)) >= 0') +endfunction"}}} + +function! neobundle#commands#complete_lazy_bundles(arglead, cmdline, cursorpos) abort "{{{ + return filter(map(filter(neobundle#config#get_neobundles(), + \ "!v:val.sourced && v:val.rtp != ''"), 'v:val.name'), + \ 'stridx(tolower(v:val), tolower(a:arglead)) == 0') +endfunction"}}} + +function! neobundle#commands#complete_deleted_bundles(arglead, cmdline, cursorpos) abort "{{{ + let bundle_dirs = map(copy(neobundle#config#get_neobundles()), 'v:val.path') + let all_dirs = split(neobundle#util#substitute_path_separator( + \ globpath(neobundle#get_neobundle_dir(), '*', 1)), "\n") + let x_dirs = filter(all_dirs, 'index(bundle_dirs, v:val) < 0') + + return filter(map(x_dirs, "fnamemodify(v:val, ':t')"), + \ 'stridx(v:val, a:arglead) == 0') +endfunction"}}} + +function! neobundle#commands#get_default_cache_file() abort "{{{ + return neobundle#get_rtp_dir() . '/cache' +endfunction"}}} + +function! neobundle#commands#get_cache_file() abort "{{{ + return get(g:, 'neobundle#cache_file', neobundle#commands#get_default_cache_file()) +endfunction"}}} + +function! neobundle#commands#save_cache() abort "{{{ + if !has('vim_starting') + " Ignore if loaded + return + endif + + let cache = neobundle#commands#get_cache_file() + + " Set function prefixes before save cache + call neobundle#autoload#_set_function_prefixes( + \ neobundle#config#get_autoload_bundles()) + + let bundles = neobundle#config#tsort( + \ deepcopy(neobundle#config#get_neobundles())) + for bundle in bundles + " Clear hooks. Because, VimL cannot save functions in JSON. + let bundle.hooks = {} + let bundle.sourced = 0 + endfor + + let current_vim = neobundle#util#redir('version') + + call writefile([neobundle#get_cache_version(), + \ v:progname, current_vim, string(s:vimrcs), + \ neobundle#util#vim2json(bundles)], cache) +endfunction"}}} +function! neobundle#commands#load_cache(vimrcs) abort "{{{ + let s:vimrcs = a:vimrcs + + let cache = neobundle#commands#get_cache_file() + if !filereadable(cache) | return 1 | endif + + for vimrc in a:vimrcs + let vimrc_ftime = getftime(vimrc) + if vimrc_ftime != -1 && getftime(cache) < vimrc_ftime | return 1 | endif + endfor + + let current_vim = neobundle#util#redir('version') + + try + let list = readfile(cache) + let ver = list[0] + let prog = get(list, 1, '') + let vim = get(list, 2, '') + let vimrcs = get(list, 3, '') + + if len(list) != 5 + \ || ver !=# neobundle#get_cache_version() + \ || v:progname !=# prog + \ || current_vim !=# vim + \ || string(a:vimrcs) !=# vimrcs + call neobundle#commands#clear_cache() + return 1 + endif + + let bundles = neobundle#util#json2vim(list[4]) + + if type(bundles) != type([]) + call neobundle#commands#clear_cache() + return 1 + endif + + for bundle in bundles + call neobundle#config#add(bundle) + endfor + catch + call neobundle#util#print_error( + \ 'Error occurred while loading cache : ' . v:exception) + call neobundle#commands#clear_cache() + return 1 + endtry +endfunction"}}} +function! neobundle#commands#clear_cache() abort "{{{ + let cache = neobundle#commands#get_cache_file() + if !filereadable(cache) + return + endif + + call delete(cache) +endfunction"}}} + +function! s:print_message(msg) abort "{{{ + if !has('vim_starting') + let &l:statusline = a:msg + redrawstatus + else + call neobundle#util#redraw_echo(a:msg) + endif +endfunction"}}} + +function! s:install(bang, bundles) abort "{{{ + " Set context. + let context = {} + let context.source__bang = a:bang + let context.source__synced_bundles = [] + let context.source__errored_bundles = [] + let context.source__processes = [] + let context.source__number = 0 + let context.source__bundles = a:bundles + let context.source__max_bundles = + \ len(context.source__bundles) + + let statusline_save = &l:statusline + try + + while 1 + while context.source__number < context.source__max_bundles + \ && len(context.source__processes) < + \ g:neobundle#install_max_processes + + let bundle = context.source__bundles[context.source__number] + call neobundle#installer#sync( + \ context.source__bundles[context.source__number], + \ context, 0) + call s:print_message( + \ neobundle#installer#get_progress_message(bundle, + \ context.source__number, + \ context.source__max_bundles)) + endwhile + + for process in context.source__processes + call neobundle#installer#check_output(context, process, 0) + endfor + + " Filter eof processes. + call filter(context.source__processes, '!v:val.eof') + + if empty(context.source__processes) + \ && context.source__number == context.source__max_bundles + break + endif + endwhile + finally + let &l:statusline = statusline_save + endtry + + return [context.source__synced_bundles, + \ context.source__errored_bundles] +endfunction"}}} + +function! s:check_update_init(bundle, context, is_unite) abort "{{{ + let a:context.source__number += 1 + + let num = a:context.source__number + let max = a:context.source__max_bundles + + let type = neobundle#config#get_types(a:bundle.type) + let cmd = has_key(type, 'get_revision_remote_command') ? + \ type.get_revision_remote_command(a:bundle) : '' + if cmd == '' || !isdirectory(a:bundle.path) + return + endif + + let message = printf('(%'.len(max).'d/%d): |%s| %s', + \ num, max, a:bundle.name, cmd) + + call neobundle#installer#log(message, a:is_unite) + + let cwd = getcwd() + try + " Cd to bundle path. + call neobundle#util#cd(a:bundle.path) + + let process = { + \ 'number' : num, + \ 'bundle' : a:bundle, + \ 'output' : '', + \ 'status' : -1, + \ 'eof' : 0, + \ 'start_time' : localtime(), + \ } + if neobundle#util#has_vimproc() + let process.proc = vimproc#pgroup_open(vimproc#util#iconv( + \ cmd, &encoding, 'char'), 0, 2) + + " Close handles. + call process.proc.stdin.close() + " call process.proc.stderr.close() + else + let process.output = neobundle#util#system(cmd) + let process.status = neobundle#util#get_last_status() + endif + finally + call neobundle#util#cd(cwd) + endtry + + call add(a:context.source__processes, process) +endfunction "}}} + +function! s:check_update_process(context, process, is_unite) abort "{{{ + if neobundle#util#has_vimproc() && has_key(a:process, 'proc') + let is_timeout = (localtime() - a:process.start_time) + \ >= a:process.bundle.install_process_timeout + let a:process.output .= vimproc#util#iconv( + \ a:process.proc.stdout.read(-1, 300), 'char', &encoding) + if !a:process.proc.stdout.eof && !is_timeout + return + endif + call a:process.proc.stdout.close() + + let status = a:process.proc.waitpid()[1] + else + let is_timeout = 0 + let status = a:process.status + endif + + let num = a:process.number + let max = a:context.source__max_bundles + let bundle = a:process.bundle + + let remote_rev = matchstr(a:process.output, '^\S\+') + + let revision_save = bundle.rev + try + " Get HEAD revision + let rev = neobundle#installer#get_revision_number(bundle) + finally + let bundle.rev = revision_save + let bundle.remote_rev = remote_rev + endtry + + if is_timeout || status + let message = printf('(%'.len(max).'d/%d): |%s| %s', + \ num, max, bundle.name, 'Error') + call neobundle#installer#log(message, a:is_unite) + call neobundle#installer#error(bundle.path) + call neobundle#installer#error( + \ (is_timeout ? 'Process timeout.' : + \ split(a:process.output, '\n'))) + elseif remote_rev != '' && remote_rev !=# rev + call add(a:context.source__updated_bundles, + \ bundle) + endif + + let a:process.eof = 1 +endfunction"}}} + +function! s:check_really_clean(dirs) abort "{{{ + echo join(a:dirs, "\n") + + return input('Are you sure you want to remove ' + \ .len(a:dirs).' bundles? [y/n] : ') =~? 'y' +endfunction"}}} + +function! s:update_tags() abort "{{{ + let enabled = neobundle#config#get_enabled_bundles() + let bundles = [{ 'rtp' : neobundle#get_runtime_dir()}] + enabled + call neobundle#util#copy_bundle_files(bundles, 'doc') + call neobundle#util#writefile('tags_info', sort(map(enabled, 'v:val.name'))) + silent execute 'helptags' fnameescape(neobundle#get_tags_dir()) +endfunction"}}} + +function! s:has_doc(path) abort "{{{ + return a:path != '' && + \ isdirectory(a:path.'/doc') + \ && (!filereadable(a:path.'/doc/tags') + \ || filewritable(a:path.'/doc/tags')) + \ && (!filereadable(a:path.'/doc/tags-??') + \ || filewritable(a:path.'/doc/tags-??')) + \ && (glob(a:path.'/doc/*.txt') != '' + \ || glob(a:path.'/doc/*.??x') != '') +endfunction"}}} + +" Vimproc is first. +function! s:cmp_vimproc(a, b) abort "{{{ + return !(a:a.name ==# 'vimproc' || a:a.name ==# 'vimproc.vim') +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle/config.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle/config.vim new file mode 100644 index 0000000..28b629b --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle/config.vim @@ -0,0 +1,761 @@ +"============================================================================= +" FILE: config.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +if !exists('s:neobundles') + let s:within_block = 0 + let s:lazy_rtp_bundles = [] + let s:neobundles = {} + let neobundle#tapped = {} +endif + +function! neobundle#config#init() abort "{{{ + if neobundle#config#within_block() + call neobundle#util#print_error( + \ 'neobundle#begin()/neobundle#end() usage is invalid.') + call neobundle#util#print_error( + \ 'Please check your .vimrc.') + return + endif + + augroup neobundle + autocmd VimEnter * call s:on_vim_enter() + augroup END + + call s:filetype_off() + + let s:within_block = 1 + let s:lazy_rtp_bundles = [] + + " Load extra bundles configuration. + call neobundle#config#load_extra_bundles() +endfunction"}}} +function! neobundle#config#append() abort "{{{ + if neobundle#config#within_block() + call neobundle#util#print_error( + \ 'neobundle#begin()/neobundle#end() usage is invalid.') + call neobundle#util#print_error( + \ 'Please check your .vimrc.') + return + endif + + if neobundle#get_rtp_dir() == '' + call neobundle#util#print_error( + \ 'You must call neobundle#begin() before.') + call neobundle#util#print_error( + \ 'Please check your .vimrc.') + return + endif + + call s:filetype_off() + + let s:within_block = 1 + let s:lazy_rtp_bundles = [] +endfunction"}}} +function! neobundle#config#final() abort "{{{ + if !neobundle#config#within_block() + call neobundle#util#print_error( + \ 'neobundle#begin()/neobundle#end() usage is invalid.') + call neobundle#util#print_error( + \ 'Please check your .vimrc.') + return + endif + + " Join to the tail in runtimepath. + let rtps = neobundle#util#split_rtp(&runtimepath) + let index = index(rtps, neobundle#get_rtp_dir()) + if index < 0 + call neobundle#util#print_error( + \ 'Invalid runtimepath is detected.') + call neobundle#util#print_error( + \ 'Please check your .vimrc.') + return + endif + for bundle in filter(s:lazy_rtp_bundles, + \ 'isdirectory(v:val.rtp) && !v:val.disabled') + let bundle.sourced = 1 + call insert(rtps, bundle.rtp, index) + let index += 1 + + if isdirectory(bundle.rtp.'/after') + call add(rtps, s:get_rtp_after(bundle)) + endif + endfor + let &runtimepath = neobundle#util#join_rtp(rtps, &runtimepath, '') + + call neobundle#call_hook('on_source', s:lazy_rtp_bundles) + + let s:within_block = 0 + let s:lazy_rtp_bundles = [] +endfunction"}}} +function! neobundle#config#within_block() abort "{{{ + return s:within_block +endfunction"}}} + +function! neobundle#config#get(name) abort "{{{ + return get(s:neobundles, a:name, {}) +endfunction"}}} + +function! neobundle#config#get_neobundles() abort "{{{ + return values(s:neobundles) +endfunction"}}} + +function! neobundle#config#get_enabled_bundles() abort "{{{ + return filter(values(s:neobundles), + \ "!v:val.disabled") +endfunction"}}} + +function! neobundle#config#get_autoload_bundles() abort "{{{ + return filter(values(s:neobundles), + \ "!v:val.sourced && v:val.lazy && !v:val.disabled") +endfunction"}}} + +function! neobundle#config#source_bundles(bundles) abort "{{{ + if !empty(a:bundles) + call neobundle#config#source(map(copy(a:bundles), + \ "type(v:val) == type({}) ? v:val.name : v:val")) + endif +endfunction"}}} + +function! neobundle#config#check_not_exists(names, ...) abort "{{{ + " For infinite loop. + let self = get(a:000, 0, []) + + let _ = map(neobundle#get_not_installed_bundles(a:names), 'v:val.name') + for bundle in map(filter(copy(a:names), + \ 'index(self, v:val) < 0 && has_key(s:neobundles, v:val)'), + \ 's:neobundles[v:val]') + call add(self, bundle.name) + + if !empty(bundle.depends) + let _ += neobundle#config#check_not_exists( + \ map(copy(bundle.depends), 'v:val.name'), self) + endif + endfor + + if len(_) > 1 + let _ = neobundle#util#uniq(_) + endif + + return _ +endfunction"}}} + +function! neobundle#config#source(names, ...) abort "{{{ + let is_force = get(a:000, 0, 1) + + let bundles = neobundle#config#search( + \ neobundle#util#convert2list(a:names)) + + let bundles = filter(bundles, "!v:val.disabled && !v:val.sourced") + if empty(bundles) + return + endif + + let filetype_before = neobundle#util#redir("autocmd FileType") + + let reset_ftplugin = 0 + for bundle in bundles + let bundle.sourced = 1 + let bundle.disabled = 0 + + if !empty(bundle.dummy_commands) + for command in bundle.dummy_commands + silent! execute 'delcommand' command + endfor + let bundle.dummy_commands = [] + endif + + if !empty(bundle.dummy_mappings) + for [mode, mapping] in bundle.dummy_mappings + silent! execute mode.'unmap' mapping + endfor + let bundle.dummy_mappings = [] + endif + + call neobundle#config#rtp_add(bundle) + + if exists('g:loaded_neobundle') || is_force + try + call s:on_source(bundle) + catch + call neobundle#util#print_error( + \ 'Uncaught error while sourcing "' . bundle.name . + \ '": '.v:exception . ' in ' . v:throwpoint) + endtry + endif + + call neobundle#autoload#_source(bundle.name) + + if !reset_ftplugin + let reset_ftplugin = s:is_reset_ftplugin(&filetype, bundle.rtp) + endif + endfor + + let filetype_after = neobundle#util#redir('autocmd FileType') + + if reset_ftplugin && &filetype != '' + if &verbose + call neobundle#util#print_error( + \ "Neobundle: resetting ftplugin, after loading bundles:" + \ .join(map(copy(bundles), 'v:val.name'), ", ")) + endif + call s:reset_ftplugin() + elseif filetype_before !=# filetype_after + if &verbose + call neobundle#util#print_error( + \ "Neobundle: FileType autocommand triggered by:" + \ .join(map(copy(bundles), 'v:val.name'), ", ")) + endif + execute 'doautocmd FileType' &filetype + endif + + if exists('g:loaded_neobundle') + call neobundle#call_hook('on_post_source', bundles) + endif +endfunction"}}} + +function! neobundle#config#disable(...) abort "{{{ + let bundle_names = neobundle#config#search(a:000) + if empty(bundle_names) + call neobundle#util#print_error( + \ 'Disabled bundles ' . string(a:000) . ' are not found.') + return + endif + + for bundle in bundle_names + call neobundle#config#rtp_rm(bundle) + let bundle.refcnt -= 1 + + if bundle.refcnt <= 0 + if bundle.sourced + call neobundle#util#print_error( + \ bundle.name . ' is already sourced. Cannot be disabled.') + continue + endif + + let bundle.disabled = 1 + endif + endfor +endfunction"}}} + +function! neobundle#config#is_disabled(name) abort "{{{ + return get(neobundle#config#get(a:name), 'disabled', 1) +endfunction"}}} + +function! neobundle#config#is_sourced(name) abort "{{{ + return get(neobundle#config#get(a:name), 'sourced', 0) +endfunction"}}} + +function! neobundle#config#is_installed(name) abort "{{{ + return isdirectory(get(neobundle#config#get(a:name), 'path', '')) +endfunction"}}} + +function! neobundle#config#rm(bundle) abort "{{{ + call neobundle#config#rtp_rm(a:bundle) + call remove(s:neobundles, a:bundle.name) +endfunction"}}} +function! neobundle#config#rmdir(path) abort "{{{ + for bundle in filter(neobundle#config#get_neobundles(), + \ 'v:val.path ==# a:path') + call neobundle#config#rm(bundle) + endfor +endfunction"}}} + +function! neobundle#config#get_types(...) abort "{{{ + let type = get(a:000, 0, '') + + if type ==# 'git' + if !exists('s:neobundle_type_git') + let s:neobundle_type_git = neobundle#types#git#define() + endif + + return s:neobundle_type_git + endif + + if !exists('s:neobundle_types') + " Load neobundle types. + let s:neobundle_types = [] + for list in map(split(globpath(&runtimepath, + \ 'autoload/neobundle/types/*.vim', 1), '\n'), + \ "neobundle#util#convert2list( + \ neobundle#types#{fnamemodify(v:val, ':t:r')}#define())") + let s:neobundle_types += list + endfor + + let s:neobundle_types = neobundle#util#uniq( + \ s:neobundle_types, 'v:val.name') + endif + + return (type == '') ? s:neobundle_types : + \ get(filter(copy(s:neobundle_types), 'v:val.name ==# type'), 0, {}) +endfunction"}}} + +function! neobundle#config#rtp_rm_all_bundles() abort "{{{ + call filter(values(s:neobundles), 'neobundle#config#rtp_rm(v:val)') +endfunction"}}} + +function! neobundle#config#rtp_rm(bundle) abort "{{{ + execute 'set rtp-='.fnameescape(a:bundle.rtp) + if isdirectory(a:bundle.rtp.'/after') + execute 'set rtp-='.s:get_rtp_after(a:bundle) + endif + + " Remove from lazy runtimepath + call filter(s:lazy_rtp_bundles, "v:val.name !=# a:bundle.name") +endfunction"}}} + +function! neobundle#config#rtp_add(bundle) abort "{{{ + if has_key(s:neobundles, a:bundle.name) + call neobundle#config#rtp_rm(s:neobundles[a:bundle.name]) + endif + + if s:within_block && !a:bundle.force + " Add rtp lazily. + call add(s:lazy_rtp_bundles, a:bundle) + return + endif + + let rtp = a:bundle.rtp + if isdirectory(rtp) + " Join to the tail in runtimepath. + let rtps = neobundle#util#split_rtp(&runtimepath) + let &runtimepath = neobundle#util#join_rtp( + \ insert(rtps, rtp, index(rtps, neobundle#get_rtp_dir())), + \ &runtimepath, rtp) + endif + if isdirectory(rtp.'/after') + execute 'set rtp+='.s:get_rtp_after(a:bundle) + endif + let a:bundle.sourced = 1 + + call neobundle#call_hook('on_source', a:bundle) +endfunction"}}} + +function! neobundle#config#search(bundle_names, ...) abort "{{{ + " For infinite loop. + let self = get(a:000, 0, []) + + let bundle_names = filter(copy(a:bundle_names), 'index(self, v:val) < 0') + if empty(bundle_names) + return [] + endif + + let _ = [] + let bundles = len(bundle_names) != 1 ? + \ filter(neobundle#config#get_neobundles(), + \ 'index(a:bundle_names, v:val.name) >= 0') : + \ has_key(s:neobundles, bundle_names[0]) ? + \ [s:neobundles[bundle_names[0]]] : [] + for bundle in bundles + call add(self, bundle.name) + + if !empty(bundle.depends) + let _ += neobundle#config#search( + \ map(copy(bundle.depends), 'v:val.name'), self) + endif + call add(_, bundle) + endfor + + if len(_) > 1 + let _ = neobundle#util#uniq(_) + endif + + return _ +endfunction"}}} + +function! neobundle#config#search_simple(bundle_names) abort "{{{ + return filter(neobundle#config#get_neobundles(), + \ 'index(a:bundle_names, v:val.name) >= 0') +endfunction"}}} + +function! neobundle#config#fuzzy_search(bundle_names) abort "{{{ + let bundles = [] + for name in a:bundle_names + let bundles += filter(neobundle#config#get_neobundles(), + \ 'stridx(v:val.name, name) >= 0') + endfor + + let _ = [] + for bundle in bundles + if !empty(bundle.depends) + let _ += neobundle#config#search( + \ map(copy(bundle.depends), 'v:val.name')) + endif + call add(_, bundle) + endfor + + if len(_) > 1 + let _ = neobundle#util#uniq(_) + endif + + return _ +endfunction"}}} + +function! neobundle#config#load_extra_bundles() abort "{{{ + let path = neobundle#get_neobundle_dir() . '/extra_bundles.vim' + + if filereadable(path) + execute 'source' fnameescape(path) + endif +endfunction"}}} + +function! neobundle#config#save_direct(arg) abort "{{{ + if neobundle#util#is_sudo() + call neobundle#util#print_error( + \ '"sudo vim" is detected. This feature is disabled.') + return + endif + + let path = neobundle#get_neobundle_dir() . '/extra_bundles.vim' + let bundles = filereadable(path) ? readfile(path) : [] + call writefile(add(bundles, 'NeoBundle ' . a:arg), path) +endfunction"}}} + +function! neobundle#config#set(name, dict) abort "{{{ + let bundle = neobundle#config#get(a:name) + if empty(bundle) + call neobundle#util#print_error( + \ 'Plugin name "' . a:name . '" is not defined.') + return + endif + if bundle.sourced + return + endif + if !neobundle#config#within_block() + call neobundle#util#print_error( + \ 'You must call neobundle#config() ' + \ .'within neobundle#begin()/neobundle#end() block.') + return + endif + + call neobundle#config#add( + \ neobundle#init#_bundle(extend(bundle, a:dict))) +endfunction"}}} + +function! neobundle#config#add(bundle) abort "{{{ + if empty(a:bundle) + return + endif + + let bundle = a:bundle + + let prev_bundle = get(s:neobundles, bundle.name, {}) + if !empty(prev_bundle) && prev_bundle.lazy != bundle.lazy + let bundle.lazy = 0 + endif + + if !empty(bundle.depends) + call s:add_depends(bundle) + endif + + if !empty(prev_bundle) + if prev_bundle.sourced + return + endif + + call neobundle#config#rtp_rm(prev_bundle) + endif + let s:neobundles[bundle.name] = bundle + + if bundle.disabled + " Ignore load. + return + endif + + if !bundle.lazy && bundle.rtp != '' + if !has('vim_starting') + " Load automatically. + call neobundle#config#source(bundle.name, bundle.force) + else + call neobundle#config#rtp_add(bundle) + + if bundle.force + execute 'runtime!' bundle.rtp . '/plugin/**/*.vim' + endif + endif + elseif bundle.lazy && !bundle.sourced + if !empty(bundle.on_cmd) + call s:add_dummy_commands(bundle) + endif + + if !empty(bundle.on_map) + call s:add_dummy_mappings(bundle) + endif + endif +endfunction"}}} + +function! neobundle#config#tsort(bundles) abort "{{{ + let sorted = [] + let mark = {} + for target in a:bundles + call s:tsort_impl(target, a:bundles, mark, sorted) + endfor + + return sorted +endfunction"}}} + +function! neobundle#config#get_lazy_rtp_bundles() abort "{{{ + return s:lazy_rtp_bundles +endfunction"}}} + +function! neobundle#config#check_commands(commands) abort "{{{ + " Environment check. + if type(a:commands) == type([]) + \ || type(a:commands) == type('') + let commands = a:commands + elseif neobundle#util#is_windows() && has_key(a:commands, 'windows') + let commands = a:commands.windows + elseif neobundle#util#is_mac() && has_key(a:commands, 'mac') + let commands = a:commands.mac + elseif neobundle#util#is_cygwin() && has_key(a:commands, 'cygwin') + let commands = a:commands.cygwin + elseif !neobundle#util#is_windows() && has_key(a:commands, 'unix') + let commands = a:commands.unix + elseif has_key(a:commands, 'others') + let commands = a:commands.others + else + " Invalid. + return 0 + endif + + for command in neobundle#util#convert2list(commands) + if !executable(command) + return 1 + endif + endfor +endfunction"}}} + +function! s:tsort_impl(target, bundles, mark, sorted) abort "{{{ + if has_key(a:mark, a:target.name) + return + endif + + let a:mark[a:target.name] = 1 + for depend in get(a:target, 'depends', []) + call s:tsort_impl(get(s:neobundles, depend.name, depend), + \ a:bundles, a:mark, a:sorted) + endfor + + call add(a:sorted, a:target) +endfunction"}}} + +function! s:on_vim_enter() abort "{{{ + if !empty(s:lazy_rtp_bundles) + call neobundle#util#print_error( + \ 'neobundle#begin() was called without calling ' . + \ 'neobundle#end() in .vimrc.') + " We're past the point of plugins being sourced, so don't bother + " trying to recover. + return + endif + + call neobundle#call_hook('on_post_source') +endfunction"}}} + +function! s:add_depends(bundle) abort "{{{ + " Add depends. + for depend in a:bundle.depends + let depend.lazy = a:bundle.lazy + + if !has_key(s:neobundles, depend.name) + call neobundle#config#add(depend) + else + let depend_bundle = s:neobundles[depend.name] + " Add reference count + let depend_bundle.refcnt += 1 + + if (a:bundle.sourced && !depend_bundle.sourced) || !a:bundle.lazy + " Load automatically. + call neobundle#config#source(depend.name, depend.force) + endif + endif + endfor +endfunction"}}} + +function! s:add_dummy_commands(bundle) abort "{{{ + let a:bundle.dummy_commands = [] + for command in map(copy(a:bundle.on_cmd), " + \ type(v:val) == type('') ? + \ { 'name' : v:val } : v:val + \") + + for name in neobundle#util#convert2list(command.name) + " Define dummy commands. + silent! execute 'command ' + \ . '-complete=customlist,neobundle#autoload#_command_dummy_complete' + \ . ' -bang -bar -range -nargs=*' name printf( + \ "call neobundle#autoload#_command(%s, %s, , + \ expand(''), expand(''), expand(''))", + \ string(name), string(a:bundle.name)) + + call add(a:bundle.dummy_commands, name) + endfor + endfor +endfunction"}}} +function! s:add_dummy_mappings(bundle) abort "{{{ + let a:bundle.dummy_mappings = [] + for [modes, mappings] in map(copy(a:bundle.on_map), " + \ type(v:val) == type([]) ? + \ [v:val[0], v:val[1:]] : ['nxo', [v:val]] + \ ") + if mappings ==# [''] + " Use plugin name. + let mappings = ['(' . a:bundle.normalized_name] + if stridx(a:bundle.normalized_name, '-') >= 0 + " The plugin mappings may use "_" instead of "-". + call add(mappings, '(' . + \ substitute(a:bundle.normalized_name, '-', '_', 'g')) + endif + endif + + for mapping in mappings + " Define dummy mappings. + for mode in filter(split(modes, '\zs'), + \ "index(['n', 'v', 'x', 'o', 'i', 'c'], v:val) >= 0") + let mapping_str = substitute(mapping, '<', '', 'g') + silent! execute mode.'noremap ' mapping printf( + \ (mode ==# 'c' ? "\=" : + \ (mode ==# 'i' ? "\:" : ":\")."call "). + \ "neobundle#autoload#_mapping(%s, %s, %s)", + \ string(mapping_str), string(a:bundle.name), string(mode)) + + call add(a:bundle.dummy_mappings, [mode, mapping]) + endfor + endfor + endfor +endfunction"}}} + +function! s:on_source(bundle) abort "{{{ + if a:bundle.verbose && a:bundle.lazy + redraw + echo 'source:' a:bundle.name + endif + + " Reload script files. + for directory in filter(['plugin', 'after/plugin'], + \ "isdirectory(a:bundle.rtp.'/'.v:val)") + for file in split(glob(a:bundle.rtp.'/'.directory.'/**/*.vim'), '\n') + " Note: "silent!" is required to ignore E122, E174 and E227. + " try/catching them aborts sourcing of the file. + " "unsilent" then displays any messages while sourcing. + execute 'silent! unsilent source' fnameescape(file) + endfor + endfor + + if !has('vim_starting') + if exists('#'.a:bundle.augroup.'#VimEnter') + execute 'doautocmd' a:bundle.augroup 'VimEnter' + endif + + if has('gui_running') && &term ==# 'builtin_gui' + \ && exists('#'.a:bundle.augroup.'#GUIEnter') + execute 'doautocmd' a:bundle.augroup 'GUIEnter' + endif + endif + + if a:bundle.verbose && a:bundle.lazy + redraw + echo 'sourced:' a:bundle.name + endif +endfunction"}}} + +function! s:clear_dummy(bundle) abort "{{{ +endfunction"}}} + +function! s:is_reset_ftplugin(filetype, rtp) abort "{{{ + for filetype in split(a:filetype, '\.') + for directory in ['ftplugin', 'indent', + \ 'after/ftplugin', 'after/indent'] + let base = a:rtp . '/' . directory + if filereadable(base.'/'.filetype.'.vim') || + \ (directory =~# 'ftplugin$' && + \ isdirectory(base . '/' . filetype) || + \ glob(base.'/'.filetype.'_*.vim') != '') + return 1 + endif + endfor + endfor + + return 0 +endfunction"}}} + +function! s:reset_ftplugin() abort "{{{ + let filetype_out = s:filetype_off() + + if filetype_out =~# 'detection:ON' + \ && filetype_out =~# 'plugin:ON' + \ && filetype_out =~# 'indent:ON' + silent! filetype plugin indent on + else + if filetype_out =~# 'detection:ON' + silent! filetype on + endif + + if filetype_out =~# 'plugin:ON' + silent! filetype plugin on + endif + + if filetype_out =~# 'indent:ON' + silent! filetype indent on + endif + endif + + if filetype_out =~# 'detection:ON' + filetype detect + endif + + " Reload filetype plugins. + let &l:filetype = &l:filetype + + " Recall FileType autocmd + execute 'doautocmd FileType' &filetype +endfunction"}}} + +function! s:filetype_off() abort "{{{ + let filetype_out = neobundle#util#redir('filetype') + + if filetype_out =~# 'plugin:ON' + \ || filetype_out =~# 'indent:ON' + filetype plugin indent off + endif + + if filetype_out =~# 'detection:ON' + filetype off + endif + + return filetype_out +endfunction"}}} + +function! s:get_rtp_after(bundle) abort "{{{ + return substitute( + \ fnameescape(a:bundle.rtp . '/after'), '//', '/', 'g') +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle/init.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle/init.vim new file mode 100644 index 0000000..fa5125f --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle/init.vim @@ -0,0 +1,300 @@ +"============================================================================= +" FILE: init.vim +" AUTHOR: Shougo Matsushita +" Copyright (C) 2010 http://github.com/gmarik +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +function! neobundle#init#_rc(path) abort "{{{ + let path = + \ neobundle#util#substitute_path_separator( + \ neobundle#util#expand(a:path)) + if path =~ '/$' + let path = path[: -2] + endif + + if path == '' + call neobundle#util#print_error( + \ 'neobundle#rc() argument is empty.') + return + endif + + call neobundle#set_neobundle_dir(path) + + " Join to the tail in runtimepath. + let rtp = neobundle#get_rtp_dir() + execute 'set rtp-='.fnameescape(rtp) + let rtps = neobundle#util#split_rtp(&runtimepath) + let n = index(rtps, $VIMRUNTIME) + if n < 0 + call neobundle#util#print_error( + \ 'Invalid runtimepath is detected.') + call neobundle#util#print_error( + \ 'Please check your .vimrc.') + return + endif + let &runtimepath = neobundle#util#join_rtp( + \ insert(rtps, rtp, n-1), &runtimepath, rtp) + + augroup neobundle + autocmd! + augroup END + + call neobundle#config#init() + call neobundle#autoload#init() +endfunction"}}} + +function! neobundle#init#_bundle(bundle) abort "{{{ + if (!has_key(a:bundle, 'type') && get(a:bundle, 'local', 0)) + \ || get(a:bundle, 'type', '') ==# 'nosync' + " Default type. + let a:bundle.type = 'none' + endif + if !has_key(a:bundle, 'type') + call neobundle#installer#error( + \ printf('Failed parse name "%s" and args %s', + \ a:bundle.orig_name, string(a:bundle.orig_opts))) + return {} + endif + + let bundle = { + \ 'uri' : '', + \ 'script_type' : '', + \ 'rev' : '', + \ 'rtp' : '', + \ 'depends' : [], + \ 'fetch' : 0, + \ 'force' : 0, + \ 'gui' : 0, + \ 'terminal' : 0, + \ 'autoload' : {}, + \ 'hooks' : {}, + \ 'external_commands' : {}, + \ 'build_commands': {}, + \ 'description' : '', + \ 'dummy_commands' : [], + \ 'dummy_mappings' : [], + \ 'sourced' : 0, + \ 'disabled' : 0, + \ 'local' : 0, + \ 'focus' : 0, + \ 'verbose' : 0, + \ 'orig_name' : '', + \ 'vim_version' : '', + \ 'orig_opts' : {}, + \ 'base' : neobundle#get_neobundle_dir(), + \ 'install_rev' : '', + \ 'install_process_timeout' + \ : g:neobundle#install_process_timeout, + \ 'refcnt' : 1, + \ 'frozen' : 0, + \ 'on_i' : 0, + \ 'on_ft' : [], + \ 'on_cmd' : [], + \ 'on_func' : [], + \ 'on_map' : [], + \ 'on_path' : [], + \ 'on_source' : [], + \ 'pre_cmd' : [], + \ 'pre_func' : [], + \ } + call extend(bundle, a:bundle) + + if !has_key(bundle, 'name') + let bundle.name = neobundle#util#name_conversion(bundle.orig_name) + endif + + if !has_key(bundle, 'normalized_name') + let bundle.normalized_name = substitute( + \ fnamemodify(bundle.name, ':r'), + \ '\c^vim[_-]\|[_-]vim$', '', 'g') + endif + if !has_key(bundle.orig_opts, 'name') && + \ g:neobundle#enable_name_conversion + " Use normalized name. + let bundle.name = bundle.normalized_name + endif + + if !has_key(bundle, 'directory') + let bundle.directory = bundle.name + + if bundle.rev != '' + let bundle.directory .= '_' . substitute(bundle.rev, + \ '[^[:alnum:]_-]', '_', 'g') + endif + endif + + if bundle.base[0] == '~' + let bundle.base = neobundle#util#expand(bundle.base) + endif + if bundle.base[-1] == '/' || bundle.base[-1] == '\' + " Chomp. + let bundle.base = bundle.base[: -2] + endif + + let bundle.path = isdirectory(bundle.uri) ? + \ bundle.uri : bundle.base.'/'.bundle.directory + + " Check relative path. + if bundle.rtp !~ '^\%([~/]\|\a\+:\)' + let bundle.rtp = bundle.path.'/'.bundle.rtp + endif + if bundle.rtp[0] == '~' + let bundle.rtp = neobundle#util#expand(bundle.rtp) + endif + if bundle.rtp[-1] == '/' || bundle.rtp[-1] == '\' + " Chomp. + let bundle.rtp = bundle.rtp[: -2] + endif + if bundle.normalized_name ==# 'neobundle' || bundle.fetch + " Do not add runtimepath. + let bundle.rtp = '' + endif + + if bundle.script_type != '' + " Add script_type. + " Note: To check by neobundle#config#is_installed(). + let bundle.path .= '/' . bundle.script_type + endif + + if !has_key(bundle, 'augroup') + let bundle.augroup = bundle.normalized_name + endif + + " Convert old name + if has_key(bundle, 'stay_same') + let bundle.frozen = bundle.stay_same + endif + call s:init_lazy(bundle) + + " Parse depends. + if !empty(bundle.depends) + call s:init_depends(bundle) + endif + + if type(bundle.disabled) == type('') + let bundle.disabled = eval(bundle.disabled) + endif + + let bundle.disabled = bundle.disabled + \ || (bundle.gui && !has('gui_running')) + \ || (bundle.terminal && has('gui_running')) + \ || (bundle.vim_version != '' + \ && s:check_version(bundle.vim_version)) + \ || (!empty(bundle.external_commands) + \ && neobundle#config#check_commands(bundle.external_commands)) + + return bundle +endfunction"}}} + +function! s:init_lazy(bundle) abort "{{{ + let bundle = a:bundle + + " Auto set autoload keys. + for key in filter([ + \ 'filetypes', 'filename_patterns', + \ 'commands', 'functions', 'mappings', + \ 'insert', 'explorer', + \ 'command_prefix', 'function_prefixes', + \ ], 'has_key(bundle, v:val)') + let bundle.autoload[key] = bundle[key] + call remove(bundle, key) + endfor + + " Auto set on keys. + for [key, value] in items(filter({ + \ 'filetypes' : 'on_ft', + \ 'filename_patterns' : 'on_path', + \ 'commands' : 'on_cmd', + \ 'functions' : 'on_func', + \ 'mappings' : 'on_map', + \ 'insert' : 'on_i', + \ 'explorer' : 'on_path', + \ 'on_source' : 'on_source', + \ 'command_prefix' : 'pre_cmd', + \ 'function_prefixes' : 'pre_func', + \ }, 'has_key(bundle.autoload, v:key)')) + + let bundle[value] = (key ==# 'explorer' + \ && type(bundle.autoload[key]) == type(0) + \ && bundle.autoload[key] == 1) ? '.*' : bundle.autoload[key] + endfor + + if empty(bundle.pre_cmd) + let bundle.pre_cmd = substitute(bundle.normalized_name, '[_-]', '', 'g') + endif + + " Auto convert2list. + for key in filter([ + \ 'on_ft', 'on_path', 'on_cmd', + \ 'on_func', 'on_map', + \ 'on_source', 'pre_cmd', 'pre_func', + \ ], "type(bundle[v:val]) != type([]) + \") + let bundle[key] = [bundle[key]] + endfor + + if !has_key(bundle, 'lazy') + " Set lazy flag automatically + let bundle.lazy = bundle.on_i + \ || !empty(filter(['on_ft', 'on_path', 'on_cmd', + \ 'on_func', 'on_map', 'on_source'], + \ '!empty(bundle[v:val])')) + endif +endfunction"}}} + +function! s:init_depends(bundle) abort "{{{ + let bundle = a:bundle + let _ = [] + + for depend in neobundle#util#convert2list(bundle.depends) + if type(depend) == type('') + let depend = string(depend) + endif + + let depend_bundle = type(depend) == type({}) ? + \ depend : neobundle#parser#bundle(depend, 1) + let depend_bundle.lazy = bundle.lazy + call add(_, depend_bundle) + + unlet depend + endfor + + let bundle.depends = _ +endfunction"}}} + +function! s:check_version(min_version) abort "{{{ + let versions = split(a:min_version, '\.') + let major = get(versions, 0, 0) + let minor = get(versions, 1, 0) + let patch = get(versions, 2, 0) + let min_version = major * 100 + minor + return v:version < min_version || + \ (patch != 0 && v:version == min_version && !has('patch'.patch)) +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle/installer.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle/installer.vim new file mode 100644 index 0000000..41a70a9 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle/installer.vim @@ -0,0 +1,892 @@ +"============================================================================= +" FILE: installer.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +let s:install_info_version = '3.0' + +let s:log = [] +let s:updates_log = [] + +function! neobundle#installer#update(bundles) abort "{{{ + if neobundle#util#is_sudo() + call neobundle#util#print_error( + \ '"sudo vim" is detected. This feature is disabled.') + return + endif + + let all_bundles = neobundle#config#get_enabled_bundles() + + call neobundle#commands#helptags(all_bundles) + call s:reload(filter(copy(a:bundles), + \ "v:val.sourced && !v:val.disabled && v:val.rtp != ''")) + + call s:save_install_info(all_bundles) + + let lazy_bundles = filter(copy(all_bundles), 'v:val.lazy') + call neobundle#util#merge_bundle_files( + \ lazy_bundles, 'ftdetect') + call neobundle#util#merge_bundle_files( + \ lazy_bundles, 'after/ftdetect') + + " For neovim remote plugins + NeoBundleRemotePlugins +endfunction"}}} + +function! neobundle#installer#build(bundle) abort "{{{ + if !empty(a:bundle.build_commands) + \ && neobundle#config#check_commands(a:bundle.build_commands) + call neobundle#installer#log( + \ printf('|%s| ' . + \ 'Build dependencies not met. Skipped', a:bundle.name)) + return 0 + endif + + " Environment check. + let build = get(a:bundle, 'build', {}) + if type(build) == type('') + let cmd = build + elseif neobundle#util#is_windows() && has_key(build, 'windows') + let cmd = build.windows + elseif neobundle#util#is_mac() && has_key(build, 'mac') + let cmd = build.mac + elseif neobundle#util#is_cygwin() && has_key(build, 'cygwin') + let cmd = build.cygwin + elseif !neobundle#util#is_windows() && has_key(build, 'linux') + \ && !executable('gmake') + let cmd = build.linux + elseif !neobundle#util#is_windows() && has_key(build, 'unix') + let cmd = build.unix + elseif has_key(build, 'others') + let cmd = build.others + else + return 0 + endif + + call neobundle#installer#log('Building...') + + let cwd = getcwd() + try + call neobundle#util#cd(a:bundle.path) + + if !neobundle#util#has_vimproc() + let result = neobundle#util#system(cmd) + + if neobundle#util#get_last_status() + call neobundle#installer#error(result) + else + call neobundle#installer#log(result) + endif + else + call s:async_system(cmd) + endif + catch + " Build error from vimproc. + let message = (v:exception !~# '^Vim:')? + \ v:exception : v:exception . ' ' . v:throwpoint + call neobundle#installer#error(message) + + return 1 + finally + call neobundle#util#cd(cwd) + endtry + + return neobundle#util#get_last_status() +endfunction"}}} + +function! neobundle#installer#reinstall(bundles) abort "{{{ + let bundles = neobundle#util#uniq(a:bundles) + + for bundle in bundles + if bundle.type ==# 'none' + \ || bundle.local + \ || bundle.normalized_name ==# 'neobundle' + \ || (bundle.sourced && + \ index(['vimproc', 'unite'], bundle.normalized_name) >= 0) + call neobundle#installer#error( + \ printf('|%s| Cannot reinstall the plugin!', bundle.name)) + continue + endif + + " Reinstall. + call neobundle#installer#log( + \ printf('|%s| Reinstalling...', bundle.name)) + + " Save info. + let arg = copy(bundle.orig_arg) + + " Remove. + call neobundle#commands#clean(1, bundle.name) + + call call('neobundle#parser#bundle', [arg]) + endfor + + call s:save_install_info(neobundle#config#get_neobundles()) + + " Install. + call neobundle#commands#install(0, + \ join(map(copy(bundles), 'v:val.name'))) + + call neobundle#installer#update(bundles) +endfunction"}}} + +function! neobundle#installer#get_reinstall_bundles(bundles) abort "{{{ + call neobundle#installer#_load_install_info(a:bundles) + + let reinstall_bundles = filter(copy(a:bundles), + \ "neobundle#config#is_installed(v:val.name) + \ && v:val.type !=# 'none' + \ && !v:val.local + \ && v:val.path ==# v:val.installed_path + \ && v:val.uri !=# v:val.installed_uri") + if !empty(reinstall_bundles) + call neobundle#util#print_error( + \ 'Reinstall bundles are detected!') + + for bundle in reinstall_bundles + echomsg printf('%s: %s -> %s', + \ bundle.name, bundle.installed_uri, bundle.uri) + endfor + + let cwd = neobundle#util#substitute_path_separator(getcwd()) + let warning_bundles = map(filter(copy(reinstall_bundles), + \ 'v:val.path ==# cwd'), 'v:val.path') + if !empty(warning_bundles) + call neobundle#util#print_error( + \ 'Warning: current directory is the + \ reinstall bundles directory! ' . string(warning_bundles)) + endif + let ret = confirm('Reinstall bundles now?', "yes\nNo", 2) + redraw + if ret != 1 + return [] + endif + endif + + return reinstall_bundles +endfunction"}}} + +function! neobundle#installer#get_updated_bundles_message(bundles) abort "{{{ + let msg = '' + + let installed_bundles = filter(copy(a:bundles), + \ "v:val.old_rev == ''") + if !empty(installed_bundles) + let msg .= "\nInstalled bundles:\n". + \ join(map(copy(installed_bundles), + \ "' ' . v:val.name"), "\n") + endif + + let updated_bundles = filter(copy(a:bundles), + \ "v:val.old_rev != ''") + if !empty(updated_bundles) + let msg .= "\nUpdated bundles:\n". + \ join(map(updated_bundles, + \ "' ' . v:val.name . (v:val.commit_count == 0 ? '' + \ : printf('(%d change%s)', + \ v:val.commit_count, + \ (v:val.commit_count == 1 ? '' : 's'))) + \ . (v:val.uri =~ '^\\h\\w*://github.com/' ? \"\\n\" + \ . printf(' %s/compare/%s...%s', + \ substitute(substitute(v:val.uri, '\\.git$', '', ''), + \ '^\\h\\w*:', 'https:', ''), + \ v:val.old_rev, v:val.new_rev) : '')") + \ , "\n") + endif + + return msg +endfunction"}}} + +function! neobundle#installer#get_errored_bundles_message(bundles) abort "{{{ + if empty(a:bundles) + return '' + endif + + let msg = "\nError installing bundles:\n".join( + \ map(copy(a:bundles), "' ' . v:val.name"), "\n") + let msg .= "\n" + let msg .= "Please read the error message log with the :message command.\n" + + return msg +endfunction"}}} + +function! neobundle#installer#get_sync_command(bang, bundle, number, max) abort "{{{ + let type = neobundle#config#get_types(a:bundle.type) + if empty(type) + return ['E: Unknown Type', ''] + endif + + let is_directory = isdirectory(a:bundle.path) + + let cmd = type.get_sync_command(a:bundle) + + if cmd == '' + return ['', 'Not supported sync action.'] + elseif (is_directory && !a:bang + \ && a:bundle.install_rev ==# + \ neobundle#installer#get_revision_number(a:bundle)) + return ['', 'Already installed.'] + endif + + let message = printf('(%'.len(a:max).'d/%d): |%s| %s', + \ a:number, a:max, a:bundle.name, cmd) + + return [cmd, message] +endfunction"}}} + +function! neobundle#installer#get_revision_lock_command(bang, bundle, number, max) abort "{{{ + let type = neobundle#config#get_types(a:bundle.type) + if empty(type) + return ['E: Unknown Type', ''] + endif + + let cmd = type.get_revision_lock_command(a:bundle) + + if cmd == '' + return ['', ''] + endif + + return [cmd, ''] +endfunction"}}} + +function! neobundle#installer#get_revision_number(bundle) abort "{{{ + let cwd = getcwd() + let type = neobundle#config#get_types(a:bundle.type) + + if !isdirectory(a:bundle.path) + \ || !has_key(type, 'get_revision_number_command') + return '' + endif + + let cmd = type.get_revision_number_command(a:bundle) + if cmd == '' + return '' + endif + + try + call neobundle#util#cd(a:bundle.path) + + let rev = neobundle#util#system(cmd) + + if type.name ==# 'vba' || type.name ==# 'raw' + " If rev is ok, the output is the checksum followed by the filename + " separated by two spaces. + let pat = '^[0-9a-f]\+ ' . a:bundle.path . '/' . + \ fnamemodify(a:bundle.uri, ':t') . '$' + return (rev =~# pat) ? matchstr(rev, '^[0-9a-f]\+') : '' + else + " If rev contains spaces, it is error message + return (rev !~ '\s') ? rev : '' + endif + finally + call neobundle#util#cd(cwd) + endtry +endfunction"}}} + +function! s:get_commit_date(bundle) abort "{{{ + let cwd = getcwd() + try + let type = neobundle#config#get_types(a:bundle.type) + + if !isdirectory(a:bundle.path) || + \ !has_key(type, 'get_commit_date_command') + return 0 + endif + + call neobundle#util#cd(a:bundle.path) + + return neobundle#util#system( + \ type.get_commit_date_command(a:bundle)) + finally + call neobundle#util#cd(cwd) + endtry +endfunction"}}} + +function! neobundle#installer#get_updated_log_message(bundle, new_rev, old_rev) abort "{{{ + let cwd = getcwd() + try + let type = neobundle#config#get_types(a:bundle.type) + + call neobundle#util#cd(a:bundle.path) + + let log_command = has_key(type, 'get_log_command') ? + \ type.get_log_command(a:bundle, a:new_rev, a:old_rev) : '' + let log = (log_command != '' ? + \ neobundle#util#system(log_command) : '') + return log != '' ? log : + \ (a:old_rev == a:new_rev) ? '' + \ : printf('%s -> %s', a:old_rev, a:new_rev) + finally + call neobundle#util#cd(cwd) + endtry +endfunction"}}} + +function! neobundle#installer#sync(bundle, context, is_unite) abort "{{{ + let a:context.source__number += 1 + + let num = a:context.source__number + let max = a:context.source__max_bundles + + let before_one_day = localtime() - 60 * 60 * 24 + let before_one_week = localtime() - 60 * 60 * 24 * 7 + + if a:context.source__bang == 1 && + \ a:bundle.frozen + let [cmd, message] = ['', 'is frozen.'] + elseif a:context.source__bang == 1 && + \ a:bundle.uri ==# a:bundle.installed_uri && + \ a:bundle.updated_time < before_one_week + \ && a:bundle.checked_time >= before_one_day + let [cmd, message] = ['', 'Outdated plugin.'] + else + let [cmd, message] = + \ neobundle#installer#get_sync_command( + \ a:context.source__bang, a:bundle, + \ a:context.source__number, a:context.source__max_bundles) + endif + + if cmd == '' + " Skipped. + call neobundle#installer#log(s:get_skipped_message( + \ num, max, a:bundle, '', message), a:is_unite) + return + elseif cmd =~# '^E: ' + " Errored. + + call neobundle#installer#update_log( + \ printf('(%'.len(max).'d/%d): |%s| %s', + \ num, max, a:bundle.name, 'Error'), a:is_unite) + call neobundle#installer#error(cmd[3:]) + call add(a:context.source__errored_bundles, + \ a:bundle) + return + endif + + call neobundle#installer#log(message, a:is_unite) + + let cwd = getcwd() + try + let lang_save = $LANG + let $LANG = 'C' + + " Cd to bundle path. + call neobundle#util#cd(a:bundle.path) + + let rev = neobundle#installer#get_revision_number(a:bundle) + + let process = { + \ 'number' : num, + \ 'rev' : rev, + \ 'bundle' : a:bundle, + \ 'output' : '', + \ 'status' : -1, + \ 'eof' : 0, + \ 'start_time' : localtime(), + \ } + + if isdirectory(a:bundle.path) && !a:bundle.local + let rev_save = a:bundle.rev + try + " Force checkout HEAD revision. + " The repository may be checked out. + let a:bundle.rev = '' + + call neobundle#installer#lock_revision( + \ process, a:context, a:is_unite) + finally + let a:bundle.rev = rev_save + endtry + endif + + if has('nvim') && a:is_unite + " Use neovim async jobs + let process.proc = jobstart( + \ iconv(cmd, &encoding, 'char'), { + \ 'on_stdout' : function('s:job_handler'), + \ 'on_stderr' : function('s:job_handler'), + \ 'on_exit' : function('s:job_handler'), + \ }) + elseif neobundle#util#has_vimproc() + let process.proc = vimproc#pgroup_open(vimproc#util#iconv( + \ cmd, &encoding, 'char'), 0, 2) + + " Close handles. + call process.proc.stdin.close() + call process.proc.stderr.close() + else + let process.output = neobundle#util#system(cmd) + let process.status = neobundle#util#get_last_status() + endif + finally + let $LANG = lang_save + call neobundle#util#cd(cwd) + endtry + + call add(a:context.source__processes, process) +endfunction"}}} + +function! neobundle#installer#check_output(context, process, is_unite) abort "{{{ + if has('nvim') && a:is_unite && has_key(a:process, 'proc') + let is_timeout = (localtime() - a:process.start_time) + \ >= a:process.bundle.install_process_timeout + + if !has_key(s:job_info, a:process.proc) + return + endif + + let job = s:job_info[a:process.proc] + + if !job.eof && !is_timeout + let output = join(job.candidates[: -2], "\n") + if output != '' + let a:process.output .= output + call neobundle#util#redraw_echo(output) + endif + let job.candidates = job.candidates[-1:] + return + else + if is_timeout + call jobstop(a:process.proc) + endif + let output = join(job.candidates, "\n") + if output != '' + let a:process.output .= output + call neobundle#util#redraw_echo(output) + endif + let job.candidates = [] + endif + + let status = job.status + elseif neobundle#util#has_vimproc() && has_key(a:process, 'proc') + let is_timeout = (localtime() - a:process.start_time) + \ >= a:process.bundle.install_process_timeout + let output = vimproc#util#iconv( + \ a:process.proc.stdout.read(-1, 300), 'char', &encoding) + if output != '' + let a:process.output .= output + call neobundle#util#redraw_echo(output) + endif + if !a:process.proc.stdout.eof && !is_timeout + return + endif + call a:process.proc.stdout.close() + + let status = a:process.proc.waitpid()[1] + else + let is_timeout = 0 + let status = a:process.status + endif + + let num = a:process.number + let max = a:context.source__max_bundles + let bundle = a:process.bundle + + if bundle.rev != '' || !a:context.source__bang + " Restore revision. + let rev_save = bundle.rev + try + if !a:context.source__bang && bundle.rev == '' + " Checkout install_rev revision. + let bundle.rev = bundle.install_rev + endif + + call neobundle#installer#lock_revision( + \ a:process, a:context, a:is_unite) + finally + let bundle.rev = rev_save + endtry + endif + + let rev = neobundle#installer#get_revision_number(bundle) + + let updated_time = s:get_commit_date(bundle) + let bundle.checked_time = localtime() + + if is_timeout || status + let message = printf('(%'.len(max).'d/%d): |%s| %s', + \ num, max, bundle.name, 'Error') + call neobundle#installer#update_log(message, a:is_unite) + call neobundle#installer#error(bundle.path) + + call neobundle#installer#error( + \ (is_timeout ? 'Process timeout.' : + \ split(a:process.output, '\n'))) + + call add(a:context.source__errored_bundles, + \ bundle) + elseif a:process.rev ==# rev + if updated_time != 0 + let bundle.updated_time = updated_time + endif + + call neobundle#installer#log(s:get_skipped_message( + \ num, max, bundle, '', 'Same revision.'), a:is_unite) + else + call neobundle#installer#update_log( + \ printf('(%'.len(max).'d/%d): |%s| %s', + \ num, max, bundle.name, 'Updated'), a:is_unite) + if a:process.rev != '' + let log_messages = split( + \ neobundle#installer#get_updated_log_message( + \ bundle, rev, a:process.rev), '\n') + let bundle.commit_count = len(log_messages) + call call((!has('vim_starting') ? 'neobundle#installer#update_log' + \ : 'neobundle#installer#log'), [ + \ map(log_messages, "printf('|%s| ' . + \ substitute(v:val, '%', '%%', 'g'), bundle.name)"), + \ a:is_unite + \ ]) + else + let bundle.commit_count = 0 + endif + + if updated_time == 0 + let updated_time = bundle.checked_time + endif + let bundle.updated_time = updated_time + let bundle.installed_uri = bundle.uri + let bundle.revisions[updated_time] = rev + let bundle.old_rev = a:process.rev + let bundle.new_rev = rev + if neobundle#installer#build(bundle) + \ && confirm('Build failed. Uninstall "' + \ .bundle.name.'" now?', "yes\nNo", 2) == 1 + " Remove. + call neobundle#commands#clean(1, bundle.name) + else + call add(a:context.source__synced_bundles, bundle) + endif + endif + + let bundle.install_rev = rev + + let a:process.eof = 1 +endfunction"}}} + +function! neobundle#installer#lock_revision(process, context, is_unite) abort "{{{ + let num = a:process.number + let max = a:context.source__max_bundles + let bundle = a:process.bundle + + let bundle.new_rev = neobundle#installer#get_revision_number(bundle) + + let [cmd, message] = + \ neobundle#installer#get_revision_lock_command( + \ a:context.source__bang, bundle, num, max) + + if cmd == '' || bundle.new_rev ==# bundle.rev + " Skipped. + return 0 + elseif cmd =~# '^E: ' + " Errored. + call neobundle#installer#error(bundle.path) + call neobundle#installer#error(cmd[3:]) + return -1 + endif + + if bundle.rev != '' + call neobundle#installer#log( + \ printf('(%'.len(max).'d/%d): |%s| %s', + \ num, max, bundle.name, 'Locked'), a:is_unite) + + call neobundle#installer#log(message, a:is_unite) + endif + + let cwd = getcwd() + try + " Cd to bundle path. + call neobundle#util#cd(bundle.path) + + let result = neobundle#util#system(cmd) + let status = neobundle#util#get_last_status() + finally + call neobundle#util#cd(cwd) + endtry + + if status + call neobundle#installer#error(bundle.path) + call neobundle#installer#error(result) + return -1 + endif +endfunction"}}} + +function! neobundle#installer#get_release_revision(bundle, command) abort "{{{ + let cwd = getcwd() + let rev = '' + try + call neobundle#util#cd(a:bundle.path) + let rev = get(neobundle#util#sort_human( + \ split(neobundle#util#system(a:command), '\n')), -1, '') + finally + call neobundle#util#cd(cwd) + endtry + + return rev +endfunction"}}} + +function! s:save_install_info(bundles) abort "{{{ + let s:install_info = {} + for bundle in filter(copy(a:bundles), + \ "!v:val.local && has_key(v:val, 'updated_time')") + " Note: Don't save local repository. + let s:install_info[bundle.name] = { + \ 'checked_time' : bundle.checked_time, + \ 'updated_time' : bundle.updated_time, + \ 'installed_uri' : bundle.installed_uri, + \ 'installed_path' : bundle.path, + \ 'revisions' : bundle.revisions, + \ } + endfor + + call neobundle#util#writefile('install_info', + \ [s:install_info_version, string(s:install_info)]) + + " Save lock file + call s:save_lockfile(a:bundles) +endfunction"}}} + +function! neobundle#installer#_load_install_info(bundles) abort "{{{ + let install_info_path = + \ neobundle#get_neobundle_dir() . '/.neobundle/install_info' + if !exists('s:install_info') + call s:source_lockfile() + + let s:install_info = {} + + if filereadable(install_info_path) + try + let list = readfile(install_info_path) + let ver = list[0] + sandbox let s:install_info = eval(list[1]) + if ver !=# s:install_info_version + \ || type(s:install_info) != type({}) + let s:install_info = {} + endif + catch + endtry + endif + endif + + call map(a:bundles, "extend(v:val, get(s:install_info, v:val.name, { + \ 'checked_time' : localtime(), + \ 'updated_time' : localtime(), + \ 'installed_uri' : v:val.uri, + \ 'installed_path' : v:val.path, + \ 'revisions' : {}, + \}))") + + return s:install_info +endfunction"}}} + +function! s:get_skipped_message(number, max, bundle, prefix, message) abort "{{{ + let messages = [a:prefix . printf('(%'.len(a:max).'d/%d): |%s| %s', + \ a:number, a:max, a:bundle.name, 'Skipped')] + if a:message != '' + call add(messages, a:prefix . a:message) + endif + return messages +endfunction"}}} + +function! neobundle#installer#log(msg, ...) abort "{{{ + let msg = neobundle#util#convert2list(a:msg) + if empty(msg) + return + endif + call extend(s:log, msg) + + call s:append_log_file(msg) +endfunction"}}} + +function! neobundle#installer#update_log(msg, ...) abort "{{{ + let is_unite = get(a:000, 0, 0) + + if !(&filetype == 'unite' || is_unite) + call neobundle#util#redraw_echo(a:msg) + endif + + call neobundle#installer#log(a:msg) + + let s:updates_log += neobundle#util#convert2list(a:msg) +endfunction"}}} + +function! neobundle#installer#echomsg(msg) abort "{{{ + call neobundle#util#redraw_echomsg(a:msg) + + call neobundle#installer#log(a:msg) + + let s:updates_log += neobundle#util#convert2list(a:msg) +endfunction"}}} + +function! neobundle#installer#error(msg) abort "{{{ + let msgs = neobundle#util#convert2list(a:msg) + if empty(msgs) + return + endif + call extend(s:log, msgs) + call extend(s:updates_log, msgs) + + call neobundle#util#print_error(msgs) + call s:append_log_file(msgs) +endfunction"}}} + +function! s:append_log_file(msg) abort "{{{ + if g:neobundle#log_filename == '' + return + endif + + let msg = a:msg + " Appends to log file. + if filereadable(g:neobundle#log_filename) + let msg = readfile(g:neobundle#log_filename) + msg + endif + + let dir = fnamemodify(g:neobundle#log_filename, ':h') + if !isdirectory(dir) + call mkdir(dir, 'p') + endif + call writefile(msg, g:neobundle#log_filename) +endfunction"}}} + +function! neobundle#installer#get_log() abort "{{{ + return s:log +endfunction"}}} + +function! neobundle#installer#get_updates_log() abort "{{{ + return s:updates_log +endfunction"}}} + +function! neobundle#installer#clear_log() abort "{{{ + let s:log = [] + let s:updates_log = [] +endfunction"}}} + +function! neobundle#installer#get_progress_message(bundle, number, max) abort "{{{ + return printf('(%'.len(a:max).'d/%d) [%-20s] %s', + \ a:number, a:max, + \ repeat('=', (a:number*20/a:max)), a:bundle.name) +endfunction"}}} + +function! neobundle#installer#get_tags_info() abort "{{{ + let path = neobundle#get_neobundle_dir() . '/.neobundle/tags_info' + if !filereadable(path) + return [] + endif + + return readfile(path) +endfunction"}}} + +function! s:save_lockfile(bundles) abort "{{{ + let path = neobundle#get_neobundle_dir() . '/NeoBundle.lock' + let dir = fnamemodify(path, ':h') + if !isdirectory(dir) + call mkdir(dir, 'p') + endif + + return writefile(sort(map(filter(map(copy(a:bundles), + \ '[v:val.name, neobundle#installer#get_revision_number(v:val)]'), + \ "v:val[1] != '' && v:val[1] !~ '\s'"), + \ "printf('NeoBundleLock %s %s', + \ escape(v:val[0], ' \'), v:val[1])")), path) +endfunction"}}} + +function! s:source_lockfile() abort "{{{ + let path = neobundle#get_neobundle_dir() . '/NeoBundle.lock' + if filereadable(path) + execute 'source' fnameescape(path) + endif +endfunction"}}} + +function! s:reload(bundles) abort "{{{ + if empty(a:bundles) + return + endif + + call filter(copy(a:bundles), 'neobundle#config#rtp_add(v:val)') + + silent! runtime! ftdetect/**/*.vim + silent! runtime! after/ftdetect/**/*.vim + silent! runtime! plugin/**/*.vim + silent! runtime! after/plugin/**/*.vim + + " Call hooks. + call neobundle#call_hook('on_post_source', a:bundles) +endfunction"}}} + +let s:job_info = {} +function! s:job_handler(job_id, data, event) abort "{{{ + if !has_key(s:job_info, a:job_id) + let s:job_info[a:job_id] = { + \ 'candidates' : [], + \ 'eof' : 0, + \ 'status' : -1, + \ } + endif + + let job = s:job_info[a:job_id] + + if a:event ==# 'exit' + let job.eof = 1 + let job.status = a:data + return + endif + + let lines = a:data + + let candidates = job.candidates + if !empty(lines) && lines[0] != "\n" && !empty(job.candidates) + " Join to the previous line + let candidates[-1] .= lines[0] + call remove(lines, 0) + endif + + let candidates += map(lines, "iconv(v:val, 'char', &encoding)") +endfunction"}}} + +function! s:async_system(cmd) abort "{{{ + let proc = vimproc#pgroup_open(a:cmd) + + " Close handles. + call proc.stdin.close() + + while !proc.stdout.eof + if !proc.stderr.eof + " Print error. + call neobundle#installer#error(proc.stderr.read_lines(-1, 100)) + endif + + call neobundle#util#redraw_echo(proc.stdout.read_lines(-1, 100)) + endwhile + + if !proc.stderr.eof + " Print error. + call neobundle#installer#error(proc.stderr.read_lines(-1, 100)) + endif + + call proc.waitpid() +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle/metadata.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle/metadata.vim new file mode 100644 index 0000000..c93a89a --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle/metadata.vim @@ -0,0 +1,84 @@ +"============================================================================= +" FILE: metadata.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +let s:metadata = {} +let s:repository = + \ 'https://gist.githubusercontent.com/Shougo/' + \ . '028d6ae320cc8f354f88/raw/' + \ . '3b62ad42d39a4d3d4f236a45e00eb6b03ca23352/vim-pi.json' + +function! neobundle#metadata#get(...) abort "{{{ + if empty(s:metadata) + call s:load() + endif + return (a:0 == 0) ? copy(s:metadata) : get(s:metadata, a:1, {}) +endfunction"}}} + +function! neobundle#metadata#update() abort "{{{ + " Reload cache. + let cache_path = neobundle#get_neobundle_dir() . '/.neobundle/metadata.json' + + if filereadable(cache_path) + call delete(cache_path) + endif + + let cmd = neobundle#util#wget(s:repository, cache_path) + if cmd =~# '^E:' + call neobundle#util#print_error( + \ 'curl or wget command is not available!') + return + endif + + let result = neobundle#util#system(cmd) + + if neobundle#util#get_last_status() + call neobundle#util#print_error('Error occurred!') + call neobundle#util#print_error(cmd) + call neobundle#util#print_error(result) + elseif !filereadable(cache_path) + call neobundle#util#print_error('Temporary file was not created!') + endif +endfunction"}}} + +function! s:load() abort "{{{ + " Reload cache. + let cache_path = neobundle#get_neobundle_dir() . '/.neobundle/metadata.json' + + if !filereadable(cache_path) + call neobundle#metadata#update() + endif + + sandbox let s:metadata = eval(get(readfile(cache_path), 0, '{}')) + + return s:metadata +endfunction"}}} + + +let &cpo = s:save_cpo +unlet s:save_cpo + diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle/parser.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle/parser.vim new file mode 100644 index 0000000..1bcf6ff --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle/parser.vim @@ -0,0 +1,314 @@ +"============================================================================= +" FILE: parser.vim +" AUTHOR: Shougo Matsushita +" Copyright (C) 2010 http://github.com/gmarik +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +function! neobundle#parser#bundle(arg, ...) abort "{{{ + let bundle = s:parse_arg(a:arg) + let is_parse_only = get(a:000, 0, 0) + if !is_parse_only + call neobundle#config#add(bundle) + + if !neobundle#config#within_block() + \ && !bundle.lazy && has('vim_starting') + call neobundle#util#print_error( + \ '`NeoBundle` commands must be executed within' . + \ ' a neobundle#begin/end block. Please check your usage.') + endif + endif + + return bundle +endfunction"}}} + +function! neobundle#parser#lazy(arg) abort "{{{ + let bundle = s:parse_arg(a:arg) + if empty(bundle) + return {} + endif + + " Update lazy flag. + let bundle.lazy = 1 + let bundle.orig_opts.lazy = 1 + for depend in bundle.depends + let depend.lazy = bundle.lazy + endfor + + call neobundle#config#add(bundle) + + return bundle +endfunction"}}} + +function! neobundle#parser#fetch(arg) abort "{{{ + let bundle = s:parse_arg(a:arg) + if empty(bundle) + return {} + endif + + " Clear runtimepath. + let bundle.fetch = 1 + let bundle.rtp = '' + + call neobundle#config#add(bundle) + + return bundle +endfunction"}}} + +function! neobundle#parser#direct(arg) abort "{{{ + let bundle = neobundle#parser#bundle(a:arg, 1) + + if empty(bundle) + return {} + endif + + if !empty(neobundle#get(bundle.name)) + call neobundle#util#print_error( + \ bundle.name . ' is already installed.') + return {} + endif + + call neobundle#config#add(bundle) + + call neobundle#config#save_direct(a:arg) + + " Direct install. + call neobundle#commands#install(0, bundle.name) + + return bundle +endfunction"}}} + +function! s:parse_arg(arg) abort "{{{ + let arg = type(a:arg) == type([]) ? + \ string(a:arg) : '[' . a:arg . ']' + let args = eval(arg) + if empty(args) + return {} + endif + + let bundle = neobundle#parser#_init_bundle( + \ args[0], args[1:]) + if empty(bundle) + return {} + endif + + let bundle.orig_arg = copy(a:arg) + + return bundle +endfunction"}}} + +function! neobundle#parser#_init_bundle(name, opts) abort "{{{ + let path = substitute(a:name, "['".'"]\+', '', 'g') + if path[0] == '~' + let path = neobundle#util#expand(path) + endif + let opts = s:parse_options(a:opts) + let bundle = extend(neobundle#parser#path( + \ path, opts), opts) + + let bundle.orig_name = a:name + let bundle.orig_path = path + let bundle.orig_opts = opts + let bundle.orig_arg = string(a:name).', '.string(opts) + + let bundle = neobundle#init#_bundle(bundle) + + return bundle +endfunction"}}} + +function! neobundle#parser#local(localdir, options, includes) abort "{{{ + let base = fnamemodify(neobundle#util#expand(a:localdir), ':p') + let directories = [] + for glob in a:includes + let directories += map(filter(split(glob(base . glob), '\n'), + \ "isdirectory(v:val)"), " + \ substitute(neobundle#util#substitute_path_separator( + \ fnamemodify(v:val, ':p')), '/$', '', '')") + endfor + + for dir in neobundle#util#uniq(directories) + let options = extend({ 'local' : 1, 'base' : base }, a:options) + let name = fnamemodify(dir, ':t') + let bundle = neobundle#get(name) + if !empty(bundle) && !bundle.sourced + call extend(options, copy(bundle.orig_opts)) + if bundle.lazy + let options.lazy = 1 + endif + + call neobundle#config#rm(bundle) + endif + + call neobundle#parser#bundle([dir, options]) + endfor +endfunction"}}} + +function! neobundle#parser#load_toml(filename, default) abort "{{{ + try + let toml = neobundle#TOML#parse_file(neobundle#util#expand(a:filename)) + catch /vital: Text.TOML:/ + call neobundle#util#print_error( + \ 'Invalid toml format: ' . a:filename) + call neobundle#util#print_error(v:exception) + return 1 + endtry + if type(toml) != type({}) || !has_key(toml, 'plugins') + call neobundle#util#print_error( + \ 'Invalid toml file: ' . a:filename) + return 1 + endif + + " Parse. + for plugin in toml.plugins + if has_key(plugin, 'repository') + let plugin.repo = plugin.repository + endif + if !has_key(plugin, 'repo') + call neobundle#util#print_error( + \ 'No repository plugin data: ' . a:filename) + return 1 + endif + + if has_key(plugin, 'depends') + let _ = [] + for depend in neobundle#util#convert2list(plugin.depends) + if type(depend) == type('') || type(depend) == type([]) + call add(_, depend) + elseif type(depend) == type({}) + if has_key(depend, 'repository') + let plugin.repo = plugin.repository + endif + if !has_key(depend, 'repo') + call neobundle#util#print_error( + \ 'No repository plugin data: ' . a:filename) + return 1 + endif + + call add(_, [depend.repo, depend]) + endif + + unlet depend + endfor + + let plugin.depends = _ + endif + + let options = extend(plugin, a:default, 'keep') + " echomsg string(options) + call neobundle#parser#bundle([plugin.repo, options]) + endfor +endfunction"}}} + +function! neobundle#parser#path(path, ...) abort "{{{ + let opts = get(a:000, 0, {}) + let site = get(opts, 'site', g:neobundle#default_site) + let path = substitute(a:path, '/$', '', '') + + if path !~ '^/\|^\a:' && path !~ ':' + " Add default site. + let path = site . ':' . path + endif + + if has_key(opts, 'type') + let type = neobundle#config#get_types(opts.type) + let types = empty(type) ? [] : [type] + else + let detect = neobundle#config#get_types('git').detect(path, opts) + if !empty(detect) + let detect.name = neobundle#util#name_conversion(path) + return detect + endif + + let types = neobundle#config#get_types() + endif + + let detect = {} + for type in types + let detect = type.detect(path, opts) + if !empty(detect) + break + endif + endfor + + if empty(detect) && isdirectory(path) + " Detect none type. + return { 'uri' : path, 'type' : 'none' } + endif + + if !empty(detect) && !has_key(detect, 'name') + let detect.name = neobundle#util#name_conversion(path) + endif + + return detect +endfunction"}}} + +function! s:parse_options(opts) abort "{{{ + if empty(a:opts) + return has_key(g:neobundle#default_options, '_') ? + \ copy(g:neobundle#default_options['_']) : {} + endif + + if len(a:opts) == 3 + " rev, default, options + let [rev, default, options] = a:opts + elseif len(a:opts) == 2 && type(a:opts[-1]) == type('') + " rev, default + let [rev, default, options] = a:opts + [{}] + elseif len(a:opts) == 2 && type(a:opts[-1]) == type({}) + " rev, options + let [rev, default, options] = [a:opts[0], '', a:opts[1]] + elseif len(a:opts) == 1 && type(a:opts[-1]) == type('') + " rev + let [rev, default, options] = [a:opts[0], '', {}] + elseif len(a:opts) == 1 && type(a:opts[-1]) == type({}) + " options + let [rev, default, options] = ['', '', a:opts[0]] + else + call neobundle#installer#error( + \ printf('Invalid option : "%s".', string(a:opts))) + return {} + endif + + if rev != '' + let options.rev = rev + endif + + if !has_key(options, 'default') + let options.default = (default == '') ? '_' : default + endif + + " Set default options. + if has_key(g:neobundle#default_options, options.default) + call extend(options, + \ g:neobundle#default_options[options.default], 'keep') + endif + + return options +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle/sources/github.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle/sources/github.vim new file mode 100644 index 0000000..e89e33c --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle/sources/github.vim @@ -0,0 +1,119 @@ +"============================================================================= +" FILE: github.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +function! neobundle#sources#github#define() abort "{{{ + return s:source +endfunction"}}} + +let s:source = { + \ 'name' : 'github', + \ 'short_name' : 'github', + \ } + +" sorter +let s:filter = { +\ "name" : "sorter_stars", +\} + +function! s:filter.filter(candidates, context) abort + return unite#util#sort_by(a:candidates, 'v:val.source__stars') +endfunction + +call unite#define_filter(s:filter) +unlet s:filter + +function! s:source.gather_candidates(args, context) abort "{{{ + let plugins = s:get_github_searches(a:context.source__input) + + + return map(copy(plugins), "{ + \ 'word' : v:val.full_name. ' ' . v:val.description, + \ 'source__name' : (v:val.fork ? '| ' : '') . + \ v:val.full_name, + \ 'source__path' : v:val.full_name, + \ 'source__description' : v:val.description, + \ 'source__stars' : v:val.stargazers_count, + \ 'source__options' : [], + \ 'action__uri' : v:val.html_url, + \ }") +endfunction"}}} + +" Misc. +" @vimlint(EVL102, 1, l:true) +" @vimlint(EVL102, 1, l:false) +" @vimlint(EVL102, 1, l:null) +function! s:get_github_searches(string) abort "{{{ + let uri = 'https://api.github.com/search/repositories?q=' + \ . a:string . '+language:VimL'.'\&sort=stars'.'\&order=desc' + let temp = neobundle#util#substitute_path_separator(tempname()) + + let cmd = neobundle#util#wget(uri, temp) + + call unite#print_message( + \ '[neobundle/search:github] Searching plugins from github...') + redraw + + let result = unite#util#system(cmd) + + if cmd =~# '^E:' + call unite#print_error( + \ '[neobundle/search:github] '. + \ 'wget or curl command is not available!') + return [] + elseif unite#util#get_last_status() + call unite#print_message('[neobundle/search:github] ' . cmd) + call unite#print_error('[neobundle/search:github] Error occurred!') + call unite#print_error(result) + return [] + elseif !filereadable(temp) + call unite#print_error('[neobundle/search:github] '. + \ 'Temporary file was not created!') + return [] + else + call unite#print_message('[neobundle/search:github] Done!') + endif + + let [true, false, null] = [1,0,"''"] + sandbox let data = eval(join(readfile(temp))) + call filter(data.items, + \ "stridx(v:val.full_name, a:string) >= 0") + + call delete(temp) + + return data.items +endfunction"}}} +" @vimlint(EVL102, 0, l:true) +" @vimlint(EVL102, 0, l:false) +" @vimlint(EVL102, 0, l:null) + +call unite#custom_source('neobundle/search', 'sorters', 'sorters_stars') + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle/sources/metadata.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle/sources/metadata.vim new file mode 100644 index 0000000..3ce432c --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle/sources/metadata.vim @@ -0,0 +1,104 @@ +"============================================================================= +" FILE: metadata.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +let s:repository_cache = [] + +function! neobundle#sources#metadata#define() abort "{{{ + return s:source +endfunction"}}} + +let s:source = { + \ 'name' : 'metadata', + \ 'short_name' : 'meta', + \ } + +function! s:source.gather_candidates(args, context) abort "{{{ + let plugins = s:get_repository_plugins(a:context) + + try + return map(copy(plugins), "{ + \ 'word' : v:val.name . ' ' . v:val.description, + \ 'source__name' : v:val.name, + \ 'source__path' : v:val.repository, + \ 'source__script_type' : s:convert2script_type(v:val.raw_type), + \ 'source__description' : v:val.description, + \ 'source__options' : [], + \ 'action__uri' : v:val.uri, + \ }") + catch + call unite#print_error( + \ '[neobundle/search:metadata] ' + \ .'Error occurred in loading cache.') + call unite#print_error( + \ '[neobundle/search:metadata] ' + \ .'Please re-make cache by (unite_redraw) mapping.') + call neobundle#installer#error(v:exception . ' ' . v:throwpoint) + + return [] + endtry +endfunction"}}} + +" Misc. +function! s:get_repository_plugins(context) abort "{{{ + if a:context.is_redraw + " Reload cache. + call unite#print_message( + \ '[neobundle/search:metadata] ' + \ .'Reloading cache from metadata repository') + redraw + + call neobundle#metadata#update() + endif + + return s:convert_metadata(neobundle#metadata#get()) +endfunction"}}} + +function! s:convert_metadata(data) abort "{{{ + return values(map(copy(a:data), "{ + \ 'name' : v:key, + \ 'raw_type' : get(v:val, 'script-type', ''), + \ 'repository' : substitute(v:val.url, '^git://', 'https://', ''), + \ 'description' : '', + \ 'uri' : get(v:val, 'homepage', ''), + \ }")) +endfunction"}}} + +function! s:convert2script_type(type) abort "{{{ + if a:type ==# 'utility' + return 'plugin' + elseif a:type ==# 'color scheme' + return 'colors' + else + return a:type + endif +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle/sources/vim_scripts_org.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle/sources/vim_scripts_org.vim new file mode 100644 index 0000000..d79f35f --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle/sources/vim_scripts_org.vim @@ -0,0 +1,160 @@ +"============================================================================= +" FILE: vim_scripts_org.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +let s:Cache = unite#util#get_vital_cache() + +let s:repository_cache = [] + +function! neobundle#sources#vim_scripts_org#define() abort "{{{ + return s:source +endfunction"}}} + +let s:source = { + \ 'name' : 'vim-scripts.org', + \ 'short_name' : 'vim.org', + \ } + +function! s:source.gather_candidates(args, context) abort "{{{ + let repository = + \ 'https://raw.githubusercontent.com/vim-scraper/' + \ .'vim-scraper.github.com/master/api/scripts_recent.json' + + call unite#print_message( + \ '[neobundle/search:vim-scripts.org] repository: ' . repository) + + let plugins = s:get_repository_plugins(a:context, repository) + + try + return map(copy(plugins), "{ + \ 'word' : v:val.name . ' ' . v:val.description, + \ 'source__name' : v:val.name, + \ 'source__path' : v:val.name, + \ 'source__script_type' : s:convert2script_type(v:val.raw_type), + \ 'source__description' : v:val.description, + \ 'source__options' : [], + \ 'action__uri' : v:val.uri, + \ }") + catch + call unite#print_error( + \ '[neobundle/search:vim-scripts.org] ' + \ .'Error occurred in loading cache.') + call unite#print_error( + \ '[neobundle/search:vim-scripts.org] ' + \ .'Please re-make cache by (unite_redraw) mapping.') + call neobundle#installer#error(v:exception . ' ' . v:throwpoint) + + return [] + endtry +endfunction"}}} + +" Misc. +function! s:get_repository_plugins(context, path) abort "{{{ + let cache_dir = neobundle#get_neobundle_dir() . '/.neobundle' + + if a:context.is_redraw || !s:Cache.filereadable(cache_dir, a:path) + " Reload cache. + let cache_path = s:Cache.getfilename(cache_dir, a:path) + + call unite#print_message( + \ '[neobundle/search:vim-scripts.org] ' + \ .'Reloading cache from ' . a:path) + redraw + + if s:Cache.filereadable(cache_dir, a:path) + call delete(cache_path) + endif + + let temp = unite#util#substitute_path_separator(tempname()) + + let cmd = neobundle#util#wget(a:path, temp) + if cmd =~# '^E:' + call unite#print_error( + \ '[neobundle/search:vim-scripts.org] '. + \ 'curl or wget command is not available!') + return [] + endif + + let result = unite#util#system(cmd) + + if unite#util#get_last_status() + call unite#print_message( + \ '[neobundle/search:vim-scripts.org] ' . cmd) + call unite#print_message( + \ '[neobundle/search:vim-scripts.org] ' . result) + call unite#print_error( + \ '[neobundle/search:vim-scripts.org] Error occurred!') + return [] + elseif !filereadable(temp) + call unite#print_error('[neobundle/search:vim-scripts.org] '. + \ 'Temporary file was not created!') + return [] + else + call unite#print_message('[neobundle/search:vim-scripts.org] Done!') + endif + + sandbox let data = eval(get(readfile(temp), 0, '[]')) + + " Convert cache data. + call s:Cache.writefile(cache_dir, a:path, + \ [string(s:convert_vim_scripts_data(data))]) + + call delete(temp) + endif + + if empty(s:repository_cache) + sandbox let s:repository_cache = + \ eval(get(s:Cache.readfile(cache_dir, a:path), 0, '[]')) + endif + + return s:repository_cache +endfunction"}}} + +function! s:convert_vim_scripts_data(data) abort "{{{ + return map(copy(a:data), "{ + \ 'name' : v:val.n, + \ 'raw_type' : v:val.t, + \ 'repository' : v:val.rv, + \ 'description' : printf('%-5s %s', v:val.rv, v:val.s), + \ 'uri' : 'https://github.com/vim-scripts/' . v:val.n, + \ }") +endfunction"}}} + +function! s:convert2script_type(type) abort "{{{ + if a:type ==# 'utility' + return 'plugin' + elseif a:type ==# 'color scheme' + return 'colors' + else + return a:type + endif +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle/types/git.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle/types/git.vim new file mode 100644 index 0000000..ab30e42 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle/types/git.vim @@ -0,0 +1,312 @@ +"============================================================================= +" FILE: git.vim +" AUTHOR: Shougo Matsushita +" Robert Nelson +" Copyright (C) 2010 http://github.com/gmarik +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +" Global options definition. "{{{ +call neobundle#util#set_default( + \ 'g:neobundle#types#git#command_path', 'git') +call neobundle#util#set_default( + \ 'g:neobundle#types#git#default_protocol', 'https', + \ 'g:neobundle_default_git_protocol') +call neobundle#util#set_default( + \ 'g:neobundle#types#git#enable_submodule', 1) +call neobundle#util#set_default( + \ 'g:neobundle#types#git#clone_depth', 0, + \ 'g:neobundle_git_clone_depth') +call neobundle#util#set_default( + \ 'g:neobundle#types#git#pull_command', 'pull --ff --ff-only') +"}}} + +function! neobundle#types#git#define() abort "{{{ + return s:type +endfunction"}}} + +let s:type = { + \ 'name' : 'git', + \ } + +function! s:type.detect(path, opts) abort "{{{ + if a:path =~ '^/\|^\a:/' && s:is_git_dir(a:path.'/.git') + " Local repository. + return { 'uri' : a:path, 'type' : 'git' } + elseif isdirectory(a:path) + return {} + endif + + let protocol = matchstr(a:path, '^.\{-}\ze://') + if protocol == '' || a:path =~# + \'\<\%(gh\|github\|bb\|bitbucket\):\S\+' + \ || has_key(a:opts, 'type__protocol') + let protocol = get(a:opts, 'type__protocol', + \ g:neobundle#types#git#default_protocol) + endif + + if protocol !=# 'https' && protocol !=# 'ssh' + call neobundle#util#print_error( + \ 'Path: ' . a:path . ' The protocol "' . protocol . + \ '" is unsecure and invalid.') + return {} + endif + + if a:path !~ '/' + " www.vim.org Vim scripts. + let name = split(a:path, ':')[-1] + let uri = (protocol ==# 'ssh') ? + \ 'git@github.com:vim-scripts/' : + \ protocol . '://github.com/vim-scripts/' + let uri .= name + else + let name = substitute(split(a:path, ':')[-1], + \ '^//github.com/', '', '') + let uri = (protocol ==# 'ssh') ? + \ 'git@github.com:' . name : + \ protocol . '://github.com/'. name + endif + + if a:path !~# '\<\%(gh\|github\):\S\+\|://github.com/' + let uri = s:parse_other_pattern(protocol, a:path, a:opts) + if uri == '' + " Parse failure. + return {} + endif + endif + + if uri !~ '\.git\s*$' + " Add .git suffix. + let uri .= '.git' + endif + + return { 'uri': uri, 'type' : 'git' } +endfunction"}}} +function! s:type.get_sync_command(bundle) abort "{{{ + if !executable(g:neobundle#types#git#command_path) + return 'E: "git" command is not installed.' + endif + + if !isdirectory(a:bundle.path) + let cmd = 'clone' + if g:neobundle#types#git#enable_submodule + let cmd .= ' --recursive' + endif + + let depth = get(a:bundle, 'type__depth', + \ g:neobundle#types#git#clone_depth) + if depth > 0 && a:bundle.rev == '' && a:bundle.uri !~ '^git@' + let cmd .= ' --depth=' . depth + endif + + let cmd .= printf(' %s "%s"', a:bundle.uri, a:bundle.path) + else + let cmd = g:neobundle#types#git#pull_command + if g:neobundle#types#git#enable_submodule + let shell = fnamemodify(split(&shell)[0], ':t') + let and = (!neobundle#util#has_vimproc() && shell ==# 'fish') ? + \ '; and ' : ' && ' + + let cmd .= and . g:neobundle#types#git#command_path + \ . ' submodule update --init --recursive' + endif + endif + + return g:neobundle#types#git#command_path . ' ' . cmd +endfunction"}}} +function! s:type.get_revision_number_command(bundle) abort "{{{ + if !executable(g:neobundle#types#git#command_path) + return '' + endif + + return g:neobundle#types#git#command_path .' rev-parse HEAD' +endfunction"}}} +function! s:type.get_revision_pretty_command(bundle) abort "{{{ + if !executable(g:neobundle#types#git#command_path) + return '' + endif + + return g:neobundle#types#git#command_path . + \ ' log -1 --pretty=format:"%h [%cr] %s"' +endfunction"}}} +function! s:type.get_commit_date_command(bundle) abort "{{{ + if !executable(g:neobundle#types#git#command_path) + return '' + endif + + return g:neobundle#types#git#command_path . + \ ' log -1 --pretty=format:"%ct"' +endfunction"}}} +function! s:type.get_log_command(bundle, new_rev, old_rev) abort "{{{ + if !executable(g:neobundle#types#git#command_path) + \ || a:new_rev == '' || a:old_rev == '' + return '' + endif + + " Note: If the a:old_rev is not the ancestor of two branchs. Then do not use + " %s^. use %s^ will show one commit message which already shown last time. + let is_not_ancestor = neobundle#util#system( + \ g:neobundle#types#git#command_path . ' merge-base ' + \ . a:old_rev . ' ' . a:new_rev) ==# a:old_rev + return printf(g:neobundle#types#git#command_path . + \ ' log %s%s..%s --graph --pretty=format:"%%h [%%cr] %%s"', + \ a:old_rev, (is_not_ancestor ? '' : '^'), a:new_rev) + + " Test. + " return g:neobundle#types#git#command_path . + " \ ' log HEAD^^^^..HEAD --graph --pretty=format:"%h [%cr] %s"' +endfunction"}}} +function! s:type.get_revision_lock_command(bundle) abort "{{{ + if !executable(g:neobundle#types#git#command_path) + return '' + endif + + let rev = a:bundle.rev + if rev ==# 'release' + " Use latest released tag + let rev = neobundle#installer#get_release_revision(a:bundle, + \ g:neobundle#types#git#command_path . ' tag') + endif + if rev == '' + " Fix detach HEAD. + let rev = 'master' + endif + + return g:neobundle#types#git#command_path . ' checkout ' . rev +endfunction"}}} +function! s:type.get_gc_command(bundle) abort "{{{ + if !executable(g:neobundle#types#git#command_path) + return '' + endif + + return g:neobundle#types#git#command_path .' gc' +endfunction"}}} +function! s:type.get_revision_remote_command(bundle) abort "{{{ + if !executable(g:neobundle#types#git#command_path) + return '' + endif + + let rev = a:bundle.rev + if rev == '' + let rev = 'HEAD' + endif + + return g:neobundle#types#git#command_path + \ .' ls-remote origin ' . rev +endfunction"}}} +function! s:type.get_fetch_remote_command(bundle) abort "{{{ + if !executable(g:neobundle#types#git#command_path) + return '' + endif + + return g:neobundle#types#git#command_path + \ .' fetch origin ' +endfunction"}}} + +function! s:parse_other_pattern(protocol, path, opts) abort "{{{ + let uri = '' + + if a:path =~# '\ +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +" Global options definition. "{{{ +call neobundle#util#set_default( + \ 'g:neobundle#types#hg#command_path', 'hg') +call neobundle#util#set_default( + \ 'g:neobundle#types#hg#default_protocol', 'https', + \ 'g:neobundle_default_hg_protocol') +"}}} + +function! neobundle#types#hg#define() abort "{{{ + return s:type +endfunction"}}} + +let s:type = { + \ 'name' : 'hg', + \ } + +function! s:type.detect(path, opts) abort "{{{ + if isdirectory(a:path.'/.hg') + " Local repository. + return { 'uri' : a:path, 'type' : 'hg' } + elseif isdirectory(a:path) + return {} + endif + + let protocol = matchstr(a:path, '^.\{-}\ze://') + if protocol == '' || a:path =~# + \'\<\%(bb\|bitbucket\):\S\+' + \ || has_key(a:opts, 'type__protocol') + let protocol = get(a:opts, 'type__protocol', + \ g:neobundle#types#hg#default_protocol) + endif + + if protocol !=# 'https' && protocol !=# 'ssh' + call neobundle#util#print_error( + \ 'Path: ' . a:path . ' The protocol "' . protocol . + \ '" is unsecure and invalid.') + return {} + endif + + if a:path =~# '\<\%(bb\|bitbucket\):' + let name = substitute(split(a:path, ':')[-1], + \ '^//bitbucket.org/', '', '') + let uri = (protocol ==# 'ssh') ? + \ 'ssh://hg@bitbucket.org/' . name : + \ protocol . '://bitbucket.org/' . name + elseif a:path =~? '[/.]hg[/.@]' + \ || (a:path =~# '\ +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +function! neobundle#types#none#define() abort "{{{ + return s:type +endfunction"}}} + +let s:type = { + \ 'name' : 'none', + \ } + +function! s:type.detect(path, opts) abort "{{{ + " No Auto detect. + return {} +endfunction"}}} +function! s:type.get_sync_command(bundle) abort "{{{ + if isdirectory(a:bundle.path) + return '' + endif + + " Try auto install. + let path = a:bundle.orig_path + let site = get(a:bundle, 'site', g:neobundle#default_site) + if path !~ '^/\|^\a:' && path !~ ':' + " Add default site. + let path = site . ':' . path + endif + + for type in neobundle#config#get_types() + let detect = type.detect(path, a:bundle.orig_opts) + + if !empty(detect) + return type.get_sync_command( + \ extend(copy(a:bundle), detect)) + endif + endfor + + return 'E: Failed to auto installation.' +endfunction"}}} +function! s:type.get_revision_number_command(bundle) abort "{{{ + return '' +endfunction"}}} +function! s:type.get_revision_lock_command(bundle) abort "{{{ + return '' +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle/types/raw.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle/types/raw.vim new file mode 100644 index 0000000..ad771cc --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle/types/raw.vim @@ -0,0 +1,116 @@ +"============================================================================= +" FILE: raw.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +" Global options definition. "{{{ +call neobundle#util#set_default( + \ 'g:neobundle#types#raw#calc_hash_command', + \ executable('sha1sum') ? 'sha1sum' : + \ executable('md5sum') ? 'md5sum' : '') +"}}} + +function! neobundle#types#raw#define() abort "{{{ + return s:type +endfunction"}}} + +let s:type = { + \ 'name' : 'raw', + \ } + +function! s:type.detect(path, opts) abort "{{{ + " No auto detect. + let type = '' + let name = '' + + if a:path =~# '^https:.*\.vim$' + " HTTPS + + let name = neobundle#util#name_conversion(a:path) + + let type = 'raw' + elseif a:path =~# + \ '^https://www\.vim\.org/scripts/download_script.php?src_id=\d\+$' + " For www.vim.org + let name = 'vim-scripts-' . matchstr(a:path, '\d\+$') + let type = 'raw' + endif + + return type == '' ? {} : + \ { 'name': name, 'uri' : a:path, 'type' : type } +endfunction"}}} +function! s:type.get_sync_command(bundle) abort "{{{ + if a:bundle.script_type == '' + return 'E: script_type is not found.' + endif + + let path = a:bundle.path + + if !isdirectory(path) + " Create script type directory. + call mkdir(path, 'p') + endif + + let filename = path . '/' . get(a:bundle, + \ 'type__filename', fnamemodify(a:bundle.uri, ':t')) + let a:bundle.type__filepath = filename + + let cmd = neobundle#util#wget(a:bundle.uri, filename) + + return cmd +endfunction"}}} +function! s:type.get_revision_number_command(bundle) abort "{{{ + if g:neobundle#types#raw#calc_hash_command == '' + return '' + endif + + if !filereadable(a:bundle.type__filepath) + " Not Installed. + return '' + endif + + " Calc hash. + return printf('%s %s', + \ g:neobundle#types#raw#calc_hash_command, + \ a:bundle.type__filepath) +endfunction"}}} +function! s:type.get_revision_lock_command(bundle) abort "{{{ + let new_rev = matchstr(a:bundle.new_rev, '^\S\+') + if a:bundle.rev != '' && new_rev != '' && + \ new_rev !=# a:bundle.rev + " Revision check. + return printf('E: revision digest is not matched : "%s"(got) and "%s"(rev).', + \ new_rev, a:bundle.rev) + endif + + " Not supported. + return '' +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle/types/svn.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle/types/svn.vim new file mode 100644 index 0000000..336b6a3 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle/types/svn.vim @@ -0,0 +1,93 @@ +"============================================================================= +" FILE: svn.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +" Global options definition. "{{{ +call neobundle#util#set_default( + \ 'g:neobundle#types#svn#command_path', 'svn') +"}}} + +function! neobundle#types#svn#define() abort "{{{ + return s:type +endfunction"}}} + +let s:type = { + \ 'name' : 'svn', + \ } + +function! s:type.detect(path, opts) abort "{{{ + if isdirectory(a:path) + return {} + endif + + let type = '' + let uri = '' + + if (a:path =~# '\<\%(file\|https\)://' + \ && a:path =~? '[/.]svn[/.]') + \ || a:path =~# '\ +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +" Global options definition. "{{{ +call neobundle#util#set_default( + \ 'g:neobundle#types#vba#calc_hash_command', + \ executable('sha1sum') ? 'sha1sum' : + \ executable('md5sum') ? 'md5sum' : '') +"}}} + +function! neobundle#types#vba#define() abort "{{{ + return s:type +endfunction"}}} + +let s:type = { + \ 'name' : 'vba', + \ } + +function! s:type.detect(path, opts) abort "{{{ + " No auto detect. + let type = '' + let name = '' + + if a:path =~# '^https:.*\.vba\(\.gz\)\?$' + " HTTPS + " .*.vba / .*.vba.gz + let name = fnamemodify(split(a:path, ':')[-1], + \ ':s?/$??:t:s?\c\.vba\(\.gz\)*\s*$??') + let type = 'vba' + elseif a:path =~# '\.vba\(\.gz\)\?$' && filereadable(a:path) + " local + " .*.vba + let name = fnamemodify(a:path, ':t:s?\c\.vba\(\.gz\)*\s*$??') + let type = 'vba' + endif + + if a:path =~# '^https:.*\.vmb$' + " HTTPS + " .*.vmb + let name = fnamemodify(split(a:path, ':')[-1], + \ ':s?/$??:t:s?\c\.vba\s*$??') + let type = 'vba' + elseif a:path =~# '\.vmb$' && filereadable(a:path) + " local + " .*.vmb + let name = fnamemodify(a:path, ':t:s?\c\.vba\s*$??') + let type = 'vba' + endif + + return type == '' ? {} : + \ { 'name': name, 'uri' : a:path, 'type' : type } +endfunction"}}} +function! s:type.get_sync_command(bundle) abort "{{{ + let path = a:bundle.path + + if !isdirectory(path) + " Create script type directory. + call mkdir(path, 'p') + endif + + let filename = path . '/' . get(a:bundle, + \ 'type__filename', fnamemodify(a:bundle.uri, ':t')) + let a:bundle.type__filepath = filename + + let cmd = '' + if filereadable(a:bundle.uri) + call writefile(readfile(a:bundle.uri, 'b'), filename, 'b') + else + let cmd = neobundle#util#wget(a:bundle.uri, filename) + if cmd =~# '^E:' + return cmd + endif + let cmd .= ' && ' + endif + + let cmd .= printf('%s -u NONE' . + \ ' -c "set nocompatible"' . + \ ' -c "filetype plugin on"' . + \ ' -c "runtime plugin/gzip.vim"' . + \ ' -c "runtime plugin/vimballPlugin.vim"' . + \ ' -c "edit %s"' . + \ ' -c "UseVimball %s"' . + \ ' -c "q"', v:progpath, filename, path) + " let cmd .= printf(' rm %s &&', filename) + " let cmd .= printf(' rm %s/.VimballRecord', path) + + return cmd +endfunction"}}} +function! s:type.get_revision_number_command(bundle) abort "{{{ + if g:neobundle#types#vba#calc_hash_command == '' + return '' + endif + + if !has_key(a:bundle, 'type__filepath') + \ || !filereadable(a:bundle.type__filepath) + " Not Installed. + return '' + endif + + " Calc hash. + return printf('%s %s', + \ g:neobundle#types#vba#calc_hash_command, + \ a:bundle.type__filepath) +endfunction"}}} +function! s:type.get_revision_lock_command(bundle) abort "{{{ + let new_rev = matchstr(a:bundle.new_rev, '^\S\+') + if a:bundle.rev != '' && new_rev != '' && + \ new_rev !=# a:bundle.rev + " Revision check. + return printf('E: revision digest is not matched : "%s"(got) and "%s"(rev).', + \ new_rev, a:bundle.rev) + endif + + " Not supported. + return '' +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/dot_vim/bundle/neobundle.vim/autoload/neobundle/util.vim b/dot_vim/bundle/neobundle.vim/autoload/neobundle/util.vim new file mode 100644 index 0000000..605f21b --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/neobundle/util.vim @@ -0,0 +1,510 @@ +"============================================================================= +" FILE: util.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +let s:is_windows = has('win32') +let s:is_cygwin = has('win32unix') +let s:is_mac = !s:is_windows && !s:is_cygwin + \ && (has('mac') || has('macunix') || has('gui_macvim') || + \ (!isdirectory('/proc') && executable('sw_vers'))) + +function! neobundle#util#substitute_path_separator(path) abort "{{{ + return (s:is_windows && a:path =~ '\\') ? + \ tr(a:path, '\', '/') : a:path +endfunction"}}} +function! neobundle#util#expand(path) abort "{{{ + let path = (a:path =~ '^\~') ? fnamemodify(a:path, ':p') : + \ (a:path =~ '^\$\h\w*') ? substitute(a:path, + \ '^\$\h\w*', '\=eval(submatch(0))', '') : + \ a:path + return (s:is_windows && path =~ '\\') ? + \ neobundle#util#substitute_path_separator(path) : path +endfunction"}}} +function! neobundle#util#join_paths(path1, path2) abort "{{{ + " Joins two paths together, handling the case where the second path + " is an absolute path. + if s:is_absolute(a:path2) + return a:path2 + endif + if a:path1 =~ (s:is_windows ? '[\\/]$' : '/$') || + \ a:path2 =~ (s:is_windows ? '^[\\/]' : '^/') + " the appropriate separator already exists + return a:path1 . a:path2 + else + " note: I'm assuming here that '/' is always valid as a directory + " separator on Windows. I know Windows has paths that start with \\?\ that + " diasble behavior like that, but I don't know how Vim deals with that. + return a:path1 . '/' . a:path2 + endif +endfunction "}}} +if s:is_windows + function! s:is_absolute(path) abort "{{{ + return a:path =~ '^[\\/]\|^\a:' + endfunction "}}} +else + function! s:is_absolute(path) abort "{{{ + return a:path =~ "^/" + endfunction "}}} +endif + +function! neobundle#util#is_windows() abort "{{{ + return s:is_windows +endfunction"}}} +function! neobundle#util#is_mac() abort "{{{ + return s:is_mac +endfunction"}}} +function! neobundle#util#is_cygwin() abort "{{{ + return s:is_cygwin +endfunction"}}} + +" Sudo check. +function! neobundle#util#is_sudo() abort "{{{ + return $SUDO_USER != '' && $USER !=# $SUDO_USER + \ && $HOME !=# expand('~'.$USER) + \ && $HOME ==# expand('~'.$SUDO_USER) +endfunction"}}} + +" Check vimproc. "{{{ +function! neobundle#util#has_vimproc() abort "{{{ + if !exists('*vimproc#version') + try + call vimproc#version() + catch + endtry + endif + + return exists('*vimproc#version') +endfunction"}}} +"}}} +" iconv() wrapper for safety. +function! s:iconv(expr, from, to) abort "{{{ + if a:from == '' || a:to == '' || a:from ==? a:to + return a:expr + endif + let result = iconv(a:expr, a:from, a:to) + return result != '' ? result : a:expr +endfunction"}}} +function! neobundle#util#system(str, ...) abort "{{{ + let command = a:str + let input = a:0 >= 1 ? a:1 : '' + let command = s:iconv(command, &encoding, 'char') + let input = s:iconv(input, &encoding, 'char') + + if a:0 == 0 + let output = neobundle#util#has_vimproc() ? + \ vimproc#system(command) : system(command, "\") + elseif a:0 == 1 + let output = neobundle#util#has_vimproc() ? + \ vimproc#system(command, input) : system(command, input) + else + " ignores 3rd argument unless you have vimproc. + let output = neobundle#util#has_vimproc() ? + \ vimproc#system(command, input, a:2) : system(command, input) + endif + + let output = s:iconv(output, 'char', &encoding) + + return substitute(output, '\n$', '', '') +endfunction"}}} +function! neobundle#util#get_last_status() abort "{{{ + return neobundle#util#has_vimproc() ? + \ vimproc#get_last_status() : v:shell_error +endfunction"}}} + +" Split a comma separated string to a list. +function! neobundle#util#split_rtp(runtimepath) abort "{{{ + if stridx(a:runtimepath, '\,') < 0 + return split(a:runtimepath, ',') + endif + + let split = split(a:runtimepath, '\\\@# a:b[1] ? 1 : -1'), 'v:val[0]') +endfunction"}}} + +" Executes a command and returns its output. +" This wraps Vim's `:redir`, and makes sure that the `verbose` settings have +" no influence. +function! neobundle#util#redir(cmd) abort "{{{ + let [save_verbose, save_verbosefile] = [&verbose, &verbosefile] + set verbose=0 verbosefile= + redir => res + silent! execute a:cmd + redir END + let [&verbose, &verbosefile] = [save_verbose, save_verbosefile] + return res +endfunction"}}} + +" Sorts a list with expression to compare each two values. +" a:a and a:b can be used in {expr}. +function! s:sort(list, expr) abort "{{{ + if type(a:expr) == type(function('function')) + return sort(a:list, a:expr) + endif + let s:expr = a:expr + return sort(a:list, 's:_compare') +endfunction"}}} + +function! s:_compare(a, b) abort + return eval(s:expr) +endfunction + +function! neobundle#util#print_bundles(bundles) abort "{{{ + echomsg string(map(copy(a:bundles), 'v:val.name')) +endfunction"}}} + +function! neobundle#util#sort_human(filenames) abort "{{{ + return sort(a:filenames, 's:compare_filename') +endfunction"}}} + +" Compare filename by human order. "{{{ +function! s:compare_filename(i1, i2) abort + let words_1 = s:get_words(a:i1) + let words_2 = s:get_words(a:i2) + let words_1_len = len(words_1) + let words_2_len = len(words_2) + + for i in range(0, min([words_1_len, words_2_len])-1) + if words_1[i] >? words_2[i] + return 1 + elseif words_1[i] a:width + let char = matchstr(ret, '.$') + let ret = ret[: -1 - len(char)] + let width -= s:wcswidth(char) + endwhile + + return ret +endfunction"}}} +function! s:strwidthpart_reverse(str, width) abort "{{{ + if a:width <= 0 + return '' + endif + let ret = a:str + let width = s:wcswidth(a:str) + while width > a:width + let char = matchstr(ret, '^.') + let ret = ret[len(char) :] + let width -= s:wcswidth(char) + endwhile + + return ret +endfunction"}}} +function! s:wcswidth(str) abort "{{{ + return v:version >= 704 ? strwidth(a:str) : strlen(a:str) +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker + diff --git a/dot_vim/bundle/neobundle.vim/autoload/unite/kinds/neobundle.vim b/dot_vim/bundle/neobundle.vim/autoload/unite/kinds/neobundle.vim new file mode 100644 index 0000000..d79a0c9 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/unite/kinds/neobundle.vim @@ -0,0 +1,106 @@ +"============================================================================= +" FILE: neobundle.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +function! unite#kinds#neobundle#define() abort "{{{ + return s:kind +endfunction"}}} + +let s:kind = { + \ 'name' : 'neobundle', + \ 'action_table': {}, + \ 'parents' : ['uri', 'directory'], + \ 'default_action' : 'update', + \} + +" Actions "{{{ +let s:kind.action_table.update = { + \ 'description' : 'update bundles', + \ 'is_selectable' : 1, + \ 'is_start' : 1, + \ } +function! s:kind.action_table.update.func(candidates) abort "{{{ + call unite#start_script([['neobundle/update', '!'] + \ + map(copy(a:candidates), 'v:val.action__bundle_name')], + \ { 'log' : 1 }) +endfunction"}}} +let s:kind.action_table.delete = { + \ 'description' : 'delete bundles', + \ 'is_invalidate_cache' : 1, + \ 'is_quit' : 0, + \ 'is_selectable' : 1, + \ } +function! s:kind.action_table.delete.func(candidates) abort "{{{ + call call('neobundle#commands#clean', insert(map(copy(a:candidates), + \ 'v:val.action__bundle_name'), 0)) +endfunction"}}} +let s:kind.action_table.reinstall = { + \ 'description' : 'reinstall bundles', + \ 'is_selectable' : 1, + \ } +function! s:kind.action_table.reinstall.func(candidates) abort "{{{ + call neobundle#installer#reinstall( + \ map(copy(a:candidates), 'v:val.action__bundle')) +endfunction"}}} +let s:kind.action_table.preview = { + \ 'description' : 'view the plugin documentation', + \ 'is_quit' : 0, + \ } +function! s:kind.action_table.preview.func(candidate) abort "{{{ + " Search help files. + let readme = get(split(globpath( + \ a:candidate.action__path, 'doc/*.?*', 1), '\n'), 0, '') + + if readme == '' + " Search README files. + let readme = get(split(globpath( + \ a:candidate.action__path, 'README*', 1), '\n'), 0, '') + if readme == '' + return + endif + endif + + let buflisted = buflisted( + \ unite#util#escape_file_searching(readme)) + + execute 'pedit' fnameescape(readme) + + " Open folds. + normal! zv + normal! zt + + if !buflisted + call unite#add_previewed_buffer_list( + \ bufnr(unite#util#escape_file_searching(readme))) + endif +endfunction"}}} +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/dot_vim/bundle/neobundle.vim/autoload/unite/sources/neobundle.vim b/dot_vim/bundle/neobundle.vim/autoload/unite/sources/neobundle.vim new file mode 100644 index 0000000..095fac8 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/unite/sources/neobundle.vim @@ -0,0 +1,143 @@ +"============================================================================= +" FILE: neobundle.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +function! unite#sources#neobundle#define() abort "{{{ + return s:source +endfunction"}}} + +let s:source = { + \ 'name' : 'neobundle', + \ 'description' : 'candidates from bundles', + \ 'hooks' : {}, + \ } + +function! s:source.hooks.on_init(args, context) abort "{{{ + let bundle_names = filter(copy(a:args), 'v:val != "!"') + let a:context.source__bang = + \ index(a:args, '!') >= 0 + let a:context.source__bundles = neobundle#util#sort_by( + \ (empty(bundle_names) ? + \ neobundle#config#get_neobundles() : + \ neobundle#config#search(bundle_names)), + \ 'tolower(v:val.orig_name)') +endfunction"}}} + +" Filters "{{{ +function! s:source.source__converter(candidates, context) abort "{{{ + for candidate in a:candidates + if candidate.source__uri =~ + \ '^\%(https\?\|git\)://github.com/' + let candidate.action__uri = candidate.source__uri + let candidate.action__uri = + \ substitute(candidate.action__uri, '^git://', 'https://', '') + let candidate.action__uri = + \ substitute(candidate.action__uri, '.git$', '', '') + endif + endfor + + return a:candidates +endfunction"}}} + +let s:source.converters = s:source.source__converter +"}}} + +function! s:source.gather_candidates(args, context) abort "{{{ + let _ = map(copy(a:context.source__bundles), "{ + \ 'word' : substitute(v:val.orig_name, + \ '^\%(https\?\|git\)://\%(github.com/\)\?', '', ''), + \ 'kind' : 'neobundle', + \ 'action__path' : v:val.path, + \ 'action__directory' : v:val.path, + \ 'action__bundle' : v:val, + \ 'action__bundle_name' : v:val.name, + \ 'source__uri' : v:val.uri, + \ 'source__description' : v:val.description, + \ 'is_multiline' : 1, + \ } + \") + + let max = max(map(copy(_), 'len(v:val.word)')) + + call unite#print_source_message( + \ '#: not sourced, X: not installed', self.name) + + for candidate in _ + let candidate.abbr = + \ neobundle#is_sourced(candidate.action__bundle_name) ? ' ' : + \ neobundle#is_installed(candidate.action__bundle_name) ? '#' : 'X' + let candidate.abbr .= ' ' . unite#util#truncate(candidate.word, max) + if candidate.source__description != '' + let candidate.abbr .= ' : ' . candidate.source__description + endif + + if a:context.source__bang + let status = s:get_commit_status(candidate.action__bundle) + if status != '' + let candidate.abbr .= "\n " . status + endif + endif + + let candidate.word .= candidate.source__description + endfor + + return _ +endfunction"}}} + +function! s:get_commit_status(bundle) abort "{{{ + if !isdirectory(a:bundle.path) + return 'Not installed' + endif + + let type = neobundle#config#get_types(a:bundle.type) + let cmd = has_key(type, 'get_revision_pretty_command') ? + \ type.get_revision_pretty_command(a:bundle) : + \ type.get_revision_number_command(a:bundle) + if cmd == '' + return '' + endif + + let cwd = getcwd() + try + call neobundle#util#cd(a:bundle.path) + let output = neobundle#util#system(cmd) + finally + call neobundle#util#cd(cwd) + endtry + + if neobundle#util#get_last_status() + return printf('Error(%d) occurred when executing "%s"', + \ neobundle#util#get_last_status(), cmd) + endif + + return output +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/dot_vim/bundle/neobundle.vim/autoload/unite/sources/neobundle_install.vim b/dot_vim/bundle/neobundle.vim/autoload/unite/sources/neobundle_install.vim new file mode 100644 index 0000000..62038b0 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/unite/sources/neobundle_install.vim @@ -0,0 +1,190 @@ +"============================================================================= +" FILE: neobundle/install.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +function! unite#sources#neobundle_install#define() abort "{{{ + return [s:source_install, s:source_update] +endfunction"}}} + +let s:source_install = { + \ 'name' : 'neobundle/install', + \ 'description' : 'install bundles', + \ 'hooks' : {}, + \ 'default_kind' : 'word', + \ 'syntax' : 'uniteSource__NeoBundleInstall', + \ } + +function! s:source_install.hooks.on_init(args, context) abort "{{{ + let bundle_names = filter(copy(a:args), "v:val != '!'") + let a:context.source__bang = + \ index(a:args, '!') >= 0 || !empty(bundle_names) + let a:context.source__not_fuzzy = 0 + call s:init(a:context, bundle_names) +endfunction"}}} + +function! s:source_install.hooks.on_syntax(args, context) abort "{{{ + syntax match uniteSource__NeoBundleInstall_Progress /(.\{-}):\s*.*/ + \ contained containedin=uniteSource__NeoBundleInstall + highlight default link uniteSource__NeoBundleInstall_Progress String + syntax match uniteSource__NeoBundleInstall_Source /|.\{-}|/ + \ contained containedin=uniteSource__NeoBundleInstall_Progress + highlight default link uniteSource__NeoBundleInstall_Source Type + syntax match uniteSource__NeoBundleInstall_URI /-> diff URI/ + \ contained containedin=uniteSource__NeoBundleInstall + highlight default link uniteSource__NeoBundleInstall_URI Underlined +endfunction"}}} + +function! s:source_install.hooks.on_close(args, context) abort "{{{ + if !empty(a:context.source__processes) + for process in a:context.source__processes + if has('nvim') + call jobstop(process.proc) + else + call process.proc.waitpid() + endif + endfor + endif +endfunction"}}} + +function! s:source_install.async_gather_candidates(args, context) abort "{{{ + if !a:context.sync && empty(filter(range(1, winnr('$')), + \ "getwinvar(v:val, '&l:filetype') ==# 'unite'")) + return [] + endif + + let old_msgs = copy(neobundle#installer#get_updates_log()) + + if a:context.source__number < a:context.source__max_bundles + while a:context.source__number < a:context.source__max_bundles + \ && len(a:context.source__processes) < + \ g:neobundle#install_max_processes + let bundle = a:context.source__bundles[a:context.source__number] + call neobundle#installer#sync(bundle, a:context, 1) + + call unite#clear_message() + call unite#print_source_message( + \ neobundle#installer#get_progress_message(bundle, + \ a:context.source__number, + \ a:context.source__max_bundles), self.name) + redrawstatus + endwhile + endif + + if !empty(a:context.source__processes) + for process in a:context.source__processes + call neobundle#installer#check_output(a:context, process, 1) + endfor + + " Filter eof processes. + call filter(a:context.source__processes, '!v:val.eof') + else + call neobundle#installer#update_log( + \ neobundle#installer#get_updated_bundles_message( + \ a:context.source__synced_bundles), 1) + call neobundle#installer#update_log( + \ neobundle#installer#get_errored_bundles_message( + \ a:context.source__errored_bundles), 1) + call neobundle#installer#update( + \ a:context.source__synced_bundles) + + " Finish. + call neobundle#installer#update_log('Completed.', 1) + + let a:context.is_async = 0 + endif + + return map(neobundle#installer#get_updates_log()[len(old_msgs) :], "{ + \ 'word' : (v:val =~ '^\\s*\\h\\w*://' ? ' -> diff URI' : v:val), + \ 'is_multiline' : 1, + \ 'kind' : (v:val =~ '^\\s*\\h\\w*://' ? 'uri' : 'word'), + \ 'action__uri' : substitute(v:val, '^\\s\\+', '', ''), + \}") +endfunction"}}} + +function! s:source_install.complete(args, context, arglead, cmdline, cursorpos) abort "{{{ + return ['!'] + + \ neobundle#commands#complete_bundles(a:arglead, a:cmdline, a:cursorpos) +endfunction"}}} + +let s:source_update = deepcopy(s:source_install) +let s:source_update.name = 'neobundle/update' +let s:source_update.description = 'update bundles' + +function! s:source_update.hooks.on_init(args, context) abort "{{{ + let a:context.source__bang = + \ index(a:args, 'all') >= 0 ? 2 : 1 + let a:context.source__not_fuzzy = index(a:args, '!') >= 0 + let bundle_names = filter(copy(a:args), + \ "v:val !=# 'all' && v:val !=# '!'") + call s:init(a:context, bundle_names) +endfunction"}}} + +function! s:init(context, bundle_names) abort "{{{ + let a:context.source__synced_bundles = [] + let a:context.source__errored_bundles = [] + + let a:context.source__processes = [] + + let a:context.source__number = 0 + + let a:context.source__bundles = !a:context.source__bang ? + \ neobundle#get_force_not_installed_bundles(a:bundle_names) : + \ empty(a:bundle_names) ? + \ neobundle#config#get_enabled_bundles() : + \ a:context.source__not_fuzzy ? + \ neobundle#config#search(a:bundle_names) : + \ neobundle#config#fuzzy_search(a:bundle_names) + + call neobundle#installer#_load_install_info( + \ a:context.source__bundles) + + let reinstall_bundles = + \ neobundle#installer#get_reinstall_bundles( + \ a:context.source__bundles) + if !empty(reinstall_bundles) + call neobundle#installer#reinstall(reinstall_bundles) + endif + + let a:context.source__max_bundles = + \ len(a:context.source__bundles) + + call neobundle#installer#clear_log() + + if empty(a:context.source__bundles) + let a:context.is_async = 0 + call neobundle#installer#error( + \ 'Target bundles not found. You may use wrong bundle name.') + else + call neobundle#installer#update_log( + \ 'Update started: ' . strftime('(%Y/%m/%d %H:%M:%S)')) + endif +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/dot_vim/bundle/neobundle.vim/autoload/unite/sources/neobundle_lazy.vim b/dot_vim/bundle/neobundle.vim/autoload/unite/sources/neobundle_lazy.vim new file mode 100644 index 0000000..e965aaa --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/unite/sources/neobundle_lazy.vim @@ -0,0 +1,76 @@ +"============================================================================= +" FILE: neobundle_lazy.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +function! unite#sources#neobundle_lazy#define() abort "{{{ + return s:source +endfunction"}}} + +let s:source = { + \ 'name' : 'neobundle/lazy', + \ 'description' : 'candidates from lazy bundles', + \ 'action_table' : {}, + \ 'default_action' : 'source', + \ } + +function! s:source.gather_candidates(args, context) abort "{{{ + let _ = [] + for bundle in filter(copy(neobundle#config#get_neobundles()), + \ '!v:val.sourced') + let name = substitute(bundle.orig_name, + \ '^\%(https\?\|git\)://\%(github.com/\)\?', '', '') + let dict = { + \ 'word' : name, + \ 'kind' : 'neobundle', + \ 'action__path' : bundle.path, + \ 'action__directory' : bundle.path, + \ 'action__bundle' : bundle, + \ 'action__bundle_name' : bundle.name, + \ 'source__uri' : bundle.uri, + \ } + call add(_, dict) + endfor + + return _ +endfunction"}}} + +" Actions "{{{ +let s:source.action_table.source = { + \ 'description' : 'source bundles', + \ 'is_selectable' : 1, + \ 'is_invalidate_cache' : 1, + \ } +function! s:source.action_table.source.func(candidates) abort "{{{ + call call('neobundle#config#source', + \ map(copy(a:candidates), 'v:val.action__bundle_name')) +endfunction"}}} +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/dot_vim/bundle/neobundle.vim/autoload/unite/sources/neobundle_log.vim b/dot_vim/bundle/neobundle.vim/autoload/unite/sources/neobundle_log.vim new file mode 100644 index 0000000..b43601f --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/unite/sources/neobundle_log.vim @@ -0,0 +1,66 @@ +"============================================================================= +" FILE: neobundle/log.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +function! unite#sources#neobundle_log#define() abort "{{{ + return s:source +endfunction"}}} + +let s:source = { + \ 'name' : 'neobundle/log', + \ 'description' : 'print previous neobundle install logs', + \ 'syntax' : 'uniteSource__NeoBundleLog', + \ 'hooks' : {}, + \ } + +function! s:source.hooks.on_syntax(args, context) abort "{{{ + syntax match uniteSource__NeoBundleLog_Message /.*/ + \ contained containedin=uniteSource__NeoBundleLog + highlight default link uniteSource__NeoBundleLog_Message Comment + syntax match uniteSource__NeoBundleLog_Progress /(.\{-}):\s*.*/ + \ contained containedin=uniteSource__NeoBundleLog + highlight default link uniteSource__NeoBundleLog_Progress String + syntax match uniteSource__NeoBundleLog_Source /|.\{-}|/ + \ contained containedin=uniteSource__NeoBundleLog_Progress + highlight default link uniteSource__NeoBundleLog_Source Type + syntax match uniteSource__NeoBundleLog_URI /-> diff URI/ + \ contained containedin=uniteSource__NeoBundleLog + highlight default link uniteSource__NeoBundleLog_URI Underlined +endfunction"}}} + +function! s:source.gather_candidates(args, context) abort "{{{ + return map(copy(neobundle#installer#get_log()), "{ + \ 'word' : (v:val =~ '^\\s*\\h\\w*://' ? ' -> diff URI' : v:val), + \ 'kind' : (v:val =~ '^\\s*\\h\\w*://' ? 'uri' : 'word'), + \ 'action__uri' : substitute(v:val, '^\\s\\+', '', ''), + \ }") +endfunction"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/dot_vim/bundle/neobundle.vim/autoload/unite/sources/neobundle_search.vim b/dot_vim/bundle/neobundle.vim/autoload/unite/sources/neobundle_search.vim new file mode 100644 index 0000000..655a4ba --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/autoload/unite/sources/neobundle_search.vim @@ -0,0 +1,265 @@ +"============================================================================= +" FILE: neobundle_search.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +let s:Cache = unite#util#get_vital_cache() + +function! unite#sources#neobundle_search#define() abort "{{{ + " Init sources. + if !exists('s:neobundle_sources') + let s:neobundle_sources = {} + for define in map(split(globpath(&runtimepath, + \ 'autoload/neobundle/sources/*.vim', 1), '\n'), + \ "neobundle#sources#{fnamemodify(v:val, ':t:r')}#define()") + for dict in (type(define) == type([]) ? define : [define]) + if !empty(dict) && !has_key(s:neobundle_sources, dict.name) + let s:neobundle_sources[dict.name] = dict + endif + endfor + unlet define + endfor + endif + + return s:source +endfunction"}}} + +let s:plugin_names = [] + +" Source rec. +let s:source = { + \ 'name' : 'neobundle/search', + \ 'description' : 'search plugins for neobundle', + \ 'hooks' : {}, + \ 'action_table' : {}, + \ 'default_action' : 'yank', + \ 'max_candidates' : 200, + \ 'syntax' : 'uniteSource__NeoBundleSearch', + \ 'parents' : ['uri'], + \ } + +function! s:source.hooks.on_init(args, context) abort "{{{ + let a:context.source__sources = copy(s:neobundle_sources) + if !empty(a:args) + let a:context.source__sources = filter( + \ a:context.source__sources, + \ 'index(a:args, v:key) >= 0') + endif + + let a:context.source__input = a:context.input + if a:context.source__input == '' + let a:context.source__input = + \ unite#util#input('Please input search word: ', '', + \ 'customlist,unite#sources#neobundle_search#complete_plugin_names') + endif +endfunction"}}} +function! s:source.gather_candidates(args, context) abort "{{{ + if neobundle#util#is_sudo() + call neobundle#util#print_error( + \ '"sudo vim" is detected. This feature is disabled.') + return [] + endif + + call unite#print_source_message('Search word: ' + \ . a:context.source__input, s:source.name) + + let candidates = [] + let a:context.source__source_names = [] + + let s:plugin_names = [] + + for source in values(a:context.source__sources) + let source_candidates = source.gather_candidates(a:args, a:context) + let source_name = get(source, 'short_name', source.name) + for candidate in source_candidates + let candidate.source__source = source_name + if !has_key(candidate, 'source__script_type') + let candidate.source__script_type = '' + endif + if !has_key(candidate, 'source__description') + let candidate.source__description = '' + endif + endfor + + let candidates += source_candidates + call add(a:context.source__source_names, source_name) + + let s:plugin_names += map(copy(source_candidates), 'v:val.source__name') + endfor + + call s:initialize_plugin_names(a:context) + + return filter(candidates, + \ 'stridx(v:val.word, a:context.source__input) >= 0') +endfunction"}}} + +function! s:source.complete(args, context, arglead, cmdline, cursorpos) abort "{{{ + let arglead = get(a:args, -1, '') + return filter(keys(s:neobundle_sources), + \ "stridx(v:val, arglead) == 0") +endfunction"}}} + +function! s:source.hooks.on_syntax(args, context) abort "{{{ + syntax match uniteSource__NeoBundleSearch_DescriptionLine + \ / -- .*$/ + \ contained containedin=uniteSource__NeoBundleSearch + syntax match uniteSource__NeoBundleSearch_Description + \ /.*$/ + \ contained containedin=uniteSource__NeoBundleSearch_DescriptionLine + syntax match uniteSource__NeoBundleSearch_Marker + \ / -- / + \ contained containedin=uniteSource__NeoBundleSearch_DescriptionLine + syntax match uniteSource__NeoBundleSearch_Install + \ / Installed / + \ contained containedin=uniteSource__NeoBundleSearch + highlight default link uniteSource__NeoBundleSearch_Install Statement + highlight default link uniteSource__NeoBundleSearch_Marker Special + highlight default link uniteSource__NeoBundleSearch_Description Comment +endfunction"}}} + +" Actions "{{{ +let s:source.action_table.yank = { + \ 'description' : 'yank plugin settings', + \ 'is_selectable' : 1, + \ } +function! s:source.action_table.yank.func(candidates) abort "{{{ + let @" = join(map(a:candidates, + \ "'NeoBundle ' . s:get_neobundle_args(v:val)"), "\n") + if has('clipboard') + call setreg(v:register, @") + endif + + echo 'Yanked plugin settings!' +endfunction"}}} + +let s:source.action_table.install = { + \ 'description' : 'direct install plugins', + \ 'is_selectable' : 1, + \ 'is_quit' : 0, + \ } +function! s:source.action_table.install.func(candidates) abort "{{{ + for candidate in a:candidates + execute 'NeoBundleDirectInstall' s:get_neobundle_args(candidate) + endfor +endfunction"}}} +"}}} + +" Filters "{{{ +function! s:source.source__sorter(candidates, context) abort "{{{ + return s:sort_by(a:candidates, 'v:val.source__name') +endfunction"}}} +function! s:source.source__converter(candidates, context) abort "{{{ + let max_plugin_name = max(map(copy(a:candidates), + \ 'len(v:val.source__name)')) + let max_script_type = max(map(copy(a:candidates), + \ 'len(v:val.source__script_type)')) + let max_source_name = max(map(copy(a:context.source__source_names), + \ 'len(v:val)')) + let format = '%-'. max_plugin_name .'s %-'. + \ max_source_name .'s %-'. max_script_type .'s -- %s' + + for candidate in a:candidates + let candidate.abbr = printf(format, + \ candidate.source__name, candidate.source__source, + \ candidate.source__script_type, + \ (neobundle#is_installed(candidate.source__name) ? + \ 'Installed' : candidate.source__description)) + let candidate.is_multiline = 1 + let candidate.kind = + \ get(candidate, 'action__path', '') != '' ? + \ 'file' : 'common' + endfor + + return a:candidates +endfunction"}}} + +let s:source.sorters = s:source.source__sorter +let s:source.converters = s:source.source__converter +"}}} + +" Misc. "{{{ +function! s:sort_by(list, expr) abort + let pairs = map(a:list, printf('[v:val, %s]', a:expr)) + return map(s:sort(pairs, + \ 'a:a[1] == a:b[1] ? 0 : a:a[1] > a:b[1] ? 1 : -1'), 'v:val[0]') +endfunction + +" Sorts a list with expression to compare each two values. +" a:a and a:b can be used in {expr}. +function! s:sort(list, expr) abort + if type(a:expr) == type(function('function')) + return sort(a:list, a:expr) + endif + let s:expr = a:expr + return sort(a:list, 's:_compare') +endfunction + +function! s:_compare(a, b) abort + return eval(s:expr) +endfunction + +function! s:get_neobundle_args(candidate) abort + return string(substitute(a:candidate.source__path, + \ '^https://github.com/', '', '')) + \ . (empty(a:candidate.source__options) ? + \ '' : ', ' . string(a:candidate.source__options)) + \ . (a:candidate.source__description == '' ? '' : + \ ' " ' . a:candidate.source__description) +endfunction + +function! unite#sources#neobundle_search#complete_plugin_names(arglead, cmdline, cursorpos) abort "{{{ + return filter(s:get_plugin_names(), "stridx(v:val, a:arglead) == 0") +endfunction"}}} + +function! s:initialize_plugin_names(context) abort "{{{ + let cache_dir = neobundle#get_neobundle_dir() . '/.neobundle' + let path = 'plugin_names' + + if a:context.is_redraw || !s:Cache.filereadable(cache_dir, path) + " Convert cache data. + call s:Cache.writefile(cache_dir, path, [string(s:plugin_names)]) + endif + + return s:get_plugin_names() +endfunction"}}} + +function! s:get_plugin_names() abort "{{{ + let cache_dir = neobundle#get_neobundle_dir() . '/.neobundle' + let path = 'plugin_names' + + if empty(s:plugin_names) && s:Cache.filereadable(cache_dir, path) + sandbox let s:plugin_names = + \ eval(get(s:Cache.readfile(cache_dir, path), 0, '[]')) + endif + + return neobundle#util#uniq(s:plugin_names) +endfunction"}}} +"}}} + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: foldmethod=marker diff --git a/dot_vim/bundle/neobundle.vim/bin/executable_install.sh b/dot_vim/bundle/neobundle.vim/bin/executable_install.sh new file mode 100644 index 0000000..a34de5c --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/bin/executable_install.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# Standalone installer for Unixs +# Original version is created by shoma2da +# https://github.com/shoma2da/neobundle_installer + +# Installation directory +BUNDLE_DIR=~/.vim/bundle +INSTALL_DIR="$BUNDLE_DIR/neobundle.vim" +echo "$INSTALL_DIR" +if [ -e "$INSTALL_DIR" ]; then + echo "$INSTALL_DIR already exists!" +fi + +NVIM_DIR=~/.config/nvim +NVIM_BUNDLE_DIR="$NVIM_DIR/bundle" +NVIM_INSTALL_DIR="$NVIM_BUNDLE_DIR/neobundle.vim" +echo "$NVIM_INSTALL_DIR" +if [ -e "$NVIM_INSTALL_DIR" ]; then + echo "$NVIM_INSTALL_DIR already exists!" +fi + +if [ -e "$INSTALL_DIR" ] && [ -e "$NVIM_INSTALL_DIR" ]; then + exit 1 +fi + +# check git command +if type git; then + : # You have git command. No Problem. +else + echo 'Please install git or update your path to include the git executable!' + exit 1 +fi + +# make bundle dir and fetch neobundle +echo "Begin fetching NeoBundle..." +if ! [ -e "$INSTALL_DIR" ]; then + mkdir -p "$BUNDLE_DIR" + git clone https://github.com/Shougo/neobundle.vim "$INSTALL_DIR" +fi + +if type nvim > /dev/null 2>&1 && ! [ -e "$NVIM_INSTALL_DIR" ]; then + mkdir -p "$NVIM_BUNDLE_DIR" + git clone https://github.com/Shougo/neobundle.vim "$NVIM_INSTALL_DIR" +fi + +echo "Done." + +# write initial setting for .vimrc +echo "Please add the following settings for NeoBundle to the top of your .vimrc file:" +{ + echo "" + echo "" + echo "\"NeoBundle Scripts-----------------------------" + echo "if &compatible" + echo " set nocompatible \" Be iMproved" + echo "endif" + echo "" + echo "\" Required:" + echo "set runtimepath+=$BUNDLE_DIR/neobundle.vim/" + echo "" + echo "\" Required:" + echo "call neobundle#begin(expand('$BUNDLE_DIR'))" + echo "" + echo "\" Let NeoBundle manage NeoBundle" + echo "\" Required:" + echo "NeoBundleFetch 'Shougo/neobundle.vim'" + echo "" + echo "\" Add or remove your Bundles here:" + echo "NeoBundle 'Shougo/neosnippet.vim'" + echo "NeoBundle 'Shougo/neosnippet-snippets'" + echo "NeoBundle 'tpope/vim-fugitive'" + echo "NeoBundle 'ctrlpvim/ctrlp.vim'" + echo "NeoBundle 'flazz/vim-colorschemes'" + echo "" + echo "\" You can specify revision/branch/tag." + echo "NeoBundle 'Shougo/vimshell', { 'rev' : '3787e5' }" + echo "" + echo "\" Required:" + echo "call neobundle#end()" + echo "" + echo "\" Required:" + echo "filetype plugin indent on" + echo "" + echo "\" If there are uninstalled bundles found on startup," + echo "\" this will conveniently prompt you to install them." + echo "NeoBundleCheck" + echo "\"End NeoBundle Scripts-------------------------" + echo "" + echo "" +} + +# write initial setting for ~/.config/nvim/init.vim +if type nvim > /dev/null 2>&1; then + echo "Please add the following settings for NeoBundle to the top of your init.vim file:" + { + echo "" + echo "" + echo "\"NeoBundle Scripts-----------------------------" + echo "if has('vim_starting')" + echo " \" Required:" + echo " set runtimepath+=$NVIM_BUNDLE_DIR/neobundle.vim/" + echo "endif" + echo "" + echo "\" Required:" + echo "call neobundle#begin(expand('$NVIM_BUNDLE_DIR'))" + echo "" + echo "\" Let NeoBundle manage NeoBundle" + echo "\" Required:" + echo "NeoBundleFetch 'Shougo/neobundle.vim'" + echo "" + echo "\" Add or remove your Bundles here:" + echo "NeoBundle 'Shougo/neosnippet.vim'" + echo "NeoBundle 'Shougo/neosnippet-snippets'" + echo "NeoBundle 'tpope/vim-fugitive'" + echo "NeoBundle 'ctrlpvim/ctrlp.vim'" + echo "NeoBundle 'flazz/vim-colorschemes'" + echo "" + echo "\" You can specify revision/branch/tag." + echo "NeoBundle 'Shougo/vimshell', { 'rev' : '3787e5' }" + echo "" + echo "\" Required:" + echo "call neobundle#end()" + echo "" + echo "\" Required:" + echo "filetype plugin indent on" + echo "" + echo "\" If there are uninstalled bundles found on startup," + echo "\" this will conveniently prompt you to install them." + echo "NeoBundleCheck" + echo "\"End NeoBundle Scripts-------------------------" + echo "" + echo "" + } +fi +echo "Done." + +echo "Complete setup NeoBundle!" diff --git a/dot_vim/bundle/neobundle.vim/bin/executable_neoinstall b/dot_vim/bundle/neobundle.vim/bin/executable_neoinstall new file mode 100644 index 0000000..914b3d9 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/bin/executable_neoinstall @@ -0,0 +1,12 @@ +#!/bin/sh + +# Detect .vimrc path. +VIMRC=$HOME/.vimrc + +if [ ! -e $VIMRC ]; then + VIMRC=$HOME/.vim/vimrc +fi + +vim -N -u $VIMRC -c "try | NeoBundleUpdate! $* | finally | qall! | endtry" \ + -U NONE -i NONE -V1 -e -s +echo '' diff --git a/dot_vim/bundle/neobundle.vim/bin/neoinstall.bat b/dot_vim/bundle/neobundle.vim/bin/neoinstall.bat new file mode 100644 index 0000000..77d4156 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/bin/neoinstall.bat @@ -0,0 +1,30 @@ +@echo off +for /F "usebackq" %%t in (`where vim`) do SET _VIM=%%t +set VIM=%_VIM:\vim.exe=% +if "%HOME%"=="" set HOME=%USERPROFILE% +set _VIMRC=%HOME%\_vimrc +if exist %_VIMRC% goto EXEC_NEOBUNDLE_INSTALL +if not exist %_VIMRC% goto DOTVIMRC + +:DOTVIMRC +set VIMRC=%HOME%\.vimrc +if exist %VIMRC% goto EXEC_NEOBUNDLE_INSTALL +if not exist %VIMRC% goto VIMFILES + +:VIMFILES +set VIMRC=%HOME%\vimfiles\vimrc +if exist %VIMRC% goto EXEC_NEOBUNDLE_INSTALL +if not exist %VIMRC% goto ORIGIN_VIM + +:ORIGIN_VIM +set VIMRC=%VIM%\_vimrc +if exist %VIMRC% goto EXEC_NEOBUNDLE_INSTALL +if not exist %VIMRC% goto NO_EXEC_NEOBUNDLE_INSTALL + +@echo on +:EXEC_NEOBUNDLE_INSTALL +vim -N -u %VIMRC% -c "try | NeoBundleUpdate! %* | finally | qall! | endtry" -U NONE -i NONE -V1 -e -s + + +:NO_EXEC_NEOBUNDLE_INSTALL +echo 'vimrc is NotFound.' diff --git a/dot_vim/bundle/neobundle.vim/bin/neoinstall_novimproc.bat b/dot_vim/bundle/neobundle.vim/bin/neoinstall_novimproc.bat new file mode 100644 index 0000000..5dda690 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/bin/neoinstall_novimproc.bat @@ -0,0 +1,30 @@ +@echo off +for /F "usebackq" %%t in (`where vim`) do SET _VIM=%%t +set VIM=%_VIM:\vim.exe=% +if "%HOME%"=="" set HOME=%USERPROFILE% +set _VIMRC=%HOME%\_vimrc +if exist %_VIMRC% goto EXEC_NEOBUNDLE_INSTALL +if not exist %_VIMRC% goto DOTVIMRC + +:DOTVIMRC +set VIMRC=%HOME%\.vimrc +if exist %VIMRC% goto EXEC_NEOBUNDLE_INSTALL +if not exist %VIMRC% goto VIMFILES + +:VIMFILES +set VIMRC=%HOME%\vimfiles\vimrc +if exist %VIMRC% goto EXEC_NEOBUNDLE_INSTALL +if not exist %VIMRC% goto ORIGIN_VIM + +:ORIGIN_VIM +set VIMRC=%VIM%\_vimrc +if exist %VIMRC% goto EXEC_NEOBUNDLE_INSTALL +if not exist %VIMRC% goto NO_EXEC_NEOBUNDLE_INSTALL + +@echo on +:EXEC_NEOBUNDLE_INSTALL +vim -N -u %VIMRC% --cmd "let g:vimproc#disable = 1" -c "try | NeoBundleUpdate! %* | finally | qall! | endtry" -U NONE -i NONE -V1 -e -s + + +:NO_EXEC_NEOBUNDLE_INSTALL +echo 'vimrc is NotFound.' diff --git a/dot_vim/bundle/neobundle.vim/doc/neobundle.txt b/dot_vim/bundle/neobundle.vim/doc/neobundle.txt new file mode 100644 index 0000000..ce9f6be --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/doc/neobundle.txt @@ -0,0 +1,1753 @@ +*neobundle.txt* Next generation Vim package manager + +Version: 4.0 +Author: Shougo + Copyright (C) 2010 http://github.com/gmarik +License: MIT license {{{ + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +}}} + +CONTENTS *neobundle-contents* + +Introduction |neobundle-introduction| +Usage |neobundle-usage| +Install |neobundle-install| +Interface |neobundle-interface| + Functions |neobundle-functions| + Commands |neobundle-commands| + Variables |neobundle-variables| + Options |neobundle-options| +Configuration Examples |neobundle-examples| +Migrating from Pathogen |neobundle-migrate-from-pathogen| +Unite sources |neobundle-unite-sources| +FAQ |neobundle-faq| + +============================================================================== +INTRODUCTION *neobundle-introduction* + +*neobundle* is the next generation Vim package manager. This plugin is based on +Vundle (https://github.com/gmarik/vundle), but I renamed and added tons of +features. Because, Vundle's author does not want to add huge features in +Vundle. + +Note: Neobundle is not a stable plugin manager. If you want a stable plugin +manager, you should use Vundle plugin. It works well widely and it is more +tested. If you want to use extended features, you can use neobundle. + +Vundle features: Stable, simple, good for beginners +Neobundle features: Early development (may break compatibility), very complex, +good for plugin power users (for example, 50+ plugins and over 1000 lines +.vimrc, ...) + +Neobundle features: + * Uses |vimproc| if available + * Uses neovim async jobs feature if available + * |unite.vim| interface + * Revision lock + * Supports svn/Mercurial repositories besides Git + * Can use a different base path + * Vundle like syntax + +============================================================================== +USAGE *neobundle-usage* + +Refer to the example: +|neobundle-examples| + +Run this command to update your bundled plugins: +> + :NeoBundleUpdate +< +Note: To use the unite.vim interface, run this command (requires |unite.vim|): +> + :Unite neobundle/update +< +Settings for this plugin are compatible with Vundle.vim :-) + +You can search popular plugins and add neobundle settings at Vimpusher +(registration required): + http://www.vimpusher.com/ +Or at vim-scripts.org: + http://vim-scripts.org/ + +Neobundle now features a plugin search for vim.org scripts (requires +|unite.vim|) +> + :Unite neobundle/search +< +============================================================================== +INSTALL *neobundle-install* + +Requirements: +* Vim 7.2.051 or above. +* "git" command in $PATH (if you want to install github or vim.org plugins) + +First of all, git clone the repository. + +Note: You need to have git installed. +> + $ mkdir ~/.vim/bundle + $ git clone https://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim +< +And set up a path to the repository directory. +> + set runtimepath+={path to neobundle directory} +< +Example: +> + set runtimepath+=~/.vim/bundle/neobundle.vim +< +Now configure your bundles. (Refer to |neobundle-examples|) + +Run the |:NeoBundleInstall| command to install your plugins. +> + $ vim +NeoBundleInstall +q + +or +> + $ . ~/.vim/bundle/neobundle.vim/bin/neoinstall +< +Note: To use neoinstall in Windows, Vim command must be in $PATH. > + > .vim/bundle/neobundle.vim/bin/neoinstall +Note: To update and build vimproc in Windows, you can use +"neoinstall_novimproc" command. > + > .vim/bundle/neobundle.vim/bin/neoinstall_novimproc vimproc.vim + +neoinstall can take arguments (install/update plugin names). +> + # Build vimproc before install plugins + $ . ~/.vim/bundle/neobundle.vim/bin/neoinstall vimproc.vim +< +============================================================================== +INTERFACE *neobundle-interface* + +------------------------------------------------------------------------------ +FUNCTIONS *neobundle-functions* + +neobundle#begin([{base-path}]) *neobundle#begin()* + Initializes neobundle.vim and start neobundle bundles + configuration block. + {base-path} is where your downloaded plugins will be placed. + + If {base-path} is omitted, neobundle looks for "~/.vim/bundle" + or "~/.config/nvim/bundle" directory. + Note: But recommend you to specify the {base-path}. + + Note: You must not call the function inside a + "has('vim_starting')" block. + Note: You can use |neobundle#begin()| / |neobundle#end()| block + only once in your .vimrc. + + Note: It executes ":filetype off" automatically. + Note: You must execute |:NeoBundle| commands in + |neobundle#begin()| or |neobundle#append()| block. +> + if &compatible + set nocompatible + endif + set runtimepath+={path to neobundle directory} + + call neobundle#begin(expand('~/.vim/bundle')) + + NeoBundle 'https://github.com/Shougo/neocomplcache.git' + ... + + call neobundle#end() + + filetype plugin indent on +< + +neobundle#append() *neobundle#append()* + Start neobundle bundles configuration block. + You can use multiple |neobundle#append()| / |neobundle#end()| + blocks in your .vimrc. + Note: It does not initialize neobundle. You must call + |neobundle#begin()| at first. + Note: It executes ":filetype off" automatically. + Note: You must execute |:NeoBundle| commands in + |neobundle#begin()| or |neobundle#append()| block. + +neobundle#end() *neobundle#end()* + End neobundle bundles configuration block. + +neobundle#add({repository}[, {options}]) *neobundle#add()* + The function version of |:NeoBundle|. + Note: You must call it in |neobundle#begin()| or + |neobundle#append()| block. + +neobundle#add_meta({repository}[, {options}]) *neobundle#add_meta()* + Initialize a bundle from the metadata {name}. + Note: You must call it in |neobundle#begin()| or + |neobundle#append()| block. > + + " It installs vimshell and vimproc + call neobundle#add_meta('vimshell') + +neobundle#source({bundle-names}) *neobundle#source()* + Same as |:NeoBundleSource|. + {bundle-names} is a list of bundle names. + + *neobundle#exists_not_installed_bundles()* +neobundle#exists_not_installed_bundles() + Checks if there are any bundles that are not installed. + + *neobundle#get_not_installed_bundle_names()* +neobundle#get_not_installed_bundle_names() + Returns the names of bundles that are not installed. + + *neobundle#is_installed()* +neobundle#is_installed({bundle-name}) + Checks if bundle {bundle-name} is installed. + + *neobundle#is_sourced()* +neobundle#is_sourced({bundle-name}) + Checks if bundle {bundle-name} is loaded. + + *neobundle#local()* +neobundle#local({directory}, [{options}, [{names}]]) + Adds the subdirectories in {directory} to + 'runtimepath', like |pathogen| does. See |neobundle-options| + for keys to set in {options}. + If {names} is given, {names} directories are only loaded. + {names} is |wildcards| list. + Note: |:NeoBundleLocal| is a shortcut for this function. +> + " Load plugin from "~/.vim/bundle". + call neobundle#local("~/.vim/bundle", {}) + " Load plugin1 and plugin2 from "~/.vim/bundle". + call neobundle#local("~/.vim/bundle", + \ {}, ['plugin1', 'plugin2', 'vim-*', '*.vim']) +< + *neobundle#load_toml()* +neobundle#load_toml({filename}, [{options}]) + Load TOML plugin configurations from {filename}. See + |neobundle-options| for keys to set in {options}. + Note: TOML parser is slow. You should use neobundle cache + feature. + + TOML file format specification: + https://github.com/toml-lang/toml + Note: Original TOML parser is created by kamichidu. + https://github.com/kamichidu +> + " Load toml from "~/.vim/bundle.toml". + call neobundle#load_toml("~/.vim/bundle.toml", {}) +< + TOML file sample is here: +> + # TOML sample + [[plugins]] + # repository name is required. + repo = 'kana/vim-niceblock' + on_map = '' + + [[plugins]] + repo = 'Shougo/neosnippet.vim' + depends = ['Shougo/neosnippet-snippets', + 'Shougo/context_filetype.vim'] + on_i = 1 + on_ft = 'snippet' + + [[plugins.depends]] + repo = 'honza/vim-snippet' + name = 'honza-snippet' + + [[plugins]] + repo = 'Shougo/neobundle.vim' + fetch = 1 + + [[plugins]] + repo = 'Shougo/vimproc.vim' + + [plugins.build] + windows = 'tools\\update-dll-mingw' + cygwin = 'make -f make_cygwin.mak' + mac = 'make -f make_mac.mak' + unix = 'make -f make_unix.mak' +< +neobundle#get({bundle-name}) *neobundle#get()* + Get the neobundle options dictionary for {bundle-name}. + Useful for setting hooks. + Example: +> + NeoBundle 'tyru/open-browser.vim', '', 'same', { + \ 'on_map' : '', + \ } + nmap gs (open-browser-wwwsearch) + + let bundle = neobundle#get('open-browser.vim') + function! bundle.hooks.on_source(bundle) + nnoremap (open-browser-wwwsearch) + \ :call www_search() + function! s:www_search() + let search_word = input('Please input search word: ', '', + \ 'customlist,wwwsearch#cmd_Wwwsearch_complete') + if search_word != '' + execute 'OpenBrowserSearch' escape(search_word, '"') + endif + endfunction + endfunction +< +neobundle#get_hooks({bundle-name}) *neobundle#get_hooks()* + Get the neobundle "hooks" dictionary for {bundle-name}. + Useful for setting hooks. + +neobundle#call_hook({hook-name}) *neobundle#call_hook()* + Calls the hook {hook-name}. + Note: If {hook-name} is "on_source", neobundle will call + "on_source" hooks in sourced bundles. + +neobundle#bundle({repository}, [{options}]) *neobundle#bundle()* + Initialize a bundle. + If {repository} is list, you can initialize options in + multiple bundles. + Note: You can use this function instead of |:NeoBundle| + command. + +neobundle#config({bundle-name}, {options}) *neobundle#config()* +neobundle#config({options}) + Change bundle options for {bundle-name}. + It you omit {bundle-name}, it uses |neobundle#tapped| + variable. + If {bundle-name} is list, you can change options in multiple + bundles. + If {bundle-name} is not configured, it will print error + messages. + If {bundle-name} is already loaded, it will ignore. + + Note: To lazy-load a plugin, you can set the "lazy" flag after + calling |:NeoBundle| or |:NeoBundleLocal|. + Note: You must call it within + |neobundle#begin()|/|neobundle#end()| block. +> + NeoBundle 'Shougo/neocomplcache' + call neobundle#config('neocomplcache', { + \ 'lazy' : 1, + \ 'on_i' : 1, + \ }) +< +neobundle#tap({bundle-name}) *neobundle#tap()* + Initialize |neobundle#tapped| and |neobundle#hooks| variable + as {bundle-name} bundle. + It returns non-zero if {bundle-name} is exists and not + disabled. +> + if neobundle#tap('foo') + " If foo plugin is installed and enabled + + " neobundle#hooks is syntax sugar + function! neobundle#hooks.on_source(bundle) + " Settings, Init, ... + " Timing of adding rtp + " Like vimrc time + let g:foo#bar = 1 + let g:foo#path = a:bundle.path + call foo#baz() + endfunction + + function! neobundle#hooks.on_post_source(bundle) + " Settings, Init, ... + " Timing of after source plugin files + " Like VimEnter time + let g:foo#bar = 3 + call foo#bazbaz() + endfunction + + " Define plugin mappings, commands, ... + map f (foo) + command! FOO call foo#foo() + + call neobundle#untap() + endif +< +neobundle#untap() *neobundle#untap()* + Clear current |neobundle#tapped| and |neobundle#hooks| variable. + +neobundle#has_cache() *neobundle#has_cache()* + Checks if a cache file is available. + Note: It is deprecated. You should use + |neobundle#load_cache()| instead of it. + +neobundle#load_cache([{vimrcs}]) *neobundle#load_cache()* + Load plugin configuration from the cache file, + which is located in `neobundle#get_rtp_dir() . '/cache'`. + {vimrcs} is a list of compared .vimrc and/or other configuration + files. The default is |$MYVIMRC|. + + It returns 1, if the cache file is old or invalid or not + found. + + The default cache location can be overridden through + |g:neobundle#cache_file|. +> + if neobundle#load_cache() + " My Bundles here: + " ... + NeoBundleSaveCache + endif +< + If you use multiple configuration files, +> + if neobundle#load_cache($MYVIMRC, 'plugin.vim', 'plugin.toml') + " My Bundles here or other files spcified as arguments + " ... + NeoBundleSaveCache + endif +< +------------------------------------------------------------------------------ +COMMANDS *neobundle-commands* + + *:NeoBundle* +:NeoBundle {repository} [[,{revision}] [,{options}]] +:NeoBundle {repository} ,{revision}, {default} [,{options}]] + Initialize a bundle. + {repository} is the repository URI. {revision} is the desired + revision or branch name. If omitted, the current latest + revision will be used. {default} is a "default options + name" (See |g:neobundle#default_options|). + Note: Don't set neobundle setting in .gvimrc! + Note: If you omit the protocol (ex: https) for a git + repo, |g:neobundle#types#git#default_protocol| is used. + Note: |neobundle-options-lazy| is set automatically. + + Note: If you manage bundle by neobundle, it may be error + occurred when update bundles. + + See |neobundle-options| for what to set in {options}. + +:NeoBundleInstall [{name}...] *:NeoBundleInstall* + Installs plugins specified by {name}. {name} is + fuzzy-searched. If {name} is omitted, all configured plugins + are installed. + Note: {name}s are plugin names like "neobundle.vim", not + "Shougo/neobundle.vim". + Note: neobundle cannot use neovim async jobs feature in the + command. If you want to use the feature, you should use unite + interface instead. + +:NeoBundleInstall! [{name}...] *:NeoBundleInstall!* + Same as |:NeoBundleUpdate|. + +:NeoBundleUpdate [{name}...] *:NeoBundleUpdate* + Installs and updates plugins specified by {name}. {name} is + fuzzy-searched. If {name} is omitted, all configured plugins + are installed and updated, except if they are outdated or have + the "frozen" option set. + Note: {name}s are plugin names like "neobundle.vim", not + "Shougo/neobundle.vim". + Note: neobundle cannot use neovim async jobs feature in the + command. If you want to use the feature, you should use unite + interface instead. + +:NeoBundleUpdate! [{name}...] *:NeoBundleUpdate!* + Same as |:NeoBundleUpdate|, except that it disregards the + "frozen" option. + +:NeoBundleReinstall [{name}...] *:NeoBundleReinstall* + Reinstalls the bundles specified by {name}. + If the bundles are "none" type or local plugins, they are + ignored. + Note: It removes the bundles and installs them. It is the + dangerous command. + +:NeoBundleList *:NeoBundleList* + Prints a list of configured bundles. + +:NeoBundleLog *:NeoBundleLog* + Prints all previous install logs. + +:NeoBundleUpdatesLog *:NeoBundleUpdatesLog* + Prints previous update logs. + +:NeoBundleLocal {base-directory-path} *:NeoBundleLocal* + Registers a bundle from the directories in + {base-directory-path} like pathogen does. + + Note: If you want to use neobundle like pathogen.vim, you + should set a different base path from the standard neobundle + bundles path. +> + NeoBundleLocal ~/.vim/bundle +< + *:NeoBundleLazy* +:NeoBundleLazy {repository} [[,{revision}] [,{options}]] +:NeoBundleLazy {repository} ,{revision}, {default} [,{options}]] + Registers a bundle, but doesn't add it to 'runtimepath'. + Note: If you want to know slow loading plugins, you should use + the external tool or |--startuptime|. + https://github.com/hyiltiz/vim-plugins-profile +> + NeoBundleLazy 'The-NERD-tree', {'augroup' : 'NERDTree'} + NeoBundleSource The-NERD-tree +< + You can use it to load plugins for specific filetypes. +> + NeoBundleLazy 'Rip-Rip/clang_complete' + autocmd FileType c,cpp NeoBundleSource clang_complete +< +:NeoBundleSource [{name}...] *:NeoBundleSource* + |:source| the bundles specified by {name}. + If {name} is omitted, |:source| all lazy bundles. + Note: This command is used to load the bundles configured with + |:NeoBundleLazy|. + +:NeoBundleFetch {repository} [, {options}] *:NeoBundleFetch* + Registers a bundle, but doesn't add it to 'runtimepath'. + Unlike |:NeoBundleLazy|, you cannot load the bundle with + |:NeoBundleSource|. This command is useful for managing + non-Vim plugins using neobundle. +> + NeoBundleFetch 'davidhalter/jedi' +< +:NeoBundleDocs *:NeoBundleDocs* + Execute |:helptags| for all bundles manually. + + *:NeoBundleDirectInstall* +:NeoBundleDirectInstall {repository} [, {options}] + Registers a bundle, and installs it directly. + Note: The settings are saved in "extra_bundles.vim" in + |neobundle#begin()| directory. + Note: To remove direct installed bundles, you must delete + plugin settings manually in "extra_bundles.vim" in + |neobundle#begin()| directory. +> + NeoBundleDirectInstall 'Shougo/neocomplcache' +< + *:NeoBundleExtraEdit* +:NeoBundleExtraEdit + Edit extra bundles configuration easily. + +:NeoBundleDisable {name}... *:NeoBundleDisable* + Disables bundles specified by {name}. If a bundle is + disabled, its path will be removed from 'runtimepath'. + Note: This command must be executed before neobundle loads + the plugins(after |neobundle#end()|). + +:NeoBundleCheck *:NeoBundleCheck* + Check plugins installation. If plugins are not installed, it + will execute |:NeoBundleInstall| automatically. This command + also check documentation directories and will execute + |:NeoBundleDocs| automatically. + +:NeoBundleCheckUpdate [{name}...] *:NeoBundleCheckUpdate* + Check plugins update specified by {name}. If updates are + available, it will execute |:NeoBundleUpdate| automatically. + Note: It is supported in git type only. + + *:NeoBundleCount* +:NeoBundleCount + Show bundles count. You can know how many bundles you have. + + *:NeoBundleGC* +:NeoBundleGC [{bundle-names}] + Execute Garbage Collect commands in bundles. + If {bundle-name} is omit, all bundles will be GCed. + + *:NeoBundleSaveCache* +:NeoBundleSaveCache + Save plugin configuration in the cache file. + Note: It cannot save functions for example "hooks" member. + Note: It is available when loading .vimrc. + + *:NeoBundleLoadCache* +:NeoBundleLoadCache + Load plugin configuration from the cache file, + which is located in `neobundle#get_rtp_dir() . '/cache'`. + + Note: It is deprecated. You should use + |neobundle#load_cache()| instead of it. + + *:NeoBundleClearCache* +:NeoBundleClearCache + Clear the configuration cache file. + + *:NeoBundleRollback* +:NeoBundleRollback {bundle-name} + Rollback {bundle-name} plugin version to previous updated + version. + Note: If you rollbacked the plugin, you cannot update it by + |:NeoBundleUpdate| command. If you want to update it, you + must reinstall the plugin by |:NeoBundleReinstall| command. + + *:NeoBundleRemotePlugins* +:NeoBundleRemotePlugins + Load not loaded neovim |:remote-plugin| and execute + |:UpdateRemotePlugins| command. + It is better than |:UpdateRemotePlugins| for neobundle + autoloading feature. + Note: It is valid in neovim. + +------------------------------------------------------------------------------ +VARIABLES *neobundle-variables* + +g:neobundle#cache_file *g:neobundle#cache_file* + The cache file to use. + + The default is provided through + neobundle#commands#get_default_cache_file(): +> + neobundle#get_rtp_dir() . '/cache' +< +neobundle#tapped *neobundle#tapped* + Current bundle variable set by |neobundle#tap()|. + +neobundle#hooks *neobundle#hooks* + Current bundle hooks variable set by |neobundle#tap()|. + +g:neobundle#default_site *g:neobundle#default_site* + The default repository site if "site" option is omitted. + + Defaults to "github". + +g:neobundle#log_filename *g:neobundle#log_filename* + The log filename. Set it to "" to disable logging. + + Defaults to "". + + *g:neobundle#enable_name_conversion* +g:neobundle#enable_name_conversion + If you set to 1 and omit bundle name, + |neobundle-options-normalized_name| is used as bundle name. + It is useful for absorbing difference of repository name. + +g:neobundle#rm_command *g:neobundle#rm_command* + The command used to remove files to uninstall. + + Defaults to "rmdir /S /Q" on Windows or "rm -rf" in + others. + + *g:neobundle#install_max_processes* +g:neobundle#install_max_processes + The max number of processes used for neobundle/install source + asynchronous update. + + Defaults to "8". + + *g:neobundle#install_process_timeout* +g:neobundle#install_process_timeout + The time of timeout seconds when updating/installing bundles. + + Defaults to "120". + +g:neobundle#default_options *g:neobundle#default_options* + A dictionary of preconfigured sets of options to use when + options are omitted for individual commands or functions. + Keys are arbitrary names for the option sets, and values are + dictionaries themselves that store option keys and values. + Use the special key "_" to store a "default default options". + Example: +> + let g:neobundle#default_options = + \ { 'rev' : {'rev' : 'ver.8'} } + NeoBundle 'Shougo/neocomplcache', '', 'rev' +< + Defaults to "{}". + + *g:neobundle#types#raw#calc_hash_command* +g:neobundle#types#raw#calc_hash_command + The hash command to use in raw repositories. + + Defaults to "sha1sum" or "md5sum". + + *g:neobundle#types#git#command_path* +g:neobundle#types#git#command_path + The "git" command path used for git type. + + Defaults to "git". + + *g:neobundle#types#git#default_protocol* +g:neobundle#types#git#default_protocol + The default protocol used for git (github). + Note: It is accepted in "https" or "ssh". + + Defaults to "https". + + *g:neobundle#types#git#enable_submodule* +g:neobundle#types#git#enable_submodule + If it is non-zero, neobundle enables git submodule support. + But it may be slow in Windows environment. + + Defaults to 1. + + *g:neobundle#types#git#clone_depth* +g:neobundle#types#git#clone_depth + The default history depth for "git clone". + If it is 1, neobundle use shallow clone feature. + See |neobundle-options-type__depth|. + + Defaults to 0. + + *g:neobundle#types#git#pull_command* +g:neobundle#types#git#pull_command + The git command used to pull updates. + The previous default has been "pull --rebase". + + Defaults to "pull --ff --ff-only". + + *g:neobundle#types#hg#command_path* +g:neobundle#types#hg#command_path + The "hg" command path used for hg type. + + Defaults to "hg". + + *g:neobundle#types#hg#default_protocol* +g:neobundle#types#hg#default_protocol + The default protocol used for hg (bitbucket). + Note: It is accepted in "https" or "ssh". + + Defaults to "https". + + *g:neobundle#types#svn#command_path* +g:neobundle#types#svn#command_path + The "svn" command path used for svn type. + + Defaults to "svn". + +------------------------------------------------------------------------------ +OPTIONS *neobundle-options* + The {options} in neobundle commands accept the following keys: + + *neobundle-options-name* + name (String) + Specify the name of the bundle. This is used for neobundle + management and other commands (like |:NeoBundleUpdate|). If + omitted, the tail of the repository name will be used. + Note: Must be unique across all bundles. If a bundle name + conflicts with another bundle, neobundle will overwrite the + previous settings with the new one. If a repo tail is bound to + conflict, you can set the "name" option manually to prevent + overwriting an existing bundle setting. + Example: +> + NeoBundle 'https://github.com/Shougo/unite.vim.git', + \ {'name' : 'unite'} + NeoBundle 'https://github.com/foo/foo.git', + \ {'name' : 'foo-foo'} + NeoBundle 'https://github.com/bar/foo.git', + \ {'name' : 'bar-foo'} + NeoBundle 'https://git.code.sf.net/p/atp-vim/code', + \ {'name': 'atp-vim'} +< + *neobundle-options-normalized_name* + normalized_name (String) + Specify the normalized name of the bundle. This is used for + neobundle management to detect dependencies. If omitted, + neobundle will normalize the tail of the repository name. + Note: Must be unique across all bundles. + Normalized name example: + name : normalized name +> + unite.vim unite + vim-quickrun quickrun +< + description (String) + Plugin description. + + rev (String) + Specify a revision number or branch/tag name. + If it is "release" in "git" type, neobundle will use latest + released tag. + Note: If the type is "raw", rev is hash number. + + Example: +> + NeoBundle 'Shougo/vimshell', { 'rev' : '3787e5' } +< + *neobundle-options-default* + default (String) + Specify a default option name. (See |g:neobundle#default_options|). + + *neobundle-options-directory* + directory (String) + Specify relative directory path from the base directory (set + by |neobundle#begin()| or "base" option). If omitted, the "name" + option will be used. + Note: If you set rev "foo" when the name key is "neobundle", + the directory key is "neobundle_foo". + + Example: +> + NeoBundle 'https://github.com/Shougo/unite.vim.git', + \ {'directory' : 'unite'} +< + *neobundle-options-base* + base (String) + Directory base path to use. If omitted, the path specified + with |neobundle#begin()| will be used. It is useful for + loading scripts from a different path. + + *neobundle-options-type* + type (String) + Specify the repository type. If omitted, a guess is made + based on {repository}. + + Available types: + "none" : None repository + "raw" : Raw plugin file ("script_type" attribute is + needed) + "git" : Git + "hg" : Mercurial + "svn" : Subversion + "vba" : Vimball + + Example: +> + NeoBundle 'https://host/path/repo.git', {'type': 'hg'} + NeoBundle 'thinca/vim-localrc', {'type' : 'svn'} +< + *neobundle-options-script_type* + script_type (String) + Specify the script type. It is useful for non-official + categorized plugins. + For example: "indent", "plugin", "ftplugin", ... + Note: You must not specify it for categorized plugins. + Example: +> + NeoBundle 'https://raw.github.com/m2ym/rsense/master/etc/rsense.vim', + \ {'script_type' : 'plugin'} + NeoBundle 'https://github.com/bronzehedwick/impactjs-colorscheme', + \ {'script_type' : 'colorscheme'} +< + *neobundle-options-site* + site (String) + Specify the repository site. If you omit both the repository + URL and the "site" option, |g:neobundle#default_site| will be + used. + Note: You can specify site by "{site-name}:{path}". + For example: "github:Shougo/vimshell" + + Available sites: + "github" or "gh" : github.com (git) + "bitbucket" or "bb" : bitbucket.org (hg) + "gist" : gist.github.com (git) + + *neobundle-options-rtp* + rtp (String) + Specify runtime path. + Use this option when the repository has the Vim plugin + in a subdirectory. + For example: https://github.com/rstacruz/sparkup + + Example: +> + NeoBundle 'rstacruz/sparkup', {'rtp': 'vim'} + NeoBundle 'https://code.google.com/p/vimwiki/', { + \ 'rtp': "~/.vim/bundle/vimwiki/src", + \ } +< + *neobundle-options-depends* + depends (List or String) + Specify a list of plugins a plugin depends on. + List items are '{plugin-name}' or ['{plugin-name}', {args}]. + Those specified in the list are installed automatically. If + the {plugin-name} needs options, specify them with {args}. + Note: Type String is syntax sugar for List of {plugin-name}. + + Example: +> + NeoBundle 'Shougo/vimfiler', {'depends' : 'Shougo/unite.vim' } + NeoBundle 'Shougo/neocomplcache', {'depends' : + \ [ 'Shougo/neosnippet.git', + \ ['rstacruz/sparkup', {'rtp': 'vim'}], + \ ]} +< + *neobundle-options-build* + build (Dictionary or String) + Specify the build script. + You may use this option if the plugin has to be built before + use. If the build script requires external commands, see + |neobundle-options-build_commands|. + This command is executed by |system()| or |vimproc#system()| + in plugin runtimepath. + Note: Type String is syntax sugar for Dictionary of + {"others": "cmd"}. + + This dictionary accepts the following keys: + + windows (String) + Specify Windows environment build script. + + mac (String) + Specify Mac OS X environment build script. + + cygwin (String) + Specify Cygwin environment build script. + + linux (String) + Specify Linux environment build script. + Note: It is detected if "gmake" command is not + executable. + + unix (String) + Specify Unix environment build script. + + others (String) + Specify others environment build script. + If you don't specify other keys, it means "all". + + Example: +> + NeoBundle 'Shougo/vimproc.vim', { + \ 'build' : { + \ 'windows' : 'tools\\update-dll-mingw', + \ 'cygwin' : 'make -f make_cygwin.mak', + \ 'mac' : 'make -f make_mac.mak', + \ 'linux' : 'make', + \ 'unix' : 'gmake', + \ }, + \ } +< + Note: The command is executed in plugin top directory. + If you need cd command, you must use "sh -c". > + NeoBundle 'wincent/command-t', { + \ 'build': { + \ 'others' : + \ 'sh -c "cd ruby/command-t && ruby extconf.rb && make"' + \ } + \ } +< + *neobundle-options-augroup* + augroup (String) + Specify an augroup name that the plugin uses for |VimEnter| or + |GUIEnter| autocmd events. + Neobundle will call their |VimEnter| or |GUIEnter| autocmds + automatically when |:NeoBundleSource| is executed. + Note: You'll want to set this option because some plugins + rely on autocmds defined for |VimEnter| or |GUIEnter|, but by + using |:NeoBundleSource| after loading .vimrc, those autocmds + may get skipped. Some examples are, "fugitive", "NERDTree", + and "session.vim". + + Examples: +> + " NERDTree uses augroup NERDTreeHijackNetrw. + NeoBundle 'scrooloose/nerdtree', { 'augroup' : 'NERDTreeHijackNetrw'} + " fugitive uses augroup fugitive. + NeoBundle 'tpope/vim-fugitive', { 'augroup' : 'fugitive'} +< + This option is also valid in |:NeoBundleLazy|. + + *neobundle-options-external_commands* + external_commands (Dictionary or List or String) + Specify a list of external commands that the plugin depends + on. List items are '{command-name}' or ['{command-name}', + ...] or { {dictionary} }. + The commands are checked when loading the plugin. + Note: Type String is syntax sugar for list of {command-name}s. + + The {dictionary} has following keys: + + windows (String) + Specify Windows environment external commands. + + mac (String) + Specify Mac OS X environment external commands. + + cygwin (String) + Specify Cygwin environment external commands. + + unix (String) + Specify Unix environment external commands. + + others (String) + Specify others environment external commands. + + Example: +> + NeoBundle 'ujihisa/neco-ghc', { 'external_commands' : 'ghc-mod' } +< + *neobundle-options-build_commands* + build_commands (Dictionary or List or String) + Specify a list of external commands that are required for + building the plugin. If any of these commands are not + installed, the bundle will not be built. The list is the same + format as |neobundle-options-external_commands|. + + Example: +> + NeoBundle 'Valloric/YouCompleteMe', { 'build_commands' : 'cmake' } +< + + *neobundle-options-frozen* + frozen (Number) + If set to 1, neobundle doesn't update it automatically when + |:NeoBundleUpdate| or ":Unite neobundle/update" is called with + no arguments. It is useful for outdated plugins that can no + longer be updated. +> + NeoBundle 'Shougo/neobundle', { 'frozen' : 1 } +< + *neobundle-options-lazy* + lazy (Number) + If set to 1, neobundle doesn't add the path to user + runtimepath. + + *neobundle-options-fetch* + fetch (Number) + If set to 1, neobundle doesn't add the path to user + runtimepath, and doesn't load the bundle. + + *neobundle-options-force* + force (Number) + If set to 1, neobundle will load plugin files in the plugin + repository forcedly. + Note: It is useful for using Bundle within bundle. + https://github.com/Shougo/neobundle.vim/issues/199 + + *neobundle-options-gui* + gui (Number) + If set 1, neobundle will only load the plugin in GUI Vim. + + Example: > + NeoBundle 'tyru/restart.vim', '', 'same', { + \ 'gui' : 1, + \ 'on_cmd' : 'Restart' + \ } +< + *neobundle-options-terminal* + terminal (Number) + If set to 1, neobundle will only load the plugin in Terminal + Vim. + + *neobundle-options-vim_version* + vim_version (String) + Minimal vim version of the plugin supported. + It accepts some version formats such as "7" and "7.3" and + "7.3.885". + + *neobundle-options-disabled* + disabled (Number) or (String) + If set to 1, neobundle will disable the plugin. + If it is string, neobundle will eval the string. + Note: Disabled plugins are not ignored when install/update + plugins. + + Example: > + " neocomplete requires Vim 7.3.885 or above. + NeoBundle 'Shougo/neocomplete', { + \ 'depends' : 'Shougo/context_filetype.vim', + \ 'disabled' : !has('lua'), + \ 'vim_version' : '7.3.885' + \ } +< + *neobundle-options-focus* + focus (Number) + If it is > 0, neobundle will source the plugin when focus + is lost. It also is source priority. + http://d.hatena.ne.jp/osyo-manga/20140212/1392216949 + Example: > + " Source all plugins when focus is lost. + let g:neobundle#default_options._ = { 'verbose' : 1, 'focus' : 1 } +< + *neobundle-options-verbose* + verbose (Number) + If set to 1, neobundle will print message when it is sourced. + + *neobundle-options-install_process_timeout* + install_process_timeout (Number) + The time of timeout seconds when updating/installing bundles. + If omit it, |g:neobundle#install_process_timeout| will be used. + Note: This feature is available if you installed |vimproc|. + + *neobundle-options-autoload* + autoload (Dictionary) + Specify autoload conditions. + If you set it, neobundle will execute |:NeoBundleSource| + automatically when the conditions are met. + Note: This dictionary is deprecated. + + *neobundle-options-on_ft* + on_ft (List) or (String) + Filetype list. If the filetype is "all", it means all + filetypes. + Note: Using this will usually cause Neobundle to + either reset the ftplugin state, or explicitly call + the FileType autocommand another time (after adding + the lazy-loaded bundle), which results in the + autocommand to be processed twice for all other + plugins. Therefore, using "all" does not make sense + usually. + + *neobundle-options-filetypes* + It is deprecated key. + + *neobundle-options-on_cmd* + on_cmd (List) or (String) + Command list. The item can be following dictionary. + name (String) or (List) + Command name or the list of command names. + + Example: > + NeoBundle 'Shougo/vimfiler.vim', { + \ 'depends' : 'Shougo/unite.vim', + \ 'on_cmd' : ['VimFiler', 'VimFilerEdit', + \ 'VimFilerWrite','VimFilerRead', + \ 'VimFilerSource'], + \ 'on_map' : '', + \ 'on_path' : '.*', + \ } +< + *neobundle-options-commands* + It is deprecated key. + + *neobundle-options-on_func* + on_func (List) or (String) + Functions list. + + *neobundle-options-functions* + It is deprecated key. + + *neobundle-options-on_map* + on_map (List) or (String) + Mappings list. The items are {mapping} or + [{mode}, {mapping1}, [{mapping2}, ...]]. If {mode} is + omitted, "nxo" is used. + Note: You can use plugin prefix mappings. + For example, you can use "(ref-" instead of + "(ref-back)" and so on. + + Note: You can use "" keyword as {mapping}. If + {mapping} is "", "(normalized_name" is + used. + For example: > + " It is same as "'mappings' : '(anzu' + NeoBundle 'osyo-manga/vim-anzu', { + \'on_map': ''} +< + Note: You cannot use lazy mappings twice. + For example: > + NeoBundle 'osyo-manga/vim-anzu', { + \ 'on_map': '(anzu-'} + " Not working!! + nmap n (anzu-jump-n)(anzu-echo-search-status)zv + nmap N (anzu-jump-N)(anzu-echo-search-status)zv +< + *neobundle-options-mappings* + It is deprecated key. + + *neobundle-options-on_i* + on_i (Number) + If set to non-zero, neobundle will |:NeoBundleSource| + on |InsertEnter| autocmd. + + *neobundle-options-insert* + It is deprecated key. + + *neobundle-options-on_path* + on_path (String) or (List) + If set to ".*", neobundle will |:NeoBundleSource| + on editing all files. + Otherwise, neobundle will |:NeoBundleSource| if the + buffer name is matched the string pattern. + Note: It is useful for explorer behavior plugins. + Ex: vimfiler, metarw, vim-gnupg ... + Note: To autoload vimfiler, you must disable netrw in + .vimrc. > + " Disable netrw.vim + let g:loaded_netrwPlugin = 1 +< + For example: > + NeoBundle 'kana/vim-meta', { + \ 'on_path' : '\h\w*:', + \ } +< + *neobundle-options-explorer* + *neobundle-options-filename_patterns* + It is deprecated key. + + *neobundle-options-on_source* + on_source (List) or (String) + Load the bundle when the list bundles are loaded. + Note: If they are not autoload bundles, "on_source" + hooks are called when |VimEnter| auto command. + You can call them manually by |neobundle#call_hook()|. + Note: The plugins must be lazy loaded plugins. + + For example: > + if neobundle#tap('plugin-B.vim') + call neobundle#config({ + \ 'on_source' : [ 'plugin-A.vim' ] + \ }) + call neobundle#untap() + endif +< + plugin-B is loaded before plugin-A is loaded. + + *neobundle-options-pre_cmd* + pre_cmd (List) or (String) + Autoload command prefix in commands. + If the prefix is set, commands were loaded + automatically. + If omitted it, automatically generated prefix is used. + Example: If you use "unite.vim", "Unite" command + prefix is used. + Note: It requires Vim 7.4.414 or above. + + *neobundle-options-command_prefix* + It is deprecated key. + + Autoload examples: +> + NeoBundle 'Rip-Rip/clang_complete', { + \ 'on_ft' : ['c', 'cpp'], + \ } + NeoBundle 'basyura/TweetVim', { 'depends' : + \ ['basyura/twibill.vim', 'tyru/open-browser.vim'], + \ 'on_cmd' : 'TweetVimHomeTimeline' } + NeoBundle 'kana/vim-smartword', { + \ 'on_map' : [ + \ '(smartword-''] + \ } + NeoBundle 'Shougo/vimshell',{ + \ 'depends' : 'Shougo/vimproc.vim', + \ 'on_cmd' : [{ 'name' : 'VimShell', + \ 'complete' : 'customlist,vimshell#complete'}, + \ 'VimShellExecute', 'VimShellInteractive', + \ 'VimShellTerminal', 'VimShellPop'], + \ 'on_map' : '' + \ }) + NeoBundle 'Shougo/vimfiler', { + \ 'depends' : 'Shougo/unite.vim', + \ 'on_cmd' : [{ 'name' : 'VimFiler', + \ 'complete' : 'customlist,vimfiler#complete' }, + \ 'VimFilerExplorer', + \ 'Edit', 'Read', 'Source', 'Write'], + \ 'on_map' : '', + \ 'on_path' : '.*', + \ } + NeoBundle 'Shougo/junkfile.vim', { + \ 'on_cmd' : 'JunkfileOpen', + \ } + NeoBundle 'tyru/winmove.vim', { + \ 'on_map' : [ + \ ['n', '']], + \ 'gui' : 1, + \ 'augroup' : 'winmove', + \ } + NeoBundle 'sophacles/vim-processing', { + \'on_path': '\.pde$' + \} + NeoBundle 'LeafCage/cmdlineplus.vim', { + \ 'on_map': [['c', '']]} +< + *neobundle-options-hooks* + hooks (Dictionary) + Specify hook functions or hook script path. The following + hooks are defined: + + *neobundle-hooks-on_source* + on_source + Called or sourced before scripts are sourced. It is + useful for plugin initialization in lazy bundles. + Note: You must call the hook before |neobundle#end()|. + + *neobundle-hooks-on_post_source* + on_post_source + Called or sourced after scripts are sourced. + Note: In Vim initializing, calling the hooks are + delayed until |VimEnter|. + Note: To re-call on_source hook when reloading .vimrc, + you must call the hook in end of .vimrc. + + *neobundle-options-type__protocol* + type__protocol (String) + The protocol used for types. + "https" and "ssh" are available for git type. + "https" is available for hg type. + If omitted, |g:neobundle#types#git#default_protocol| + or |g:neobundle#types#hg#default_protocol| is used. + Note: This attribute is available in git and hg types only. + + Examples: +> + NeoBundle 'ujihisa/neco-ghc', { 'type__protocol' : 'ssh' } +< + *neobundle-options-type__filename* + type__filename (String) + The downloaded filename. + If omitted, URI filename will be used. + It is useful for downloading vim.org scripts. + Note: This attribute is available in raw type only. + + Examples: |:NeoBundle-examples| +> + NeoBundle 'git_repository_uri' + NeoBundle 'script_name' + NeoBundle 'https://github.com/tpope/vim-fugitive.git' + NeoBundle 'Shougo/neocomplcache', {'depends' : + \ [ 'Shougo/neosnippet.git', + \ ['rstacruz/sparkup', {'rtp': 'vim'}], + \ ]} + NeoBundle 'github:Shougo/vimshell' + + " Pushable github repository. + NeoBundle 'git@github.com:Shougo/neocomplcache.git' + + " For bitbucket hg repository. + NeoBundle 'bitbucket:ns9tks/vim-fuzzyfinder' + NeoBundle 'https://bitbucket.org/ns9tks/vim-fuzzyfinder' + + " For bitbucket git repository (.git is needed). + NeoBundle 'bitbucket:kh3phr3n/vim-qt-syntax.git' + NeoBundle 'https://bitbucket.org/kh3phr3n/vim-qt-syntax.git' + + " For raw repository. + NeoBundle 'https://raw.github.com/m2ym/rsense/master/etc/rsense.vim', + \ {'script_type' : 'plugin'} + + " For gist repository. + NeoBundle 'gist:Shougo/656148', { + \ 'name': 'everything.vim', + \ 'script_type': 'plugin'} + NeoBundle 'gist:355360', { + \ 'name': 'ambicmd.vim', + \ 'script_type': 'plugin'} +< + Neobundle supports revision (or branch) lock. + Note: The revision (or branch) is checked out in + install/update. + Note: You can either specify the revision manually or set the + to revision "master" to restore a plugin. +> + NeoBundle 'Shougo/vimshell', '3787e5' + NeoBundle 'Shougo/vimshell', 'master' +< + If type is "none", neobundle does not update + automatically (like pathogen.vim). See also |NeoBundleLocal|. +> + NeoBundle 'muttator', {'type' : 'none', 'base' : '~/.vim/bundle'} +< + Note: To use hg commands for git repository, please use this. +> + NeoBundle 'https://github.com/Shougo/neobundle.vim.git', {'type': 'hg'} +< + *neobundle-options-type__depth* + type__depth (Number) + History depth for "git clone". + If omitted, |g:neobundle#types#git#clone_depth| is used. + If it is than 0, neobundle clones the repository by shallow + clone. Shallow clone feature saves your repository clone time. + But it have problems in some repository. + + See below issues: + https://github.com/Shougo/neobundle.vim/issues/81 + https://github.com/Homebrew/homebrew/issues/12024 + + Note: This attribute is available in git type only. + +============================================================================== +EXAMPLES *neobundle-examples* +> + " Note: Skip initialization for vim-tiny or vim-small. + if 0 | endif + + if has('vim_starting') + if &compatible + set nocompatible " Be iMproved + endif + set runtimepath+={path to neobundle directory} + endif + + call neobundle#begin(expand('~/.vim/bundle')) + + " Let neobundle manage neobundle + NeoBundleFetch 'Shougo/neobundle.vim' + + " My Bundles here: + " Refer to |:NeoBundle-examples|. + " Note: You don't set neobundle setting in .gvimrc! + + " ... + + call neobundle#end() + + filetype plugin indent on " Required! + + " Installation check. + NeoBundleCheck + + "... + + if !has('vim_starting') + " Call on_source hook when reloading .vimrc. + call neobundle#call_hook('on_source') + endif +< +============================================================================== +MIGRATING FROM PATHOGEN *neobundle-migrate-from-pathogen* + +Here are a few tips if you want to migrate from a |pathogen| based +installation to neobundle. + +You might want to use a different/non-default directory for neobundle: > + + set rtp+=~/.vim/bundle/neobundle + call neobundle#begin(expand('~/.vim/neobundle')) +< +This allows you to keep `~/.vim/bundle` in place while migrating. + +If you are using Git submodules currently, you can use a shell command like +the following to automatically generate your NeoBundle statements: > + + while read p url; do \ + bundle_name="${url#*://github.com/}"; \ + dir="$(command git config -f .gitmodules --get ${p%.url}.path)"; \ + echo "NeoBundle '$bundle_name', { 'directory': '${dir##*/}' }"; \ + done < <(command git config -f .gitmodules \ + --get-regexp 'submodule.vim/bundle/\S+.(url)' | sort) +< +This uses the "submodule.*" urls and path from your .gitmodules sections that +start with `submodule.vim/bundle/`. +It sets the directory option explicitly to the name you were using before +(see |neobundle-options-directory|), which is useful if you want to compare +your old bundles directory with the one managed by neocomplete later. + +The output looks like this: > + NeoBundle 'tpope/vim-abolish.git', { 'directory': 'abolish' } +> +============================================================================== +UNITE SOURCES *neobundle-unite-sources* + +Here let me explain about a source for |unite| provided in neobundle. + + *neobundle-unite-source-neobundle* +neobundle + Nominates bundles as a candidate. + + Note: + If argument is bang(!), print plugins status. + + https://github.com/Shougo/vimproc.vim + + *neobundle-unite-source-neobundle-install* +neobundle/install + Install configured plugins asynchronously. + It supports neovim async jobs feature. + + Note: Installing the |vimproc| plugin or using neovim is + recommended. + + If argument is bang(!), it will install and update all plugins. + + Source arguments: + bundle names (fuzzy searched). + + Example: +> + :Unite neobundle/install:! + :Unite neobundle/install:neocomplcache + :Unite neobundle/install:neocomplcache:unite.vim +< + If you use the source with "-auto-quit" option, the unite + buffer will close automatically. +> + :Unite neobundle/install -auto-quit +< + *neobundle-unite-source-neobundle-log* +neobundle/log + Print previous neobundle install logs. + And you can jump the diff URI in github. + + *neobundle-unite-source-neobundle-update* +neobundle/update + Install and update configured plugins asynchronously, except + for outdated ones or those with the "frozen" option. + It supports neovim async jobs feature. + Note: This source is the same as "neobundle/install:!". + Note: Installing the |vimproc| plugin or using neovim is + recommended. + + If argument is bang(!), it will not be with fuzzy search. + If argument is "all", it will update all plugins. + + If you use the source with "-auto-quit" option, the unite + buffer will close automatically. +> + :Unite neobundle/update -log -wrap -auto-quit +< + *neobundle-unite-source-neobundle-search* +neobundle/search + Search plugin settings from sources. + Note: This source requires "curl" or "wget" command. + Note: If you get errors in this source, please refresh the + cache file by |(unite_redraw)|. + + Source arguments: + source names. + + Following source names are available: + "vim_scripts_org": + Search plugins settings from "http://vim-scripts.org". + "github": + Search plugins settings from "https://github.org/". + "metadata": + Search plugins settings from converted metadata in + "https://bitbucket.org/vimcommunity/vim-pi/". + + *neobundle-unite-source-neobundle-lazy* +neobundle/lazy + List lazy configured plugins (not sourced by + |:NeoBundleSource|). + + *unite-kind-neobundle* +neobundle An interface for neobundle bundles. It is used in + neobundle source and neobundle/lazy sources. + update Update bundles (Default action) + delete Delete bundles + preview view the plugin documentation + reinstall Reinstall bundles + narrow Narrow bundle files + edit Browse bundle directory + start Browse github plugin page + +Actions for each of the sources + +neobundle/search *unite-action-neobundle-search* + yank Yank plugin settings (Default action). + install Direct install plugins from repository. + Note: The settings are saved in "extra_bundles.vim" in + |neobundle#begin()| directory. + start Browse github plugin page. + + Note: If you use the install action, you cannot customize the bundle + settings. + +neobundle/lazy *unite-action-neobundle-lazy* + source Source plugin files (Default action) + +============================================================================== +FAQ *neobundle-faq* + +Q: What's the neobundle advantage for Vundle or other plugin management +system? + +A: neobundle solves some problems in Vundle or other plugin management system. +But you must know they are huge and complex features. + + 1. Plugin prefixed command name (:Bundle vs :NeoBundle). + https://github.com/gmarik/Vundle.vim/issues/76 + 2. Support vimproc (asynchronous update/install). + https://github.com/gmarik/Vundle.vim/issues/259 + 3. Support unite.vim interface (update/install/search). + 4. Support revision lock feature. + https://github.com/gmarik/Vundle.vim/issues/35 + 5. Support other VCS (Subversion/Git). + https://github.com/gmarik/Vundle.vim/pull/134 + https://github.com/gmarik/Vundle.vim/pull/268 + 6. Support lazy initialization for optimizing startup time. + https://github.com/gmarik/Vundle.vim/issues/364 + https://github.com/gmarik/Vundle.vim/pull/98 + +Q: I want to manage the rsense Vim plugin using neobundle. + +A: Use |neocomplcache-rsense|. Installation and settings can be found in the +neocomplcache-rsense docs. +Note: neocomplcache-rsense depends |neocomplcache| plugin. + +https://github.com/Shougo/neocomplcache-rsense + +Q: Vim freezes when a NeoBundle command is run with a typo in the repo name. + +A: It's a git feature. Git awaits user input when the repo name is +wrong. You can install |vimproc| to keep your Vim from freezing: + https://github.com/Shougo/vimproc.vim + +Q: Duplicated error was printed when sourcing .vimrc. + +A: Your .vimrc was wrong. You must reset neobundle setting by +|neobundle#begin()| in .vimrc. +Note: You must not call |neobundle#begin()| inside a "has('vim_starting')" +block. +> + if has('vim_starting') + " This is wrong neobundle#begin(). + "call neobundle#begin(expand('~/.vim/bundle')) + endif + + " This is OK. + call neobundle#begin(expand('~/.vim/bundle')) +< + +Q: I want to compile vimproc automatically. + +A: +> + NeoBundle 'Shougo/vimproc.vim', { + \ 'build' : { + \ 'windows' : 'tools\\update-dll-mingw', + \ 'cygwin' : 'make -f make_cygwin.mak', + \ 'mac' : 'make -f make_mac.mak', + \ 'unix' : 'make -f make_unix.mak', + \ }, + \ } +< + +Q: What's the "outdated" plugin? + +A: Last update time is older than one week -> Automatic updates are disabled +until one day from the last update. +Last update time is older within one week -> Automatic updates are every time. +Note: If you use update with name or use "all" argument in neobundle/update +source or use "!" in |:NeoBundleUpdate| command, this feature will be +disabled; it forces updates them. + +Q: I want to update messages in unite buffer. + +A: +> + Unite -log -wrap neobundle/update +< + +Q: neobundle.vim is not worked in Debian/Ubuntu Linux... + +A: Did you use "debian.vim"? "debian.vim" changes 'runtimepath'. +So it conflicts with neobundle. You should not use "debian.vim". + +Q: neobundle.vim fails update in submodule repository. + +A: neobundle.vim supports submodule repository. But I think the repository was +changed recently from non-use submodule to use submodule. You must reinstall +the repository. + +Q: I want to install github plugins with Subversion. + +A: +> + NeoBundle 'thinca/vim-localrc', {'type' : 'svn'} +< +Q: I want to add absolute path in 'runtimepath' with |:NeoBundle| and +|:NeoBundleLazy|. +https://github.com/Shougo/neobundle.vim/issues/136 + +A: You can use "none" type. > + NeoBundle '/absolute/path/to/plugin', { 'type' : 'none' } + +Q: Problem with lazy loading of matchit plugin. +https://github.com/Shougo/neobundle.vim/issues/153 + +A: +> + NeoBundle 'matchit.zip', { + \ 'on_map' : ['%', 'g%'] + \ } + let bundle = neobundle#get('matchit.zip') + function! bundle.hooks.on_post_source(bundle) + silent! execute 'doautocmd Filetype' &filetype + endfunction +< + +Q: Cannot load colorscheme when reloading .vimrc. +https://github.com/Shougo/neobundle.vim/issues/157 + +A: You must write :NeoBundle lines before filetype plugin indent on and syntax +enable. +> + filetype plugin indent on + + NeoBundle 'tomasr/molokai' + ... + + syntax enable + colorscheme molokai +< + +Q: Timeout on github makes Vim terribly slow if the repository is not found in +console Vim. +https://github.com/Shougo/neobundle.vim/issues/175 + +A: |vimproc| and |system()| uses input redirection. But git ignores it when +you used https protocol in console Vim. So it freezes. I think it is bad +feature in git. I cannot fix it. You should change +|g:neobundle#types#git#default_protocol| to "git". + +Q: I want to use shallow clone in git. + +A: See |neobundle-options-type__depth|. + +Q: I want to use lockfile feature like "Gemfile.lock" in neobundle. +https://github.com/Shougo/neobundle.vim/issues/222 + +A: You can copy "NeoBundle.lock" to another machine from neobundle base path +directory. It is used when install plugins. + +Q: neobundle#begin() breaks plugin function calls. +https://github.com/Shougo/neobundle.vim/issues/330 + +A: You must use the functions after |neobundle#end()|. +Because, the plugins are loaded when neobundle calls |neobundle#end()|. + +Q: Fails submoduled repository clone like YouCompleteMe. + +A: I think you use the submodule repository in proxy environment. + +https://github.com/ekg/freebayes/issues/63 +> + $ git config --global url.https://github.com/.insteadOf git://github.com/ +< +Q: Colorscheme does not load below code. > + NeoBundle 'mrkn256.vim' + colorscheme mrkn256 + ... + neobundle#end() + +A: 'runtimepath' is set on |neobundle#end()|. So it is not set when the +colorscheme executed. You can use |neobundle-options-force| for it or write +|:colorscheme| command after |neobundle#end()|. + +Q: fugitive does not work using neobundle. Please help! > + NeoBundle 'tpope/vim-fugitive' + +A: You must specify |neobundle-options-augroup| like this. > + " fugitive uses augroup fugitive. + NeoBundle 'tpope/vim-fugitive', { 'augroup' : 'fugitive'} + +Q: I setup gVim-only colorscheme but neobundle doesn't load it. + +A: neobundle can't load colorschemes automatically. So you can't use +|:NeoBundleLazy| for colorschemes. + +Q: I want to use "git" or "http" protocol instead of "https". + +A: No, you cannot. + +Q: Why neobundle only accepts "https" or "ssh"? + +A: https://glyph.twistedmatrix.com/2015/11/editor-malware.html + +Q: I want to autoload vim-gnupg + +A: vim-gnupg uses |BufReadCmd| and |FileReadCmd| autocmd. You must specify +the autocmd. > + autocmd BufReadCmd,FileReadCmd *.gpg,*.asc,*.pgp + \ NeoBundleSource vim-gnupg | doautocmd BufReadCmd + autocmd FileReadCmd *.gpg,*.asc,*.pgp + \ NeoBundleSource vim-gnupg | doautocmd FileReadCmd + +Q: Where is :NeoBundleClean command? +https://github.com/Shougo/neobundle.vim/issues/501 + +A: It is removed because it is dangerous. + +Q: Why the install script does not use "curl | bash" ? +https://github.com/Shougo/neobundle.vim/pull/515 + +A: https://www.idontplaydarts.com/2016/04/detecting-curl-pipe-bash-server-side/ + +============================================================================== +vim:tw=78:ts=8:ft=help:norl:noet:fen: diff --git a/dot_vim/bundle/neobundle.vim/dot_git b/dot_vim/bundle/neobundle.vim/dot_git new file mode 100644 index 0000000..405f8b7 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/dot_git @@ -0,0 +1 @@ +gitdir: ../../../../.git/modules/vim/.vim/bundle/neobundle.vim diff --git a/dot_vim/bundle/neobundle.vim/dot_gitignore b/dot_vim/bundle/neobundle.vim/dot_gitignore new file mode 100644 index 0000000..926ccaa --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/dot_gitignore @@ -0,0 +1 @@ +doc/tags diff --git a/dot_vim/bundle/neobundle.vim/dot_travis.yml b/dot_vim/bundle/neobundle.vim/dot_travis.yml new file mode 100644 index 0000000..8a04a43 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/dot_travis.yml @@ -0,0 +1,13 @@ +language: viml + +sudo: false + +before_script: + - vim --version + - git clone https://github.com/syngan/vim-vimlint /tmp/vim-vimlint + - git clone https://github.com/ynkdir/vim-vimlparser /tmp/vim-vimlparser + - git clone https://github.com/thinca/vim-themis + +script: + - sh /tmp/vim-vimlint/bin/vimlint.sh -l /tmp/vim-vimlint -p /tmp/vim-vimlparser -e EVL103=1 -e EVL102.l:_=1 autoload + - make test diff --git a/dot_vim/bundle/neobundle.vim/plugin/neobundle.vim b/dot_vim/bundle/neobundle.vim/plugin/neobundle.vim new file mode 100644 index 0000000..971e116 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/plugin/neobundle.vim @@ -0,0 +1,60 @@ +"============================================================================= +" FILE: neobundle.vim +" AUTHOR: Shougo Matsushita +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +if exists('g:loaded_neobundle') + let &cpo = s:save_cpo + unlet s:save_cpo + + finish +elseif v:version < 702 || (v:version == 702 && !has('patch51')) + " Neobundle uses glob()/globpath() another parameter. + " It is implemented in Vim 7.2.051. + echoerr 'neobundle does not work this version of Vim "' . v:version . '".' + \ .' You must use Vim 7.2.051 or later.' + + let &cpo = s:save_cpo + unlet s:save_cpo + + finish +elseif fnamemodify(&shell, ':t') ==# 'fish' && !has('patch-7.4.276') + echoerr 'Vim does not support "' . &shell . '".' + \ .' You must use Vim 7.4.276 or later.' + + let &cpo = s:save_cpo + unlet s:save_cpo + + finish +endif + +let g:loaded_neobundle = 1 + +let &cpo = s:save_cpo +unlet s:save_cpo + +" __END__ +" vim: foldmethod=marker diff --git a/dot_vim/bundle/neobundle.vim/test/commands.vim b/dot_vim/bundle/neobundle.vim/test/commands.vim new file mode 100644 index 0000000..3a0da22 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/test/commands.vim @@ -0,0 +1,117 @@ +" Basic commands test. +set verbose=1 + +let path = expand('~/test-bundle/'.fnamemodify(expand(''), ':t:r')) + +if isdirectory(path) + let rm_command = neobundle#util#is_windows() ? 'rmdir /S /Q' : 'rm -rf' + call system(printf('%s "%s"', rm_command, path)) +endif + +call mkdir(path, 'p') + +call neobundle#begin(path) + +let g:neobundle#types#git#default_protocol = 'https' + +" My Bundles here: +" + +" Original repositories in github. +NeoBundle 'Shougo/neocomplcache-clang.git' + +" Vim-script repositories. +NeoBundle 'rails.vim' + +" Username with dashes. +NeoBundle 'vim-scripts/ragtag.vim' + +" Original repo. +NeoBundle 'altercation/vim-colors-solarized' + +" With extension. +" Comment is allowed. +NeoBundle 'nelstrom/vim-mac-classic-theme.git' " Foo, Bar + +" Invalid uri. +NeoBundle 'nonexistinguser/hogehoge.git' + +" Full uri. +NeoBundle 'https://github.com/vim-scripts/vim-game-of-life' +NeoBundle 'git@github.com:gmarik/ingretu.git' + +" Short uri. +NeoBundle 'gh:gmarik/snipmate.vim.git' +NeoBundle 'github:mattn/gist-vim.git' + +" Camel case. +NeoBundle 'vim-scripts/RubySinatra' + +" With options. +NeoBundle 'Shougo/vimshell', '3787e5' + +" None repos. +NeoBundle 'muttator', {'type' : 'none', 'base' : '~/.vim/bundle'} + +" Raw repos. +NeoBundle 'https://raw.github.com/m2ym/rsense/master/etc/rsense.vim', + \ {'script_type' : 'plugin'} + +" NeoBundleLocal test. +NeoBundleLocal ~/.vim/bundle/ + +" Depends repos. +NeoBundle 'Shougo/neocomplcache', + \ {'depends' : [ + \ 'Shougo/neocomplcache-snippets-complete.git', + \ ['rstacruz/sparkup', {'rtp': 'vim'}], + \ ]} +NeoBundle 'Shougo/vimfiler', + \ { 'depends' : 'Shougo/unite.vim' } + +" Build repos. +NeoBundle 'Shougo/vimproc', { + \ 'build' : { + \ 'windows' : 'echo "Sorry, cannot update vimproc binary file in Windows."', + \ 'cygwin' : 'make -f make_cygwin.mak', + \ 'mac' : 'make -f make_mac.mak', + \ 'unix' : 'make -f make_unix.mak', + \ }, + \ } + +" Lazy load. +NeoBundleLazy 'c9s/perlomni.vim.git' +NeoBundleSource perlomni.vim +call neobundle#source(['CSApprox']) + +NeoBundleLazy 'The-NERD-tree', {'augroup' : 'NERDTree'} +call neobundle#source(['The-NERD-tree']) + +NeoBundleLazy 'masudaK/vim-python' +NeoBundleLazy 'klen/python-mode' + +NeoBundleLazy 'Rip-Rip/clang_complete', { + \ 'autoload' : { + \ 'filetypes' : ['c', 'cpp'], + \ }, + \ } + +" script_type support. +NeoBundle 'https://raw.github.com/m2ym/rsense/master/etc/rsense.vim', + \ {'script_type' : 'plugin'} + +" Fetch only. +NeoBundleFetch 'Shougo/neobundle.vim' + +call neobundle#end() + +filetype plugin indent on " required! + +" Should not break helptags. +set wildignore+=doc + +" Should not break clone. +set wildignore+=.git +set wildignore+=.git/* +set wildignore+=*/.git/* + diff --git a/dot_vim/bundle/neobundle.vim/test/lock.vim b/dot_vim/bundle/neobundle.vim/test/lock.vim new file mode 100644 index 0000000..7dd4bfb --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/test/lock.vim @@ -0,0 +1,35 @@ +" Lock file test. +set verbose=1 + +let path = expand('~/test-bundle/'.fnamemodify(expand(''), ':t:r')) + +if isdirectory(path) + let rm_command = neobundle#util#is_windows() ? 'rmdir /S /Q' : 'rm -rf' + call system(printf('%s "%s"', rm_command, path)) +endif + +call mkdir(path, 'p') + +call neobundle#begin(path) + +NeoBundleFetch 'Shougo/neocomplete.vim' + +call neobundle#end() + +filetype plugin indent on " Required! + +" Create lock file +call writefile([ + \ 'NeoBundleLock neocomplete.vim 8200dfd83ba829f77f028ea26e81eebbe95e6a89', + \ ], path . '/NeoBundle.lock') + +NeoBundleInstall + +let s:suite = themis#suite('lock') +let s:assert = themis#helper('assert') + +function! s:suite.revision_check() abort + let bundle = neobundle#get('neocomplete.vim') + call s:assert.equals(neobundle#installer#get_revision_number(bundle), + \ '8200dfd83ba829f77f028ea26e81eebbe95e6a89') +endfunction diff --git a/dot_vim/bundle/neobundle.vim/test/parse.vim b/dot_vim/bundle/neobundle.vim/test/parse.vim new file mode 100644 index 0000000..cb7dc57 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/test/parse.vim @@ -0,0 +1,333 @@ +let s:suite = themis#suite('parser') +let s:assert = themis#helper('assert') + +let g:neobundle#types#git#default_protocol = 'https' +let g:neobundle#types#hg#default_protocol = 'https' +let g:neobundle#enable_name_conversion = 0 + +function! s:suite.github_git_repos() abort + call s:assert.equals(neobundle#parser#path( + \ 'Shougo/neocomplcache-clang.git'), + \ {'type' : 'git', 'uri' : + \ g:neobundle#types#git#default_protocol . + \ '://github.com/Shougo/neocomplcache-clang.git', + \ 'name' : 'neocomplcache-clang'}) + call s:assert.equals(neobundle#parser#path('Shougo/vimshell'), + \ {'type' : 'git', 'uri' : + \ g:neobundle#types#git#default_protocol . + \ '://github.com/Shougo/vimshell.git', + \ 'name' : 'vimshell'}) + call s:assert.equals(neobundle#parser#path('rails.vim'), + \ {'type' : 'git', 'uri' : + \ g:neobundle#types#git#default_protocol . + \ '://github.com/vim-scripts/rails.vim.git', + \ 'name' : 'rails.vim'}) + call s:assert.equals(neobundle#parser#path('vim-scripts/ragtag.vim'), + \ {'type' : 'git', 'uri' : + \ g:neobundle#types#git#default_protocol . + \ '://github.com/vim-scripts/ragtag.vim.git', + \ 'name' : 'ragtag.vim'}) + call s:assert.equals(neobundle#parser#path( + \ 'https://github.com/vim-scripts/vim-game-of-life'), + \ {'type' : 'git', 'uri' : + \ 'https://github.com/vim-scripts/vim-game-of-life.git', + \ 'name' : 'vim-game-of-life'}) + call s:assert.equals(neobundle#parser#path( + \ 'git@github.com:gmarik/ingretu.git'), + \ {'type' : 'git', 'uri' : + \ 'git@github.com:gmarik/ingretu.git', + \ 'name' : 'ingretu'}) + call s:assert.equals(neobundle#parser#path( + \ 'gh:gmarik/snipmate.vim.git'), + \ {'type' : 'git', 'uri' : + \ g:neobundle#types#git#default_protocol . + \ '://github.com/gmarik/snipmate.vim.git', + \ 'name' : 'snipmate.vim'}) + call s:assert.equals(neobundle#parser#path( + \ 'github:mattn/gist-vim.git'), + \ {'type' : 'git', 'uri' : + \ g:neobundle#types#git#default_protocol . + \ '://github.com/mattn/gist-vim.git', + \ 'name' : 'gist-vim'}) + call s:assert.equals(neobundle#parser#path( + \ 'git@github.com:Shougo/neocomplcache.git'), + \ {'type' : 'git', 'uri' : + \ 'git@github.com:Shougo/neocomplcache.git', + \ 'name' : 'neocomplcache'}) + call s:assert.equals(neobundle#parser#path( + \ 'https://github.com/Shougo/neocomplcache/'), + \ {'type' : 'git', 'uri' : + \ 'https://github.com/Shougo/neocomplcache.git', + \ 'name' : 'neocomplcache'}) + call s:assert.equals(neobundle#parser#path( + \ 'git://git.wincent.com/command-t.git'), + \ {}) + call s:assert.equals(neobundle#parser#path( + \ 'http://github.com/Shougo/neocomplcache/'), + \ {}) +endfunction + +function! s:suite.svn_repos() abort + call s:assert.equals(neobundle#parser#path( + \ 'http://svn.macports.org/repository/macports/contrib/mpvim/'), + \ {}) + call s:assert.equals(neobundle#parser#path( + \ 'svn://user@host/repos/bar'), + \ {}) + call s:assert.equals(neobundle#parser#path( + \ 'https://svn.macports.org/repository/macports/contrib/mpvim/'), + \ {'type' : 'svn', 'uri' : + \ 'https://svn.macports.org/repository/macports/contrib/mpvim', + \ 'name' : 'mpvim'}) + call s:assert.equals(neobundle#parser#path( + \ 'svn+ssh://user@host/repos/bar'), + \ {'type' : 'svn', 'uri' : + \ 'svn+ssh://user@host/repos/bar', + \ 'name' : 'bar'}) +endfunction + +function! s:suite.hg_repos() abort + call s:assert.equals(neobundle#parser#path( + \ 'https://bitbucket.org/ns9tks/vim-fuzzyfinder'), + \ {'type' : 'hg', 'uri' : + \ 'https://bitbucket.org/ns9tks/vim-fuzzyfinder', + \ 'name' : 'vim-fuzzyfinder'}) + call s:assert.equals(neobundle#parser#path( + \ 'bitbucket://bitbucket.org/ns9tks/vim-fuzzyfinder'), + \ {'type' : 'hg', 'uri' : + \ g:neobundle#types#hg#default_protocol. + \ '://bitbucket.org/ns9tks/vim-fuzzyfinder', + \ 'name' : 'vim-fuzzyfinder'}) + call s:assert.equals(neobundle#parser#path( + \ 'bitbucket:ns9tks/vim-fuzzyfinder'), + \ {'type' : 'hg', 'uri' : + \ g:neobundle#types#hg#default_protocol. + \ '://bitbucket.org/ns9tks/vim-fuzzyfinder', + \ 'name' : 'vim-fuzzyfinder'}) + call s:assert.equals(neobundle#parser#path( + \ 'ns9tks/vim-fuzzyfinder', {'site': 'bitbucket'}), + \ {'type' : 'hg', 'uri' : + \ g:neobundle#types#hg#default_protocol. + \ '://bitbucket.org/ns9tks/vim-fuzzyfinder', + \ 'name' : 'vim-fuzzyfinder'}) + call s:assert.equals(neobundle#parser#path( + \ 'ssh://hg@bitbucket.org/ns9tks/vim-fuzzyfinder'), + \ {'type' : 'hg', 'uri' : + \ 'ssh://hg@bitbucket.org/ns9tks/vim-fuzzyfinder', + \ 'name' : 'vim-fuzzyfinder'}) + + let bundle = neobundle#parser#_init_bundle( + \ 'https://github.com/Shougo/neobundle.vim.git', + \ [{ 'type' : 'hg'}]) + call s:assert.equals(bundle.name, 'neobundle.vim') + call s:assert.equals(bundle.type, 'hg') + call s:assert.equals(bundle.uri, + \ 'https://github.com/Shougo/neobundle.vim.git') +endfunction + +function! s:suite.gitbucket_git_repos() abort + call s:assert.equals(neobundle#parser#path( + \ 'https://bitbucket.org/kh3phr3n/vim-qt-syntax.git'), + \ {'type' : 'git', 'uri' : + \ 'https://bitbucket.org/kh3phr3n/vim-qt-syntax.git', + \ 'name' : 'vim-qt-syntax'}) + call s:assert.equals(neobundle#parser#path( + \ 'bitbucket:kh3phr3n/vim-qt-syntax.git'), + \ {'type' : 'git', 'uri' : + \ g:neobundle#types#git#default_protocol. + \ '://bitbucket.org/kh3phr3n/vim-qt-syntax.git', + \ 'name' : 'vim-qt-syntax'}) + call s:assert.equals(neobundle#parser#path( + \ 'git@bitbucket.com:accountname/reponame.git'), + \ {'type' : 'git', 'uri' : + \ 'git@bitbucket.com:accountname/reponame.git', + \ 'name' : 'reponame'}) + call s:assert.equals(neobundle#parser#path( + \ 'ssh://git@bitbucket.com:foo/bar.git'), + \ {'type' : 'git', 'uri' : + \ 'ssh://git@bitbucket.com:foo/bar.git', + \ 'name' : 'bar'}) +endfunction + +function! s:suite.raw_repos() abort + call s:assert.equals(neobundle#parser#path( + \ 'http://raw.github.com/m2ym/rsense/master/etc/rsense.vim'), + \ {}) + call s:assert.equals(neobundle#parser#path( + \ 'http://www.vim.org/scripts/download_script.php?src_id=19237'), + \ {}) + let bundle = neobundle#parser#_init_bundle( + \ 'https://raw.github.com/m2ym/rsense/master/etc/rsense.vim', + \ [{ 'script_type' : 'plugin'}]) + call s:assert.equals(bundle.name, 'rsense.vim') + call s:assert.equals(bundle.type, 'raw') + call s:assert.equals(bundle.uri, + \ 'https://raw.github.com/m2ym/rsense/master/etc/rsense.vim') +endfunction + +function! s:suite.vba_repos() abort + call s:assert.equals(neobundle#parser#path( + \ 'https://foo/bar.vba'), + \ { 'name' : 'bar', 'uri' : 'https://foo/bar.vba', 'type' : 'vba' }) + call s:assert.equals(neobundle#parser#path( + \ 'https://foo/bar.vba.gz'), + \ { 'name' : 'bar', 'uri' : 'https://foo/bar.vba.gz', 'type' : 'vba' }) + call s:assert.equals(neobundle#parser#path( + \ 'http://foo/bar.vba.gz'), + \ {}) +endfunction + +function! s:suite.default_options() abort + let g:default_options_save = g:neobundle#default_options + let g:neobundle#default_options = + \ { 'rev' : {'type__update_style' : 'current'}, + \ '_' : {'type' : 'hg'} } + + let bundle = neobundle#parser#_init_bundle( + \ 'Shougo/neocomplcache', ['', 'rev', {}]) + call s:assert.equals(bundle.type__update_style, 'current') + + let bundle2 = neobundle#parser#_init_bundle( + \ 'Shougo/neocomplcache', []) + call s:assert.equals(bundle2.type, 'hg') + + let g:neobundle#default_options = g:default_options_save +endfunction + +function! s:suite.ssh_protocol() abort + let bundle = neobundle#parser#_init_bundle( + \ 'accountname/reponame', [{ + \ 'site' : 'github', 'type' : 'git', 'type__protocol' : 'ssh' }]) + call s:assert.equals(bundle.uri, + \ 'git@github.com:accountname/reponame.git') + + let bundle = neobundle#parser#_init_bundle( + \ 'accountname/reponame', [{ + \ 'site' : 'bitbucket', 'type' : 'hg', 'type__protocol' : 'ssh' }]) + call s:assert.equals(bundle.uri, + \ 'ssh://hg@bitbucket.org/accountname/reponame') + + let bundle = neobundle#parser#_init_bundle( + \ 'accountname/reponame.git', [{ + \ 'site' : 'bitbucket', 'type' : 'git', 'type__protocol' : 'ssh' }]) + call s:assert.equals(bundle.uri, + \ 'git@bitbucket.org:accountname/reponame.git') +endfunction + +function! s:suite.fetch_plugins() abort + let bundle = neobundle#parser#fetch( + \ string('accountname/reponame.git')) + call s:assert.equals(bundle.rtp, '') +endfunction + +function! s:suite.parse_directory() abort + let bundle = neobundle#parser#_init_bundle( + \ 'Shougo/neocomplcache', []) + call s:assert.equals(bundle.directory, 'neocomplcache') + + let bundle = neobundle#parser#_init_bundle( + \ 'Shougo/neocomplcache', ['ver.3']) + call s:assert.equals(bundle.directory, 'neocomplcache_ver_3') +endfunction + +function! s:suite.name_conversion() abort + let g:neobundle#enable_name_conversion = 1 + + let bundle = neobundle#parser#_init_bundle( + \ 'https://github.com/Shougo/neobundle.vim.git', + \ [{ 'type' : 'hg'}]) + call s:assert.equals(bundle.name, 'neobundle') + + let bundle = neobundle#parser#_init_bundle( + \ 'https://bitbucket.org/kh3phr3n/vim-qt-syntax.git', + \ [{ 'type' : 'hg'}]) + call s:assert.equals(bundle.name, 'qt-syntax') + + let bundle = neobundle#parser#_init_bundle( + \ 'https://bitbucket.org/kh3phr3n/qt-syntax-vim.git', + \ [{ 'type' : 'hg'}]) + call s:assert.equals(bundle.name, 'qt-syntax') + + let bundle = neobundle#parser#_init_bundle( + \ 'https://bitbucket.org/kh3phr3n/vim-qt-syntax.git', + \ [{ 'name' : 'vim-qt-syntax'}]) + call s:assert.equals(bundle.name, 'vim-qt-syntax') + + let g:neobundle#enable_name_conversion = 0 +endfunction + +function! s:suite.autoload() abort + let bundle = neobundle#parser#_init_bundle( + \ 'https://github.com/Shougo/neobundle.vim.git', + \ [{ 'filetypes' : 'foo_ft' }]) + call s:assert.equals(bundle.on_ft, ['foo_ft']) + call s:assert.equals(bundle.lazy, 1) + + let bundle = neobundle#parser#_init_bundle( + \ 'https://github.com/Shougo/neobundle.vim.git', + \ [{ 'filename_patterns' : 'foo_filename' }]) + call s:assert.equals(bundle.on_path, ['foo_filename']) + call s:assert.equals(bundle.lazy, 1) + + let bundle = neobundle#parser#_init_bundle( + \ 'https://github.com/Shougo/neobundle.vim.git', + \ [{ 'explorer' : 1 }]) + call s:assert.equals(bundle.on_path, ['.*']) + call s:assert.equals(bundle.lazy, 1) + + let bundle = neobundle#parser#_init_bundle( + \ 'https://github.com/Shougo/neobundle.vim.git', + \ [{ 'commands' : 'Foo' }]) + call s:assert.equals(bundle.on_cmd, ['Foo']) + call s:assert.equals(bundle.lazy, 1) + + let bundle = neobundle#parser#_init_bundle( + \ 'https://github.com/Shougo/neobundle.vim.git', + \ [{ 'functions' : 'foo#bar' }]) + call s:assert.equals(bundle.on_func, ['foo#bar']) + call s:assert.equals(bundle.lazy, 1) + + let bundle = neobundle#parser#_init_bundle( + \ 'https://github.com/Shougo/neobundle.vim.git', + \ [{ 'mappings' : '' }]) + call s:assert.equals(bundle.on_map, ['']) + call s:assert.equals(bundle.lazy, 1) + + let bundle = neobundle#parser#_init_bundle( + \ 'https://github.com/Shougo/neobundle.vim.git', + \ [{ 'insert' : 1 }]) + call s:assert.equals(bundle.on_i, 1) + call s:assert.equals(bundle.lazy, 1) + + let bundle = neobundle#parser#_init_bundle( + \ 'https://github.com/Shougo/neobundle.vim.git', + \ [{ 'on_source' : 'plug_foo' }]) + call s:assert.equals(bundle.on_source, ['plug_foo']) + call s:assert.equals(bundle.lazy, 1) + + let bundle = neobundle#parser#_init_bundle( + \ 'https://github.com/Shougo/neobundle.vim.git', + \ [{ 'command_prefix' : 'PreFoo' }]) + call s:assert.equals(bundle.pre_cmd, ['PreFoo']) + call s:assert.equals(bundle.lazy, 0) + + let bundle = neobundle#parser#_init_bundle( + \ 'https://github.com/Shougo/neobundle.vim.git', + \ [{ 'function_prefixes' : 'foo#' }]) + call s:assert.equals(bundle.pre_func, ['foo#']) + call s:assert.equals(bundle.lazy, 0) +endfunction + +function! s:suite.deprecated() abort + let bundle = neobundle#parser#_init_bundle( + \ 'https://github.com/Shougo/neobundle.vim.git', + \ [{ 'stay_same' : '1' }]) + call s:assert.equals(bundle.frozen, 1) + + let bundle = neobundle#parser#_init_bundle( + \ 'https://github.com/Shougo/neobundle.vim.git', + \ [{ 'type' : 'nosync' }]) + call s:assert.equals(bundle.type, 'none') +endfunction + +" vim:foldmethod=marker:fen: diff --git a/dot_vim/bundle/neobundle.vim/test/sample.vim b/dot_vim/bundle/neobundle.vim/test/sample.vim new file mode 100644 index 0000000..ca46962 --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/test/sample.vim @@ -0,0 +1,39 @@ +" Sample configurations test. +set verbose=1 + +let path = expand('~/test-bundle/'.fnamemodify(expand(''), ':t:r')) + +if isdirectory(path) + let rm_command = neobundle#util#is_windows() ? 'rmdir /S /Q' : 'rm -rf' + call system(printf('%s "%s"', rm_command, path)) +endif + +let neobundle#types#git#default_protocol = 'git' + +call neobundle#begin(path) + +" Let NeoBundle manage NeoBundle +NeoBundleFetch 'Shougo/neobundle.vim' + +" Recommended to install +" After install, turn shell ~/.vim/bundle/vimproc, (n,g)make -f your_machines_makefile +NeoBundle 'Shougo/vimproc' + +" My Bundles here: +" +" Note: You don't set neobundle setting in .gvimrc! +" Original repos on github +NeoBundle 'tpope/vim-fugitive' +NeoBundle 'Lokaltog/vim-easymotion' +NeoBundle 'rstacruz/sparkup', {'rtp': 'vim/'} +" vim-scripts repos +NeoBundle 'L9' +NeoBundle 'FuzzyFinder' +NeoBundle 'rails.vim' +" Non git repos +NeoBundle 'https://bitbucket.org/ns9tks/vim-fuzzyfinder' + +call neobundle#end() + +filetype plugin indent on " Required! + diff --git a/dot_vim/bundle/neobundle.vim/test/source.vim b/dot_vim/bundle/neobundle.vim/test/source.vim new file mode 100644 index 0000000..eb6932e --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/test/source.vim @@ -0,0 +1,95 @@ +" Source test. +set verbose=1 + +let path = expand('~/test-bundle/'.fnamemodify(expand(''), ':t:r')) + +if isdirectory(path) + let rm_command = neobundle#util#is_windows() ? 'rmdir /S /Q' : 'rm -rf' + call system(printf('%s "%s"', rm_command, path)) +endif + +let neobundle#types#git#default_protocol = 'https' + +call neobundle#begin(path) + +" Test dependencies. + +let s:suite = themis#suite('source') +let s:assert = themis#helper('assert') + +NeoBundleLazy 'Shougo/echodoc' +NeoBundle 'Shougo/unite-build', { 'depends' : 'Shougo/echodoc' } + +NeoBundle 'Shougo/unite-ssh', { 'depends' : 'Shougo/unite-sudo' } +NeoBundleLazy 'Shougo/unite-sudo' + +NeoBundleLazy 'Shougo/neomru.vim', { 'depends': 'Shougo/neocomplcache' } +NeoBundle 'Shougo/neocomplcache.vim', 'ver.8' + +NeoBundleLazy 'Shougo/vimshell', { 'depends': 'Shougo/vinarise' } +NeoBundleLazy 'Shougo/vinarise' + +NeoBundle 'Shougo/vimfiler', { 'depends' : 'foo/var' } + +NeoBundleLazy 'Shougo/unite.vim', { + \ 'depends' : ['Shougo/unite-outline', 'basyura/TweetVim'], + \ 'autoload' : { 'commands' : 'Unite' } } +NeoBundleLazy 'Shougo/unite-outline', { + \ 'depends' : 'Shougo/unite.vim' } + +" Dependencies test. +NeoBundleLazy 'basyura/twibill.vim' +NeoBundleLazy 'yomi322/neco-tweetvim' +NeoBundleLazy 'rhysd/tweetvim-advanced-filter' +NeoBundleLazy 'rhysd/TweetVim', { +\ 'depends' : +\ ['basyura/twibill.vim', +\ 'tyru/open-browser.vim', +\ 'yomi322/neco-tweetvim', +\ 'rhysd/tweetvim-advanced-filter'], +\ 'autoload' : { +\ 'commands' : +\ ['TweetVimHomeTimeline', +\ 'TweetVimMentions', +\ 'TweetVimSay', +\ 'TweetVimUserTimeline'] +\ } +\ } + +" Law. +NeoBundle 'https://raw.github.com/m2ym/rsense/master/etc/rsense.vim', + \ {'script_type' : 'plugin', 'rev' : '0'} +" NeoBundleReinstall rsense.vim + +call neobundle#end() + +filetype plugin indent on " required! + +" Should not break helptags. +set wildignore+=doc + +" Should not break clone. +set wildignore+=.git +set wildignore+=.git/* +set wildignore+=*/.git/* + +function! s:suite.pattern_a() abort + call s:assert.equals(neobundle#is_sourced('echodoc'), 1) + call s:assert.equals(neobundle#is_sourced('unite-build'), 1) +endfunction + +function! s:suite.pattern_b() abort + call s:assert.equals(neobundle#is_sourced('unite-ssh'), 1) + call s:assert.equals(neobundle#is_sourced('unite-sudo'), 1) +endfunction + +function! s:suite.pattern_c() abort + call s:assert.equals(neobundle#is_sourced('neomru.vim'), 0) + call s:assert.equals(neobundle#is_sourced('neocomplcache.vim'), 1) +endfunction + +function! s:suite.pattern_d() abort + call s:assert.equals(neobundle#is_sourced('vimshell'), 0) + call s:assert.equals(neobundle#is_sourced('vinarise'), 0) +endfunction + diff --git a/dot_vim/bundle/neobundle.vim/test/toml.vim b/dot_vim/bundle/neobundle.vim/test/toml.vim new file mode 100644 index 0000000..1624f5f --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/test/toml.vim @@ -0,0 +1,49 @@ +let s:suite = themis#suite('toml') +let s:assert = themis#helper('assert') + +let g:path = expand('~/test-bundle/'.fnamemodify(expand(''), ':t:r')) + +function! s:suite.before_each() abort + let g:temp = tempname() + call neobundle#begin(g:path) +endfunction + +function! s:suite.after_each() abort + call neobundle#end() + call delete(g:temp) +endfunction + +function! s:suite.no_toml() abort + call writefile([ + \ 'foobar' + \ ], g:temp) + call s:assert.equals(neobundle#parser#load_toml(g:temp, {}), 1) +endfunction + +function! s:suite.no_plugins() abort + call writefile([], g:temp) + call s:assert.equals(neobundle#parser#load_toml(g:temp, {}), 1) +endfunction + +function! s:suite.no_repository() abort + call writefile([ + \ "[[plugins]]", + \ "filetypes = 'all'", + \ "[[plugins]]", + \ "filetypes = 'all'" + \ ], g:temp) + call s:assert.equals(neobundle#parser#load_toml(g:temp, {}), 1) +endfunction + +function! s:suite.normal() abort + call writefile([ + \ "[[plugins]]", + \ "repository = 'Shougo/tabpagebuffer.vim'", + \ "filetypes = 'all'", + \ "[[plugins]]", + \ "repository = 'Shougo/tabpagebuffer.vim'", + \ "filetypes = 'all'" + \ ], g:temp) + call s:assert.equals(neobundle#parser#load_toml(g:temp, {}), 0) +endfunction + diff --git a/dot_vim/bundle/neobundle.vim/test/tsort.vim b/dot_vim/bundle/neobundle.vim/test/tsort.vim new file mode 100644 index 0000000..01650aa --- /dev/null +++ b/dot_vim/bundle/neobundle.vim/test/tsort.vim @@ -0,0 +1,182 @@ +let s:suite = themis#suite('tsort') +let s:assert = themis#helper('assert') + +let g:path = expand('~/test-bundle/'.fnamemodify(expand(''), ':t:r')) + +function! s:comp_bundle(bundle1, bundle2) abort + return a:bundle1.name > a:bundle2.name +endfunction + +function! s:rotate_bundle(bundles) abort + return a:bundles[1:-1]+a:bundles[0:0] +endfunction + +function! s:suite.before_each() abort +endfunction + +function! s:suite.after_each() abort +endfunction + +function! s:suite.no_depends() abort + " [a, b, c] => [a, b, c] + let neobundle_test_data = [{'name' : 'a'}, {'name' : 'b'}, {'name' : 'c'},] + call s:assert.equals(neobundle#config#tsort(neobundle_test_data), + \ neobundle_test_data) +endfunction + +function! s:suite.normal() abort + " a -> b -> c + " b -> d + " c + " [a, b, c] => [c, b, a] + let neobundle_test_data = [ + \ {'name' : 'a', 'depends' : [ + \ {'name' : 'b', 'depends' : [ + \ {'name' : 'c'}, + \ ]}, + \ ]}, + \ {'name' : 'b', 'skip' : 1, 'depends' : [ + \ {'name' : 'd', 'skipped' : 1, }, + \ ]}, + \ {'name' : 'c', 'skip' : 1}, + \ ] + call s:assert.equals(neobundle#config#tsort(neobundle_test_data), [ + \ neobundle_test_data[0].depends[0].depends[0], + \ neobundle_test_data[0].depends[0], + \ neobundle_test_data[0], + \ ]) + + " a -> c -> b + " a -> d + " b + " c + " [a, b, c] => [b, c, d, a] + let neobundle_test_data = [ + \ {'name' : 'a', 'depends' : [ + \ {'name' : 'c', 'depends' : [ + \ {'name' : 'b'}, + \ ]}, + \ {'name' : 'd'}, + \ ]}, + \ {'name' : 'b', 'skip' : 1}, + \ {'name' : 'c', 'skip' : 1}, + \ ] + call s:assert.equals(neobundle#config#tsort(neobundle_test_data), + \ [ + \ neobundle_test_data[0].depends[0].depends[0], + \ neobundle_test_data[0].depends[0], + \ neobundle_test_data[0].depends[1], + \ neobundle_test_data[0], + \ ]) +endfunction + +function! s:suite.tsort_circular_reference() abort + " a -> b -> c -> a + " b + " c + " [a, b, c] => [c, b, a] + let neobundle_test_data = [ + \ {'name' : 'a', 'depends' : [ + \ {'name' : 'b', 'depends' : [ + \ {'name' : 'c', 'depends' : [ + \ {'name' : 'a', 'skip' : 1}, + \ ]}, + \ ]}, + \ ]}, + \ {'name' : 'b', 'skip' : 1}, + \ {'name' : 'c', 'skip' : 1}, + \ ] + call s:assert.equals(neobundle#config#tsort(neobundle_test_data), + \ [ + \ neobundle_test_data[0].depends[0].depends[0], + \ neobundle_test_data[0].depends[0], + \ neobundle_test_data[0], + \ ]) +endfunction + +function! s:suite.bundled_no_depends() abort + call neobundle#begin(g:path) + NeoBundleLazy 'a/a' + NeoBundleLazy 'b/b' + NeoBundleLazy 'c/c' + call neobundle#end() + + let neobundle_test_data = sort(filter(neobundle#config#get_neobundles(), + \ "v:val.name =~# '^[abc]$'"), "s:comp_bundle") + + " [a, b, c] => [a, b, c] + call s:assert.equals(s:map(neobundle#config#tsort(neobundle_test_data)), + \ s:map(neobundle_test_data)) + + " [c, b, a] => [c, b, a] + call reverse(neobundle_test_data) + call s:assert.equals(s:map(neobundle#config#tsort(neobundle_test_data)), + \ s:map(neobundle_test_data)) +endfunction + +function! s:suite.bundled_normal() abort + call neobundle#begin(g:path) + NeoBundleLazy 'a/a' + NeoBundleLazy 'b/b', {'depends' : 'a/a'} + NeoBundleLazy 'c/c', {'depends' : 'b/b'} + call neobundle#end() + + let neobundle_test_data = sort(filter(neobundle#config#get_neobundles(), + \ "v:val.name =~# '^[abc]$'"), "s:comp_bundle") + + " [a, b, c] => [a, b, c] + call s:assert.equals(s:map(neobundle#config#tsort(neobundle_test_data)), + \ s:map(neobundle_test_data)) + + " [c, b, a] => [a, b, c] + call s:assert.equals(s:map(neobundle#config#tsort( + \ reverse(copy(neobundle_test_data)))), s:map(neobundle_test_data)) +endfunction + +function! s:suite.bundled_normal2() abort + call neobundle#begin(g:path) + NeoBundleLazy 'a/a', {'depends' : ['c/c', 'b/b']} + NeoBundleLazy 'b/b' + NeoBundleLazy 'c/c', {'depends' : 'b/b'} + call neobundle#end() + + let neobundle_test_data = sort(filter(neobundle#config#get_neobundles(), + \ "v:val.name =~# '^[abc]$'"), "s:comp_bundle") + let neobundle_test_rotated = s:map(s:rotate_bundle(neobundle_test_data)) + + " [a, b, c] => [b, c, a] + call s:assert.equals(s:map(neobundle#config#tsort( + \ neobundle_test_data)), + \ neobundle_test_rotated) + + " [c, b, a] => [b, c, a] + call s:assert.equals(s:map(neobundle#config#tsort( + \ reverse(copy(neobundle_test_data)))), + \ neobundle_test_rotated) +endfunction + +function! s:suite.bundled_circular_reference() abort + call neobundle#begin(g:path) + NeoBundleLazy 'a/a', {'depends' : 'b/b'} + NeoBundleLazy 'b/b', {'depends' : 'c/c'} + NeoBundleLazy 'c/c', {'depends' : 'a/a'} + call neobundle#end() + + let neobundle_test_data = sort(filter(neobundle#config#get_neobundles(), + \ "v:val.name =~# '^[abc]$'"), "s:comp_bundle") + + " [a, b, c] => [c, b, a] + call s:assert.equals(s:map(neobundle#config#tsort(neobundle_test_data)), + \ s:map(reverse(copy(neobundle_test_data)))) + + " [c, b, a] => [b, a, c] + call reverse(neobundle_test_data) + let neobundle_test_rotated = s:rotate_bundle(neobundle_test_data) + call s:assert.equals(s:map(neobundle#config#tsort(neobundle_test_data)), + \ s:map(neobundle_test_rotated)) +endfunction + +function! s:map(list) abort + return map(copy(a:list), 'v:val.name') +endfunction + diff --git a/dot_vim/dot_gitattributes b/dot_vim/dot_gitattributes new file mode 100644 index 0000000..2be8980 --- /dev/null +++ b/dot_vim/dot_gitattributes @@ -0,0 +1 @@ +* text eol=lf diff --git a/dot_vimrc b/dot_vimrc new file mode 100644 index 0000000..b92ae58 --- /dev/null +++ b/dot_vimrc @@ -0,0 +1,136 @@ +set nocompatible + +if has("gui_running") + let do_syntax_sel_menu=1 +endif + +set langmenu=none +if has("win32") || has("win64") + language messages en_US +else + language messages en_US.UTF-8 +endif + +if has("multi_byte") + if has("win32") || has("win64") + if has("gui_running") + set encoding=utf-8 + endif + endif + set encoding=utf-8 +endif + +set nocompatible + +" set modeline + +set backspace=indent,eol,start + +" Highlight problematic whitespace +" set listchars=tab:>.,trail:.,extends:#,nbsp:. +" set listchars=eol:¶,tab:»,trail:·,extends:>,precedes:<,nbsp:¤ +" il carattere per eol (¶) si ottiene con CTRL-vu00b6 +" il carattere per tab (») si ottiene con CTRL-vu00bb +" seguito da \ oppure +" il carattere per trail (·) si ottiene con CTRL-vu00b7 +" il carattere per extends (>) e' il carattere di maggiore +" il carattere per precedes (<) e' il carattere di minore +" il carattere per nbsp (¤) si ottiene con CTRL-vu00a4 +set listchars=eol:¶,tab:»\ ,trail:·,extends:>,precedes:<,nbsp:¤ + +set number +set relativenumber +set history=50 +set incsearch +set ignorecase +set smartcase +set wrapscan + +" Make the 'cw' and like commands put a $ at the end instead of +" just deleting the text and replacing it +set cpoptions=ces$ + +set statusline=%<%F\ %h%m%r%w%q\ %y\(%{&ff}\)\ %=\ \#%n\ ln:%l\/%L[%P]\ co:%c%V\ %b + +set lazyredraw +set showmode +set foldenable +set foldopen=block,insert,jump,mark,percent,quickfix,search,tag,undo +set whichwrap=b,s,h,l,<,>,[,] +set scrolljump=0 +set scrolloff=0 +set sidescrolloff=0 +set wildmenu +set showfulltag +set diffopt+=iwhite +set clipboard+=unnamed +set grepprg=grep\ -nH\ $* + +" let loaded_matchparen=1 + +set showtabline=2 +set nostartofline +set nospell " spell checking off (default!) +if has("autocmd") + filetype plugin indent on + augroup vimrcEx + au! + autocmd BufReadPost * + \ if line("'\"") > 1 && line("'\"") <= line("$") | + \ exe "normal! g`\"" | + \ endif + augroup END + +endif " has("autocmd") + +set nowrap +set autoindent +set tabstop=4 +set shiftwidth=4 +set softtabstop=4 +set noexpandtab + +if has("mouse") + set mouse=a +endif + +if &t_Co > 2 || has("gui_running") + syntax enable + set hlsearch + set synmaxcol=2048 +endif + +if has("cmdline_info") + set noruler + set showcmd +endif + +if has("statusline") + set laststatus=2 + set statusline=%<%f\ " Filename + set statusline+=%w%h%m%r " Options + set statusline+=\ [%{&ff}/%Y] " filetype + set statusline+=\ [%{getcwd()}] " current dir + "set statusline+=\ [A=\%03.3b/H=\%02.2B] " ASCII / Hexadecimal value of char + set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info +endif + +if has("gui_running") + " GUI + set cursorline + set guicursor=n-v-c:block-Cursor-blinkon0,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor,r-cr:hor20-Cursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175 + set cmdheight=2 " Abbreviato: set ch=2 + set mousehide +endif + +set shortmess+=I + +" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, +" so that you can undo CTRL-U after inserting a line break. +inoremap u + +set background=dark + +" +" vim: set tabstop=4:shiftwidth=4:filetype=vim:fdm=marker:fileformat=unix: +"