├── .gitignore
├── .vim
└── coc-settings.json
├── LICENSE
├── README.md
├── cmd
└── jarvim
│ └── main.go
├── go.mod
├── go.sum
├── install.sh
├── internal
├── cli
│ └── cli.go
├── logic
│ ├── interactive.go
│ └── logic.go
├── plugin
│ ├── appearance.go
│ ├── autoload.go
│ ├── core.go
│ ├── database.go
│ ├── enhance.go
│ ├── event.go
│ ├── explorer.go
│ ├── filetype.go
│ ├── fuzzyfind.go
│ ├── general.go
│ ├── initvim.go
│ ├── installscript.go
│ ├── keymap.go
│ ├── languages.go
│ ├── lsp.go
│ ├── pluginmanage.go
│ ├── program.go
│ ├── textobj.go
│ ├── theme.go
│ └── versioncontrol.go
├── render
│ ├── dein
│ │ └── dein.go
│ ├── render.go
│ └── vimplug
│ │ └── vimplug.go
└── vim
│ └── vim.go
├── pkg
├── cli
│ └── cli.go
├── color
│ └── color.go
└── util
│ └── util.go
└── template
├── bufkill.go
├── difftools.go
├── hlsearch.go
├── nicefold.go
└── whitespace.go
/.gitignore:
--------------------------------------------------------------------------------
1 | */jarvis
2 |
--------------------------------------------------------------------------------
/.vim/coc-settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "cSpell.words": [
3 | "defx",
4 | "rhysd"
5 | ]
6 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2020, Raphael
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | 1. Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | 2. Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | 3. Neither the name of the copyright holder nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |

3 |
Generate a module vim configruation like VIM PRO!
4 |
5 |
6 | > I have been maintaining [Thinkvim](https://github.com/hardcoreplayers/ThinkVim) for a long time, and slowly it deviated from my original intention. At first I wanted
7 | > to use it as a vim configuration template for Vimer to use, but slowly it has to accept everyone’s preferences, I have
8 | > to get Add more language support and other plug-in configurations, thinkvim becomes more and more bloated. This is wrong.
9 | > I think that vim should be lightweight, so I wrote this cli tool jarvim, which will generate a greateful configuration
10 | > for you, there are some useful hacks in the generated configuration, I hope it can help you, if you are new to vim, you
11 | > no longer need to refer to other people's configurations, you can use the generated configuration as your starting point
12 | > This will greatly save your time.
13 |
14 | ## Install
15 |
16 | You can download build binary file from release page https://github.com/glepnir/jarvim/releases
17 |
18 | **MacOs brew**
19 |
20 | ```console
21 | brew tap glepnir/jarvim
22 | brew install jarvim
23 | ```
24 |
25 | **Linux**
26 |
27 | ```console
28 | curl -fLo install.sh https://raw.githubusercontent.com/glepnir/jarvim/master/install.sh
29 | sh install.sh
30 | ./jarvim -g
31 | ```
32 |
33 | **Install From Source**
34 |
35 | ```go
36 | go get github.com/glepnir/jarvim
37 | ```
38 |
39 | ## Usage
40 |
41 | **Here is a [gif](https://github.com/glepnir/jarvim/wiki) to show how to use jarvim.**
42 |
43 | ```
44 | -v to print jarvim version.
45 | -g to generate vim configuration.
46 | ```
47 |
48 | ## FAQ
49 |
50 | - Why the symbols look weird in my vim ?
51 |
52 | Make sure you have installed nerdfont font from https://www.nerdfonts.com/, Different fonts may be inconsistent in the performance of symbols.
53 | The solution, If you use Mac with iterm2, you can set a different font for the symbol.
54 |
55 |
56 |
57 |
58 |
59 | Another way I recommend you to use [kitty terminal](https://github.com/kovidgoyal/kitty), it has built-in symbol font support.Kitty support
60 | Mac and Linux.
61 |
62 | Normal graphics should be like this
63 |
64 |
65 |
66 |
67 |
68 | ## Donate
69 |
70 | Do you like jarvim? buy me a coffe 😘!
71 |
72 | [](https://www.paypal.me/bobbyhub)
73 |
74 | | Wechat | AliPay |
75 | | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
76 | |  |  |
77 |
78 | ## LICENSE
79 |
80 | - MIT
81 |
--------------------------------------------------------------------------------
/cmd/jarvim/main.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 The jarvim Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package main
6 |
7 | import "github.com/glepnir/jarvim/internal/cli"
8 |
9 | func main() {
10 | cli.Execute()
11 | }
12 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/glepnir/jarvim
2 |
3 | go 1.14
4 |
5 | require (
6 | github.com/AlecAivazis/survey/v2 v2.0.8
7 | github.com/spf13/cobra v1.0.0
8 | )
9 |
--------------------------------------------------------------------------------
/go.sum:
--------------------------------------------------------------------------------
1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
2 | github.com/AlecAivazis/survey v1.8.8 h1:Y4yypp763E8cbqb5RBqZhGgkCFLRFnbRBHrxnpMMsgQ=
3 | github.com/AlecAivazis/survey/v2 v2.0.8 h1:zVjWKN+JIAfmrq6nGWG3DfLS8ypEBhxYy0p7FM+riFk=
4 | github.com/AlecAivazis/survey/v2 v2.0.8/go.mod h1:9FJRdMdDm8rnT+zHVbvQT2RTSTLq0Ttd6q3Vl2fahjk=
5 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
6 | github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8/go.mod h1:oX5x61PbNXchhh0oikYAH+4Pcfw5LKv21+Jnpr6r6Pc=
7 | github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
8 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
9 | github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
10 | github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
11 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
12 | github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
13 | github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
14 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
15 | github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
16 | github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
17 | github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
18 | github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
19 | github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
20 | github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
21 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
22 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
23 | github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
24 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
25 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
26 | github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
27 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
28 | github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
29 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
30 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
31 | github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
32 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
33 | github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
34 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
35 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
36 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
37 | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
38 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
39 | github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
40 | github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
41 | github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
42 | github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
43 | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
44 | github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A=
45 | github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
46 | github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
47 | github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
48 | github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
49 | github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
50 | github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
51 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
52 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
53 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
54 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
55 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
56 | github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
57 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
58 | github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
59 | github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
60 | github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
61 | github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
62 | github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
63 | github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
64 | github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
65 | github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
66 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
67 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
68 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
69 | github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
70 | github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
71 | github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
72 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
73 | github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
74 | github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
75 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
76 | github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
77 | github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
78 | github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
79 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
80 | github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
81 | github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
82 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
83 | github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
84 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
85 | github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
86 | github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
87 | github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
88 | github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
89 | github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
90 | github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8=
91 | github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
92 | github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
93 | github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
94 | github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
95 | github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
96 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
97 | github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
98 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
99 | github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
100 | github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
101 | github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
102 | github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
103 | go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
104 | go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
105 | go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
106 | go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
107 | golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
108 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
109 | golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5 h1:8dUaAV7K4uHsF56JQWkprecIQKdPHtR9jCHF5nB8uzc=
110 | golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
111 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
112 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
113 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
114 | golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
115 | golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
116 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
117 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
118 | golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
119 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
120 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
121 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
122 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
123 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
124 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
125 | golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
126 | golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
127 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
128 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
129 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
130 | golang.org/x/sys v0.0.0-20190530182044-ad28b68e88f1 h1:R4dVlxdmKenVdMRS/tTspEpSTRWINYrHD8ySIU9yCIU=
131 | golang.org/x/sys v0.0.0-20190530182044-ad28b68e88f1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
132 | golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
133 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
134 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
135 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
136 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
137 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
138 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
139 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
140 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
141 | google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
142 | gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
143 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
144 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
145 | gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
146 | gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
147 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
148 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
149 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
150 |
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -u
4 |
5 | APP=jarvim
6 |
7 | DOWNLOAD_URL="https://github.com/glepnir/jarvim/releases/latest/download/"
8 |
9 | exists() {
10 | command -v "$1" >/dev/null 2>&1
11 | }
12 |
13 | download() {
14 | local from=$1
15 | local to=$2
16 | if exists "curl"; then
17 | curl -fLo "$to" "$from"
18 | elif exists 'wget'; then
19 | wget --output-document="$to" "$from"
20 | else
21 | echo 'curl or wget is required'
22 | exit 1
23 | fi
24 | }
25 |
26 | try_download() {
27 | local asset=$1
28 | if [ -z "${TMPDIR+x}" ]; then
29 | rm -f $APP
30 | download "$DOWNLOAD_URL/$asset" $APP
31 | else
32 | local temp=${TMPDIR}/jarvim
33 | download "$DOWNLOAD_URL/$asset" "$temp"
34 | mv "$temp" $APP
35 | fi
36 | chmod a+x "$APP"
37 | }
38 |
39 | main() {
40 | osname=$(uname -sm)
41 | case "${osname}" in
42 | "Linux x86_64")
43 | try_download "$APP"-x86_64-linux ;;
44 | "Darwin x86_64")
45 | try_download "$APP"-x86_64-darwin ;;
46 | *)
47 | echo "No prebuilt jarvim binary available for ${osname}."
48 | exit 1
49 | ;;
50 | esac
51 | }
52 |
53 | main
54 |
--------------------------------------------------------------------------------
/internal/cli/cli.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 The jarvim Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package cli
6 |
7 | import (
8 | "fmt"
9 | "log"
10 | "os"
11 |
12 | "github.com/glepnir/jarvim/internal/logic"
13 | "github.com/spf13/cobra"
14 | )
15 |
16 | var (
17 | cli_version = "0.2.3"
18 | version bool
19 | genConfig bool
20 | )
21 |
22 | var rootCmd = &cobra.Command{
23 | Use: "jarvim",
24 | Short: "jarvim is a cli tool to generate a module vim configruation which like a pro",
25 | Long: "jarvim is a cli tool to generate a module vim configruation which like a pro",
26 | RunE: func(cmd *cobra.Command, args []string) error {
27 | if version {
28 | return printVersion()
29 | }
30 | if genConfig {
31 | return logic.RunLogic()
32 | }
33 | return cmd.Help()
34 | },
35 | }
36 |
37 | func init() {
38 | cobra.OnInitialize()
39 | rootCmd.Flags().BoolVarP(&version, "Version", "v", false, "show current version of CLI")
40 | rootCmd.Flags().BoolVarP(&genConfig, "Generate vim config", "g", false, "generate new configuration")
41 | }
42 |
43 | // Execute do the rootmcmd.Execute() function
44 | func Execute() {
45 | if err := rootCmd.Execute(); err != nil {
46 | log.Fatal(err)
47 | os.Exit(1)
48 | }
49 | }
50 |
51 | func printVersion() error {
52 | fmt.Println("Version: ", cli_version)
53 | return nil
54 | }
55 |
--------------------------------------------------------------------------------
/internal/logic/interactive.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 The jarvim Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package logic
6 |
7 | import (
8 | "github.com/glepnir/jarvim/internal/plugin"
9 | "github.com/glepnir/jarvim/internal/render"
10 | "github.com/glepnir/jarvim/internal/render/dein"
11 | "github.com/glepnir/jarvim/internal/render/vimplug"
12 | "github.com/glepnir/jarvim/internal/vim"
13 | "github.com/glepnir/jarvim/pkg/cli"
14 | )
15 |
16 | // PluginManage return the plugin management plugin
17 | // that user select
18 | func PluginManage() render.Render {
19 | message := "What is plugin manage do you use?"
20 | options := []string{"dein", "vim-plug"}
21 | pm := cli.SingleSelectTemplate(message, options)
22 | if pm == "dein" {
23 | return new(dein.Dein)
24 | } else {
25 | return new(vimplug.VimPlug)
26 | }
27 | }
28 |
29 | // NewDatFileMap according the render type return
30 | // datafilemap
31 | func NewDataFileMap(r render.Render) map[string]string {
32 | _, ok := r.(*dein.Dein)
33 | if ok {
34 | return map[string]string{
35 | "MarkDown": plugin.DeinMarkDown,
36 | "Toml": plugin.DeinToml,
37 | "Nginx": plugin.DeinNginx,
38 | "Json": plugin.DeinJson,
39 | "Dockerfile": plugin.DeinDockerFile,
40 | }
41 | }
42 | return map[string]string{
43 | "MarkDown": plugin.PlugMarkDown,
44 | "Toml": plugin.PlugToml,
45 | "Nginx": plugin.PlugNginx,
46 | "Json": plugin.PlugJson,
47 | "Dockerfile": plugin.PlugDockerFile,
48 | }
49 |
50 | }
51 |
52 | // NewENewEnhancePluginMap return the enhance plugin map
53 | // according plugin management type
54 | func NewEnhancePluginMap(r render.Render) map[string]string {
55 | _, ok := r.(*dein.Dein)
56 | if ok {
57 | return map[string]string{
58 | "accelerated-jk accelerate up-down moving (j and k mapping)": plugin.DeinFastJK,
59 | "vim-mundo vim undo tree": plugin.DeinMundo,
60 | "vim-easymotion fast jump": plugin.DeinEasyMotion,
61 | "rainbow rainbow parentheses": plugin.DeinRainbow,
62 | "vim-floterm vim terminal float": plugin.DeinFloaterm,
63 | }
64 | }
65 | return map[string]string{
66 | "accelerated-jk accelerate up-down moving (j and k mapping)": plugin.PlugFastJK,
67 | "vim-mundo vim undo tree": plugin.PlugMundo,
68 | "vim-easymotion fast jump": plugin.PlugEasyMotion,
69 | "rainbow rainbow parentheses": plugin.PlugRainbow,
70 | "vim-floterm vim terminal float": plugin.PlugFloaterm,
71 | }
72 | }
73 |
74 | // NewVersionPluginMap return the version control map
75 | func NewVersionPluginMap(r render.Render) map[string]string {
76 | _, ok := r.(*dein.Dein)
77 | if ok {
78 | return map[string]string{
79 | "jreybert/vimagit": plugin.DeinVimagt,
80 | "tpope/vim-fugitive": plugin.DeinFugiTive,
81 | "lambdalisue/gina.vim": plugin.DeinGina,
82 | }
83 | }
84 | return map[string]string{
85 | "jreybert/vimagit": plugin.PlugVimagit,
86 | "tpope/vim-fugitive": plugin.PlugFugTive,
87 | "lambdalisue/gina.vim": plugin.PlugGina,
88 | }
89 |
90 | }
91 |
92 | // NewLanguagePlugMap return the lanuages config map
93 | func NewLanguagePlugMap(r render.Render) map[string]string {
94 | _, ok := r.(*dein.Dein)
95 | if ok {
96 | return map[string]string{
97 | "C-family": plugin.DeinCFamily,
98 | "R": plugin.DeinR,
99 | "Javascript": plugin.DeinJavascript,
100 | "Typescript": plugin.DeinTypescript,
101 | "Dart": plugin.DeinDart,
102 | "React": plugin.DeinReact,
103 | "Vue": plugin.DeinVue,
104 | "Go": plugin.DeinGo,
105 | "Rust": plugin.DeinRust,
106 | "Haskell": plugin.DeinHaskell,
107 | "Php": plugin.DeinPhp,
108 | "Ruby": plugin.DeinRuby,
109 | "Scala": plugin.DeinScala,
110 | "Shell": plugin.DeinShell,
111 | "Lua": plugin.DeinLua,
112 | "Python": plugin.DeinPython,
113 | "Html": plugin.DeinHtml,
114 | "Css": plugin.DeinCss,
115 | "Less": plugin.DeinLess,
116 | "Sass scss": plugin.DeinSass,
117 | "Stylus": plugin.DeinStylus,
118 | }
119 | }
120 | return map[string]string{
121 | "C-family": plugin.PlugCFamily,
122 | "R": plugin.PlugR,
123 | "Javascript": plugin.PlugJavascript,
124 | "Typescript": plugin.PlugTypescript,
125 | "Dart": plugin.PlugDart,
126 | "React": plugin.PlugReact,
127 | "Vue": plugin.PlugVue,
128 | "Go": plugin.PlugGo,
129 | "Rust": plugin.PlugRust,
130 | "Haskell": plugin.PlugHaskell,
131 | "Php": plugin.PlugPhp,
132 | "Ruby": plugin.PlugRuby,
133 | "Scala": plugin.PlugScala,
134 | "Shell": plugin.PlugShell,
135 | "Lua": plugin.PlugLua,
136 | "Python": plugin.PlugPython,
137 | "Html": plugin.PlugHtml,
138 | "Css": plugin.PlugCss,
139 | "Less": plugin.PlugLess,
140 | "Sass scss": plugin.PlugSass,
141 | "Stylus": plugin.PlugStylus,
142 | }
143 |
144 | }
145 |
146 | // Leaderkey get the user LeaderKey
147 | func LeaderKey() string {
148 | message := "What is your Leader Key?"
149 | options := []string{"Space", "Comma(,)", "Semicolon(;)"}
150 | return cli.SingleSelectTemplate(message, options)
151 | }
152 |
153 | // LocalLeaderKey get the user LocalLeaderKey
154 | func LocalLeaderKey() string {
155 | message := "What is your LocalLeader Key?"
156 | options := []string{"Space", "Comma(,)", "Semicolon(;)"}
157 | return cli.SingleSelectTemplate(message, options)
158 | }
159 |
160 | // Colorscheme get the user colorshemes
161 | func Colorscheme() []string {
162 | questionname := "Colorscheme Question"
163 | message := "Choose your favorite colorscheme"
164 | pagesize := 19
165 | options := make([]string, 0)
166 | for k, _ := range vim.ColorschemeMap {
167 | options = append(options, k)
168 | }
169 | return cli.MultiSelectTemplate(questionname, message, options, pagesize)
170 | }
171 |
172 | // DashboardPlugin return bool according user choose
173 | func DashboardPlugin() bool {
174 | message := "Do you want use dashboard-nvim a better StartScreenPlugin?"
175 | return cli.ConfirmTemplate(message)
176 | }
177 |
178 | // BufferLinePlugin return bool according user choose
179 | func BufferLinePlugin() bool {
180 | message := "Do you want use vim-buffet as your bufferline?"
181 | return cli.ConfirmTemplate(message)
182 | }
183 |
184 | // SpacelinePlugin return bool according user choose
185 | func SpacelinePlugin() bool {
186 | message := "Do you want use spaceline.vim a light and beautiful statusline?"
187 | return cli.ConfirmTemplate(message)
188 | }
189 |
190 | // ExplorerPlugin return the explorer plugin
191 | func ExplorerPlugin() string {
192 | message := "What is your explorer plugin?"
193 | options := []string{"defx.nvim", "nerdtree", "coc-explorer"}
194 | return cli.SingleSelectTemplate(message, options)
195 | }
196 |
197 | // DatabasePlugin return bool according user choose
198 | func DatabasePlugin() bool {
199 | message := "Do you need database plugins?"
200 | return cli.ConfirmTemplate(message)
201 | }
202 |
203 | // FuzzyFindPlugin return bool according user choose
204 | func FuzzyFindPlugin() bool {
205 | message := "Do you want use fuzzy find plugin vim-clap?"
206 | return cli.ConfirmTemplate(message)
207 | }
208 |
209 | // EditorConfigPlugin return bool according user choose
210 | func EditorConfigPlugin() bool {
211 | message := "Do you want use editorconfig to control program style(like indent,whitespace etc)"
212 | return cli.ConfirmTemplate(message)
213 | }
214 |
215 | // IndentLinePlugin return string according user choose
216 | func IndentLinePlugin() string {
217 | message := "Choose your favorite indentline plugin?"
218 | options := []string{"Yggdroot/indentLine", "nathanaelkane/vim-indent-guides"}
219 | return cli.SingleSelectTemplate(message, options)
220 | }
221 |
222 | // CommentPlugin return bool according user choose
223 | func CommentPlugin() bool {
224 | message := "Do you want to use Caw.vim as comment plugin?"
225 | return cli.ConfirmTemplate(message)
226 | }
227 |
228 | // ViewSymbolsPlugin return bool according user choose
229 | func ViewSymbolsPlugin() bool {
230 | message := "Do you want to use vista.vim to view tags and LSP symbols in sidebar"
231 | return cli.ConfirmTemplate(message)
232 | }
233 |
234 | // GentagsPlugin return bool according user choose
235 | func GentagsPlugin() bool {
236 | message := "Do you want to use vim-gutentags to gen tags"
237 | return cli.ConfirmTemplate(message)
238 | }
239 |
240 | // QuickRunPlugin return bool according user choose
241 | func QuickRunPlugin() bool {
242 | message := "Do you want to use vim-quickrun to fast run program in vim?"
243 | return cli.ConfirmTemplate(message)
244 | }
245 |
246 | // DataTypeFile return string slice according user choose
247 | func DataTypeFile(r render.Render) []string {
248 | questionname := "Data filetype"
249 | message := "Which Data filetype you need?"
250 | pagesize := 10
251 | options := make([]string, 0)
252 | for k, _ := range NewDataFileMap(r) {
253 | options = append(options, k)
254 | }
255 |
256 | return cli.MultiSelectTemplate(questionname, message, options, pagesize)
257 | }
258 |
259 | // EnhancePlugin return string slice according user choose
260 | func EnhancePlugin(r render.Render) []string {
261 | questionname := "Enhance question"
262 | message := "Choose the enhance plugins that you need "
263 | pagesize := 10
264 | options := make([]string, 0)
265 | for k, _ := range NewEnhancePluginMap(r) {
266 | options = append(options, k)
267 | }
268 |
269 | return cli.MultiSelectTemplate(questionname, message, options, pagesize)
270 | }
271 |
272 | // SandWichPlugin return bool according user choose
273 | func SandWichPlugin() bool {
274 | message := "Do you want use vim-sandwich more useful than vim-surround?"
275 | return cli.ConfirmTemplate(message)
276 | }
277 |
278 | // VersionControlPlugin return string slice according user choose
279 | func VersionControlPlugin(r render.Render) []string {
280 | questionname := "Version Control plugin"
281 | message := "Choose the version control plugins that you need"
282 | pagesize := 10
283 |
284 | options := make([]string, 0)
285 | for k, _ := range NewVersionPluginMap(r) {
286 | options = append(options, k)
287 | }
288 |
289 | return cli.MultiSelectTemplate(questionname, message, options, pagesize)
290 | }
291 |
292 | // LanguageServerProtocol return string slice according user choose
293 | func LanguageServerProtocol(r render.Render) []string {
294 | questionname := "LanguageQuestion"
295 | message := "What Languages do you write"
296 | pagesize := 19
297 | options := make([]string, 0)
298 | for k, _ := range NewLanguagePlugMap(r) {
299 | options = append(options, k)
300 | }
301 | return cli.MultiSelectTemplate(questionname, message, options, pagesize)
302 | }
303 |
--------------------------------------------------------------------------------
/internal/logic/logic.go:
--------------------------------------------------------------------------------
1 | // Package logic provides ...
2 | package logic
3 |
4 | import (
5 | "github.com/glepnir/jarvim/internal/vim"
6 | "github.com/glepnir/jarvim/pkg/util"
7 | )
8 |
9 | // RunLogic run our logic
10 | func RunLogic() error {
11 | util.EnsureFoldersExist(vim.ConfPath, vim.ConfCore, vim.ConfAutoload, vim.ConfModules, vim.CachePath, vim.ConfPlugin)
12 | r := PluginManage()
13 | vim.Leaderkey = LeaderKey()
14 | vim.LocalLeaderKey = LocalLeaderKey()
15 | vim.Colorscheme = Colorscheme()
16 | vim.StartScreenPlugin = DashboardPlugin()
17 | vim.StatusLine = SpacelinePlugin()
18 | vim.BufferLine = BufferLinePlugin()
19 | vim.Explorer = ExplorerPlugin()
20 | vim.Database = DatabasePlugin()
21 | vim.Fuzzyfind = FuzzyFindPlugin()
22 | vim.EditorConfig = EditorConfigPlugin()
23 | vim.IndentPlugin = IndentLinePlugin()
24 | vim.CommentPlugin = CommentPlugin()
25 | vim.OutLinePlugin = ViewSymbolsPlugin()
26 | vim.TagsPlugin = GentagsPlugin()
27 | vim.QuickRun = QuickRunPlugin()
28 | vim.DataTypeFile = DataTypeFile(r)
29 | vim.EnhancePlugins = EnhancePlugin(r)
30 | vim.SandwichPlugin = SandWichPlugin()
31 | vim.VersionControlPlugin = VersionControlPlugin(r)
32 | vim.UserLanguages = LanguageServerProtocol(r)
33 | r.GenerateInit()
34 | r.GenerateCore(vim.Leaderkey, vim.LocalLeaderKey, vim.LeaderKeyMap)
35 | r.GeneratePlugMan()
36 | r.GenerateGeneral()
37 | r.GenerateAutoloadFunc()
38 | r.GeneratePluginFolder()
39 | r.GenerateDevIcons()
40 | r.GenerateTheme()
41 | r.GenerateCacheTheme(vim.Colorscheme, vim.ColorschemeMap)
42 | r.GenerateColorscheme(vim.Colorscheme)
43 | r.GenerateDashboard(vim.StartScreenPlugin)
44 | r.GenerateBufferLine(vim.BufferLine)
45 | r.GenerateStatusLine(vim.StatusLine)
46 | r.GenerateExplorer(vim.Explorer)
47 | r.GenerateDatabase(vim.Database)
48 | r.GenerateFuzzyFind(vim.Fuzzyfind)
49 | r.GenerateEditorConfig(vim.EditorConfig)
50 | r.GenerateIndentLine(vim.IndentPlugin)
51 | r.GenerateComment(vim.CommentPlugin)
52 | r.GenerateOutLine(vim.OutLinePlugin)
53 | r.GenerateTags(vim.TagsPlugin)
54 | r.GenerateQuickRun(vim.QuickRun)
55 | r.GenerateDataTypeFile(vim.DataTypeFile, NewDataFileMap(r))
56 | r.GenerateEnhanceplugin(vim.EnhancePlugins, NewEnhancePluginMap(r))
57 | r.GenerateSandWich(vim.SandwichPlugin)
58 | r.GenerateTextObj()
59 | r.GenerateVersionControl(vim.VersionControlPlugin, NewVersionPluginMap(r))
60 | r.GenerateCocJson()
61 | r.GenerateVimMap()
62 | r.GenerateLanguagePlugin(vim.UserLanguages, NewLanguagePlugMap(r))
63 | r.GenerateInstallScripts()
64 | return nil
65 | }
66 |
--------------------------------------------------------------------------------
/internal/plugin/appearance.go:
--------------------------------------------------------------------------------
1 | // Package plugin provides ...
2 | package plugin
3 |
4 | const (
5 | // DeinDevicons plugin
6 | DeinDevicons = `
7 | [[plugins]]
8 | repo = 'ryanoasis/vim-devicons'
9 | `
10 | DeinColorscheme = `
11 | {{range .}}
12 | [[plugins]]
13 | repo = '{{.}}'
14 | {{end}}
15 | `
16 |
17 | // DeinDashboard plugin
18 | DeinDashboard = `
19 | [[plugins]]
20 | repo = 'glepnir/dashboard-nvim'
21 | `
22 | // DeinStatusline plugin
23 | DeinStatusline = `
24 | [[plugins]]
25 | repo = 'glepnir/spaceline.vim'
26 | hook_source = '''
27 | let g:spaceline_seperate_style= 'slant'
28 | '''
29 | `
30 | // DeinBufferLine plugin
31 | DeinBufferLine = `
32 | [[plugins]]
33 | repo = 'romgrk/barbar.nvim'
34 | on_event = ['BufReadPre','BufNewFile']
35 | `
36 | // PlugColorscheme
37 | PlugColorscheme = `
38 | {{range .}}
39 | Plug '{{.}}'
40 | {{end}}
41 | `
42 | // PlugDevicons
43 | PlugDevicons = `
44 | Plug 'ryanoasis/vim-devicons'
45 | `
46 | // PlugDashboard
47 | PlugDashboard = `
48 | Plug 'glepnir/dashboard-nvim'
49 | `
50 | //PlugBufferLine
51 | PlugBufferLine = `
52 | Plug 'romgrk/barbar.nvim'
53 | `
54 | //PlugStatusline
55 | PlugStatusline = `
56 | Plug 'glepnir/spaceline.vim'
57 | `
58 | // PlugStatuslineSetting
59 | PlugStatuslineSetting = `
60 | let g:spaceline_seperate_style= 'slant'
61 | `
62 | )
63 |
--------------------------------------------------------------------------------
/internal/plugin/autoload.go:
--------------------------------------------------------------------------------
1 | // Package plugin provides ...
2 | package plugin
3 |
4 | // AutoloadLoadEnv is a hack load data from .env file
5 | const AutoloadLoadEnv = `
6 | " Load Env file and return env content
7 | function! initself#load_env()
8 | let l:env_file = getenv("HOME")."/.env"
9 | let l:env_dict={}
10 | if filereadable(l:env_file)
11 | let l:env_content = readfile(l:env_file)
12 | for item in l:env_content
13 | let l:env_dict[split(item,"=")[0]] = split(item,"=")[1]
14 | endfor
15 | return l:env_dict
16 | else
17 | echo "env file doesn't exist"
18 | endif
19 | endfunction
20 |
21 | " Load database connection from env file
22 | function! initself#load_db_from_env()
23 | let l:env = initself#load_env()
24 | let l:dbs={}
25 | for key in keys(l:env)
26 | if stridx(key,"DB_CONNECTION_") >= 0
27 | let l:dbs[split(key,"_")[2]] = l:env[key]
28 | endif
29 | endfor
30 | if empty(l:dbs)
31 | echo "Env Database config error"
32 | endif
33 | return l:dbs
34 | endfunction
35 | `
36 |
37 | // AutoloadSourceFile is a hack to source file
38 | const AutoloadSourceFile = `
39 | function! initself#source_file(root_path,path, ...)
40 | " Source user configuration files with set/global sensitivity
41 | let use_global = get(a:000, 0, ! has('vim_starting'))
42 | let abspath = resolve(a:root_path . '/' . a:path)
43 | if ! use_global
44 | execute 'source' fnameescape(abspath)
45 | return
46 | endif
47 |
48 | let tempfile = tempname()
49 | let content = map(readfile(abspath),
50 | \ "substitute(v:val, '^\\W*\\zsset\\ze\\W', 'setglobal', '')")
51 | try
52 | call writefile(content, tempfile)
53 | execute printf('source %s', fnameescape(tempfile))
54 | finally
55 | if filereadable(tempfile)
56 | call delete(tempfile)
57 | endif
58 | endtry
59 | endfunction
60 | `
61 |
62 | // AutoloadMkdir ensure dir exist
63 | const AutoloadMkdir = `
64 | " Credits: https://github.com/Shougo/shougo-s-github/blob/master/vim/rc/options.rc.vim#L147
65 | " mkdir
66 | function! initself#mkdir_as_necessary(dir, force) abort
67 | if !isdirectory(a:dir) && &l:buftype == '' &&
68 | \ (a:force || input(printf('"%s" does not exist. Create? [y/N]',
69 | \ a:dir)) =~? '^y\%[es]$')
70 | call mkdir(iconv(a:dir, &encoding, &termencoding), 'p')
71 | endif
72 | endfunction
73 | `
74 |
75 | // AutoloadCoc
76 | const AutoloadCoc = `
77 | " Jump definition in other window
78 | function! initself#definition_other_window() abort
79 | if winnr('$') >= 4 || winwidth(0) < 120
80 | exec "normal \(coc-definition)"
81 | else
82 | exec 'vsplit'
83 | exec "normal \(coc-definition)"
84 | endif
85 | endfunction
86 |
87 | " COC select the current word
88 | function! initself#select_current_word()
89 | if !get(g:, 'coc_cursors_activated', 0)
90 | return "\(coc-cursors-word)"
91 | endif
92 | return "*\(coc-cursors-word):nohlsearch\"
93 | endfunction
94 | `
95 |
--------------------------------------------------------------------------------
/internal/plugin/core.go:
--------------------------------------------------------------------------------
1 | // Package plugin provides ...
2 | package plugin
3 |
4 | // Core is dein
5 | const Core = `
6 | if &compatible
7 | " vint: -ProhibitSetNoCompatible
8 | set nocompatible
9 | " vint: +ProhibitSetNoCompatible
10 | endif
11 |
12 | " Set main configuration directory as parent directory
13 | let $VIM_PATH = fnamemodify(resolve(expand(':p')), ':h:h')
14 |
15 | " Set data/cache directory as $XDG_CACHE_HOME/vim
16 | let $DATA_PATH =
17 | \ expand(($XDG_CACHE_HOME ? $XDG_CACHE_HOME : '~/.cache') . '/vim')
18 |
19 | " Disable vim distribution plugins
20 | let g:loaded_gzip = 1
21 | let g:loaded_tar = 1
22 | let g:loaded_tarPlugin = 1
23 | let g:loaded_zip = 1
24 | let g:loaded_zipPlugin = 1
25 |
26 | let g:loaded_getscript = 1
27 | let g:loaded_getscriptPlugin = 1
28 | let g:loaded_vimball = 1
29 | let g:loaded_vimballPlugin = 1
30 |
31 | let g:loaded_matchit = 1
32 | let g:loaded_matchparen = 1
33 | let g:loaded_2html_plugin = 1
34 | let g:loaded_logiPat = 1
35 | let g:loaded_rrhelper = 1
36 |
37 | let g:loaded_netrw = 1
38 | let g:loaded_netrwPlugin = 1
39 | let g:loaded_netrwSettings = 1
40 | let g:loaded_netrwFileHandlers = 1
41 |
42 | " Initialize base requirements
43 | if has('vim_starting')
44 | " Use spacebar as leader and ; as secondary-leader
45 | " Required before loading plugins!
46 | let g:mapleader="{{index . 0}}"
47 | let g:maplocalleader="{{index . 1}}"
48 |
49 | " Release keymappings prefixes, evict entirely for use of plug-ins.
50 | nnoremap
51 | xnoremap
52 | nnoremap ,
53 | xnoremap ,
54 | nnoremap ;
55 | xnoremap ;
56 |
57 | endif
58 |
59 | call initself#source_file($VIM_PATH,'core/dein.vim')
60 | call initself#source_file($VIM_PATH,'core/general.vim')
61 | call initself#source_file($VIM_PATH,'core/event.vim')
62 | call initself#source_file($VIM_PATH,'core/pmap.vim')
63 | call initself#source_file($VIM_PATH,'core/vmap.vim')
64 | call theme#theme_init()
65 |
66 | set secure
67 |
68 | " vim: set ts=2 sw=2 tw=80 noet :
69 | `
70 |
71 | // PlugCore is vim-plug
72 | const PlugCore = `
73 | if &compatible
74 | " vint: -ProhibitSetNoCompatible
75 | set nocompatible
76 | " vint: +ProhibitSetNoCompatible
77 | endif
78 |
79 | " Set main configuration directory as parent directory
80 | let $VIM_PATH = fnamemodify(resolve(expand(':p')), ':h:h')
81 |
82 | " Set data/cache directory as $XDG_CACHE_HOME/vim
83 | let $DATA_PATH =
84 | \ expand(($XDG_CACHE_HOME ? $XDG_CACHE_HOME : '~/.cache') . '/vim')
85 |
86 | " Disable vim distribution plugins
87 | let g:loaded_gzip = 1
88 | let g:loaded_tar = 1
89 | let g:loaded_tarPlugin = 1
90 | let g:loaded_zip = 1
91 | let g:loaded_zipPlugin = 1
92 |
93 | let g:loaded_getscript = 1
94 | let g:loaded_getscriptPlugin = 1
95 | let g:loaded_vimball = 1
96 | let g:loaded_vimballPlugin = 1
97 |
98 | let g:loaded_matchit = 1
99 | let g:loaded_matchparen = 1
100 | let g:loaded_2html_plugin = 1
101 | let g:loaded_logiPat = 1
102 | let g:loaded_rrhelper = 1
103 |
104 | let g:loaded_netrw = 1
105 | let g:loaded_netrwPlugin = 1
106 | let g:loaded_netrwSettings = 1
107 | let g:loaded_netrwFileHandlers = 1
108 |
109 | " Initialize base requirements
110 | if has('vim_starting')
111 | " Use spacebar as leader and ; as secondary-leader
112 | " Required before loading plugins!
113 | let g:mapleader="{{index . 0}}"
114 | let g:maplocalleader="{{index . 1}}"
115 |
116 | " Release keymappings prefixes, evict entirely for use of plug-ins.
117 | nnoremap
118 | xnoremap
119 | nnoremap ,
120 | xnoremap ,
121 | nnoremap ;
122 | xnoremap ;
123 |
124 | endif
125 |
126 | call initself#source_file($VIM_PATH,'core/plug.vim')
127 | call initself#source_file($VIM_PATH,'core/general.vim')
128 | call initself#source_file($VIM_PATH,'core/event.vim')
129 | call initself#source_file($VIM_PATH,'core/vmap.vim')
130 | call theme#theme_init()
131 |
132 | let s:config_paths = split(globpath('$VIM_PATH/modules/', '*'), '\n')
133 |
134 | for config in s:config_paths
135 | exec 'source'. config .'/config.vim'
136 | endfor
137 |
138 | set secure
139 |
140 | " vim: set ts=2 sw=2 tw=80 noet :
141 | `
142 |
--------------------------------------------------------------------------------
/internal/plugin/database.go:
--------------------------------------------------------------------------------
1 | // Package plugin provides ...
2 | package plugin
3 |
4 | const (
5 | // DeinDatabase
6 | DeinDatabase = `
7 | [[plugins]]
8 | repo = 'tpope/vim-dadbod'
9 |
10 | [[plugins]]
11 | repo = 'kristijanhusak/vim-dadbod-ui'
12 | on_cmd = ['DBUIToggle', 'DBUIAddConnection', 'DBUI', 'DBUIFindBuffer', 'DBUIRenameBuffer']
13 | on_source = 'vim-dadbod'
14 | hook_source = '''
15 | let g:db_ui_show_help = 0
16 | let g:db_ui_win_position = 'left'
17 | let g:db_ui_use_nerd_fonts = 1
18 | let g:db_ui_winwidth = 35
19 | let g:db_ui_save_location = $DATA_PATH . '/db_ui_queries'
20 | let g:dbs = initself#load_db_from_env()
21 | '''
22 | `
23 | //PlugDatabase
24 | PlugDatabase = `
25 | Plug 'tpope/vim-dadbod'
26 | Plug 'kristijanhusak/vim-dadbod-ui',{'on':['DBUIToggle', 'DBUIAddConnection', 'DBUI', 'DBUIFindBuffer', 'DBUIRenameBuffer']}
27 | `
28 | //PlugDatabaseUiSetting
29 | PlugDatabaseUiSetting = `
30 | let g:db_ui_show_help = 0
31 | let g:db_ui_win_position = 'left'
32 | let g:db_ui_use_nerd_fonts = 1
33 | let g:db_ui_winwidth = 35
34 | let g:db_ui_save_location = $DATA_PATH . '/db_ui_queries'
35 | let g:dbs = initself#load_db_from_env()
36 | `
37 | )
38 |
--------------------------------------------------------------------------------
/internal/plugin/enhance.go:
--------------------------------------------------------------------------------
1 | // Package plugin provides ...
2 | package plugin
3 |
4 | const (
5 | // DeinDein
6 | DeinDein = `
7 | [[plugins]]
8 | repo = 'Shougo/dein.vim'
9 | `
10 | //DeinFastJK
11 | DeinFastJK = `
12 | [[plugins]]
13 | repo = 'rhysd/accelerated-jk'
14 | on_map = {n = ''}
15 | hook_add = '''
16 | nmap j (accelerated_jk_gj)
17 | nmap k (accelerated_jk_gk)
18 | '''
19 | `
20 | // DeinMundo
21 | DeinMundo = `
22 | [[plugins]]
23 | repo = 'simnalamburt/vim-mundo'
24 | on_cmd = 'MundoToggle'
25 | `
26 | // DeinEasyMotion
27 | DeinEasyMotion = `
28 | [[plugins]]
29 | repo = 'easymotion/vim-easymotion'
30 | on_map = { n = '' }
31 | hook_source = '''
32 | let g:EasyMotion_do_mapping = 0
33 | let g:EasyMotion_prompt = 'Jump to → '
34 | let g:EasyMotion_keys = 'fjdkswbeoavn'
35 | let g:EasyMotion_smartcase = 1
36 | let g:EasyMotion_use_smartsign_us = 1
37 | '''
38 | `
39 | // DeinRainbow
40 | DeinRainbow = `
41 | [[plugins]]
42 | repo = 'luochen1990/rainbow'
43 | on_ft = [
44 | 'html',
45 | 'css',
46 | 'javascript',
47 | 'javascriptreact',
48 | 'go',
49 | 'python',
50 | 'lua',
51 | 'rust',
52 | 'vim',
53 | 'less',
54 | 'stylus',
55 | 'sass',
56 | 'scss',
57 | 'json',
58 | 'ruby',
59 | 'toml',
60 | ]
61 | hook_source = '''
62 | let g:rainbow_active = 1
63 | '''
64 | `
65 | // DeinFloaterm
66 | DeinFloaterm = `
67 | repo = 'voldikss/vim-floaterm'
68 | on_cmd = ['FloatermNew', 'FloatermToggle', 'FloatermPrev', 'FloatermNext', 'FloatermSend']
69 | hook_source= '''
70 | let g:floaterm_position = 'center'
71 | let g:floaterm_wintype = 'floating'
72 |
73 | " Set floaterm window's background to black
74 | hi Floaterm guibg=black
75 | " Set floating window border line color to cyan, and background to orange
76 | hi FloatermBorder guibg=none guifg=cyan
77 | '''
78 | `
79 | // PlugFastJK
80 | PlugFastJK = `
81 | Plug 'rhysd/accelerated-jk'
82 | `
83 | // PlugMundo
84 | PlugMundo = `
85 | Plug 'simnalamburt/vim-mundo'
86 | `
87 | // PlugEasyMotion
88 | PlugEasyMotion = `
89 | Plug 'easymotion/vim-easymotion'
90 | `
91 | // PlugRainbow
92 | PlugRainbow = `
93 | Plug 'luochen1990/rainbow',{'for': ['html','css','javascript','javascriptreact','go','python','lua','rust','vim','less','sass','scss','json','ruby','toml']}
94 | `
95 |
96 | // PlugFloaterm
97 | PlugFloaterm = `
98 | Plug 'voldikss/vim-floaterm'
99 | `
100 | // PlugRainbowSetting
101 | PlugRainbowSetting = `
102 | " Rainbow
103 | let g:rainbow_active = 1
104 | `
105 | // PlugFloatermSetting
106 | PlugFloatermSetting = `
107 | "Floaterm
108 | let g:floaterm_position = 'center'
109 | let g:floaterm_wintype = 'floating'
110 |
111 | " Set floaterm window's background to black
112 | hi Floaterm guibg=black
113 | " Set floating window border line color to cyan, and background to orange
114 | hi FloatermBorder guibg=none guifg=cyan
115 | `
116 | // PlugEasyMotionSetting
117 | PlugEasyMotionSetting = `
118 | " Easymotion
119 | let g:EasyMotion_do_mapping = 0
120 | let g:EasyMotion_prompt = 'Jump to → '
121 | let g:EasyMotion_keys = 'fjdkswbeoavn'
122 | let g:EasyMotion_smartcase = 1
123 | let g:EasyMotion_use_smartsign_us = 1
124 | `
125 | // PlugFastJKSetting
126 | PlugFastJKSetting = `
127 | "accelerated-jk
128 | nmap j (accelerated_jk_gj)
129 | nmap k (accelerated_jk_gk)
130 | `
131 | )
132 |
--------------------------------------------------------------------------------
/internal/plugin/event.go:
--------------------------------------------------------------------------------
1 | // Package plugin provides ...
2 | package plugin
3 |
4 | // Event is event.vim
5 | const Event = `
6 | augroup common "{{{
7 | autocmd!
8 | " Reload vim config automatically
9 | autocmd BufWritePost $VIM_PATH/{*.vim,*.yaml,vimrc} nested
10 | \ source $MYVIMRC | redraw
11 |
12 | " Reload Vim script automatically if setlocal autoread
13 | autocmd BufWritePost,FileWritePost *.vim nested
14 | \ if &l:autoread > 0 | source |
15 | \ echo 'source ' . bufname('%') |
16 | \ endif
17 |
18 | " Update filetype on save if empty
19 | autocmd BufWritePost * nested
20 | \ if &l:filetype ==# '' || exists('b:ftdetect')
21 | \ | unlet! b:ftdetect
22 | \ | filetype detect
23 | \ | endif
24 |
25 | " Highlight current line only on focused window
26 | autocmd WinEnter,InsertLeave * if &ft !~# '^\(denite\|clap_\)' |
27 | \ set cursorline | endif
28 |
29 | autocmd WinLeave,InsertEnter * if &ft !~# '^\(denite\|clap_\)' |
30 | \ set nocursorline | endif
31 |
32 | " Automatically set read-only for files being edited elsewhere
33 | autocmd SwapExists * nested let v:swapchoice = 'o'
34 |
35 | " Equalize window dimensions when resizing vim window
36 | autocmd VimResized * tabdo wincmd =
37 |
38 | " Force write shada on leaving nvim
39 | autocmd VimLeave * if has('nvim') | wshada! | else | wviminfo! | endif
40 |
41 | " Check if file changed when its window is focus, more eager than 'autoread'
42 | autocmd FocusGained * checktime
43 |
44 | autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | execute "normal! g'\"" | endif
45 |
46 | autocmd Syntax * if line('$') > 5000 | syntax sync minlines=200 | endif
47 |
48 | " Make directory automatically.
49 | autocmd BufWritePre * call initself#mkdir_as_necessary(expand(':p:h'), v:cmdbang)
50 |
51 | autocmd BufNewFile,BufRead coc-settings.json setlocal filetype=jsonc
52 |
53 | augroup END "}}}
54 | `
55 |
--------------------------------------------------------------------------------
/internal/plugin/explorer.go:
--------------------------------------------------------------------------------
1 | // Package plugin provides ...
2 | package plugin
3 |
4 | const (
5 | // DeinDefx
6 | DeinDefx = `
7 | [[plugins]]
8 | repo = 'Shougo/defx.nvim'
9 | on_cmd = 'Defx'
10 | hook_source = '''
11 | call defx#custom#option('_', {
12 | \ 'resume': 1,
13 | \ 'winwidth': 30,
14 | \ 'split': 'vertical',
15 | \ 'direction': 'topleft',
16 | \ 'show_ignored_files': 0,
17 | \ 'columns': 'indent:git:icons:filename',
18 | \ 'root_marker': ' ',
19 | \ 'floating_preview': 1,
20 | \ 'vertical_preview': 1,
21 | \ 'preview_height': 50,
22 | \ })
23 |
24 | call defx#custom#column('git', {
25 | \ 'indicators': {
26 | \ 'Modified' : '•',
27 | \ 'Staged' : '✚',
28 | \ 'Untracked' : 'ᵁ',
29 | \ 'Renamed' : '≫',
30 | \ 'Unmerged' : '≠',
31 | \ 'Ignored' : 'ⁱ',
32 | \ 'Deleted' : '✖',
33 | \ 'Unknown' : '⁇'
34 | \ }
35 | \ })
36 |
37 | call defx#custom#column('mark', { 'readonly_icon': '', 'selected_icon': '' })
38 |
39 | " Events
40 | " ---
41 |
42 | augroup user_plugin_defx
43 | autocmd!
44 |
45 | " Define defx window mappings
46 | autocmd FileType defx call defx_mappings()
47 |
48 | " Delete defx if it's the only buffer left in the window
49 | autocmd WinEnter * if &filetype == 'defx' && winnr('$') == 1 | bdel | endif
50 |
51 | " Move focus to the next window if current buffer is defx
52 | autocmd TabLeave * if &filetype == 'defx' | wincmd w | endif
53 |
54 | augroup END
55 |
56 | " Internal functions
57 | " ---
58 | function! s:jump_dirty(dir) abort
59 | " Jump to the next position with defx-git dirty symbols
60 | let l:icons = get(g:, 'defx_git_indicators', {})
61 | let l:icons_pattern = join(values(l:icons), '\|')
62 |
63 | if ! empty(l:icons_pattern)
64 | let l:direction = a:dir > 0 ? 'w' : 'bw'
65 | return search(printf('\(%s\)', l:icons_pattern), l:direction)
66 | endif
67 | endfunction
68 |
69 | function! s:defx_toggle_tree() abort
70 | " Open current file, or toggle directory expand/collapse
71 | if defx#is_directory()
72 | return defx#do_action('open_or_close_tree')
73 | endif
74 | return defx#do_action('multi', ['drop'])
75 | endfunction
76 |
77 | function! s:defx_mappings() abort
78 | " Defx window keyboard mappings
79 | setlocal signcolumn=no expandtab
80 |
81 | nnoremap defx#do_action('drop')
82 | nnoremap l defx_toggle_tree()
83 | nnoremap h defx#async_action('cd', ['..'])
84 | nnoremap st defx#do_action('multi', [['drop', 'tabnew'], 'quit'])
85 | nnoremap s defx#do_action('open', 'botright vsplit')
86 | nnoremap i defx#do_action('open', 'botright split')
87 | nnoremap P defx#do_action('preview')
88 | nnoremap K defx#do_action('new_directory')
89 | nnoremap N defx#do_action('new_multiple_files')
90 | nnoremap dd defx#do_action('remove_trash')
91 | nnoremap r defx#do_action('rename')
92 | nnoremap x defx#do_action('execute_system')
93 | nnoremap . defx#do_action('toggle_ignored_files')
94 | nnoremap yy defx#do_action('yank_path')
95 | nnoremap ~ defx#async_action('cd')
96 | nnoremap q defx#do_action('quit')
97 | nnoremap winnr('$') != 1 ?
98 | \ ':wincmd w' :
99 | \ ':Defx -buffer-name=temp -split=vertical'
100 | " Defx's buffer management
101 | nnoremap q defx#do_action('quit')
102 | nnoremap se defx#do_action('save_session')
103 | nnoremap defx#do_action('redraw')
104 | nnoremap defx#do_action('print')
105 | " File/dir management
106 | nnoremap c defx#do_action('copy')
107 | nnoremap m defx#do_action('move')
108 | nnoremap p defx#do_action('paste')
109 | nnoremap r defx#do_action('rename')
110 | nnoremap dd defx#do_action('remove_trash')
111 | nnoremap K defx#do_action('new_directory')
112 | nnoremap N defx#do_action('new_multiple_files')
113 |
114 | " Jump
115 | nnoremap [g :call jump_dirty(-1)
116 | nnoremap ]g :call jump_dirty(1)
117 |
118 | " Change directory
119 | nnoremap \ defx#do_action('cd', getcwd())
120 | nnoremap & defx#do_action('cd', getcwd())
121 | nnoremap defx#async_action('cd', ['..'])
122 | nnoremap ~ defx#async_action('cd')
123 | nnoremap u defx#do_action('cd', ['..'])
124 | nnoremap 2u defx#do_action('cd', ['../..'])
125 | nnoremap 3u defx#do_action('cd', ['../../..'])
126 | nnoremap 4u defx#do_action('cd', ['../../../..'])
127 |
128 | " Selection
129 | nnoremap * defx#do_action('toggle_select_all')
130 | nnoremap
131 | \ defx#do_action('toggle_select') . 'j'
132 |
133 | nnoremap S defx#do_action('toggle_sort', 'Time')
134 | nnoremap C
135 | \ defx#do_action('toggle_columns', 'indent:mark:filename:type:size:time')
136 | endfunction
137 | '''
138 |
139 | [[plugins]]
140 | repo = 'kristijanhusak/defx-git'
141 | on_source = 'defx.nvim'
142 | hook_source = '''
143 | let g:defx_git#indicators = {
144 | \ 'Modified' : '•',
145 | \ 'Staged' : '✚',
146 | \ 'Untracked' : 'ᵁ',
147 | \ 'Renamed' : '≫',
148 | \ 'Unmerged' : '≠',
149 | \ 'Ignored' : 'ⁱ',
150 | \ 'Deleted' : '✖',
151 | \ 'Unknown' : '⁇'
152 | \ }
153 | '''
154 |
155 | [[plugins]]
156 | repo = 'kristijanhusak/defx-icons'
157 | on_source = 'defx.nvim'
158 | hook_add = '''
159 | let g:defx_icons_column_length = 1
160 | let g:defx_icons_mark_icon = ''
161 | '''
162 | `
163 |
164 | DeinNerdTree = `
165 | [[plugins]]
166 | repo = 'preservim/nerdtree'
167 | on_map = { n = '' }
168 | hook_source: '''
169 | let g:NERDTreeWinSize = 30
170 | let g:NERDTreeDirArrowExpandable = '▷'
171 | let g:NERDTreeDirArrowCollapsible = '▼'
172 | '''
173 |
174 | [[plugins]]
175 | repo = 'liuchengxu/nerdtree-dash'
176 | on_source = 'nerdtree'
177 | '''
178 |
179 | [[plugins]]
180 | repo = 'Xuyuanp/nerdtree-git-plugin'
181 | on_source = 'nerdtree'
182 | `
183 |
184 | PlugDefx = `
185 | Plug 'Shougo/defx.nvim'
186 | Plug 'kristijanhusak/defx-icons'
187 | Plug 'kristijanhusak/defx-git'
188 | `
189 |
190 | PlugNerdTree = `
191 | Plug 'preservim/nerdtree'
192 | Plug 'liuchengxu/nerdtree-dash'
193 | Plug 'Xuyuanp/nerdtree-git-plugin'
194 | `
195 |
196 | PlugDefxSetting = `
197 | call defx#custom#option('_', {
198 | \ 'resume': 1,
199 | \ 'winwidth': 30,
200 | \ 'split': 'vertical',
201 | \ 'direction': 'topleft',
202 | \ 'show_ignored_files': 0,
203 | \ 'columns': 'indent:git:icons:filename',
204 | \ 'root_marker': ' ',
205 | \ 'floating_preview': 1,
206 | \ 'vertical_preview': 1,
207 | \ 'preview_height': 50,
208 | \ })
209 |
210 | call defx#custom#column('git', {
211 | \ 'indicators': {
212 | \ 'Modified' : '•',
213 | \ 'Staged' : '✚',
214 | \ 'Untracked' : 'ᵁ',
215 | \ 'Renamed' : '≫',
216 | \ 'Unmerged' : '≠',
217 | \ 'Ignored' : 'ⁱ',
218 | \ 'Deleted' : '✖',
219 | \ 'Unknown' : '⁇'
220 | \ }
221 | \ })
222 |
223 | call defx#custom#column('mark', { 'readonly_icon': '', 'selected_icon': '' })
224 |
225 | " Events
226 | " ---
227 |
228 | augroup user_plugin_defx
229 | autocmd!
230 |
231 | " Define defx window mappings
232 | autocmd FileType defx call defx_mappings()
233 |
234 | " Delete defx if it's the only buffer left in the window
235 | autocmd WinEnter * if &filetype == 'defx' && winnr('$') == 1 | bdel | endif
236 |
237 | " Move focus to the next window if current buffer is defx
238 | autocmd TabLeave * if &filetype == 'defx' | wincmd w | endif
239 |
240 | augroup END
241 |
242 | " Internal functions
243 | " ---
244 | function! s:jump_dirty(dir) abort
245 | " Jump to the next position with defx-git dirty symbols
246 | let l:icons = get(g:, 'defx_git_indicators', {})
247 | let l:icons_pattern = join(values(l:icons), '\|')
248 |
249 | if ! empty(l:icons_pattern)
250 | let l:direction = a:dir > 0 ? 'w' : 'bw'
251 | return search(printf('\(%s\)', l:icons_pattern), l:direction)
252 | endif
253 | endfunction
254 |
255 | function! s:defx_toggle_tree() abort
256 | " Open current file, or toggle directory expand/collapse
257 | if defx#is_directory()
258 | return defx#do_action('open_or_close_tree')
259 | endif
260 | return defx#do_action('multi', ['drop'])
261 | endfunction
262 |
263 | function! s:defx_mappings() abort
264 | " Defx window keyboard mappings
265 | setlocal signcolumn=no expandtab
266 |
267 | nnoremap defx#do_action('drop')
268 | nnoremap l defx_toggle_tree()
269 | nnoremap h defx#async_action('cd', ['..'])
270 | nnoremap st defx#do_action('multi', [['drop', 'tabnew'], 'quit'])
271 | nnoremap s defx#do_action('open', 'botright vsplit')
272 | nnoremap i defx#do_action('open', 'botright split')
273 | nnoremap P defx#do_action('preview')
274 | nnoremap K defx#do_action('new_directory')
275 | nnoremap N defx#do_action('new_multiple_files')
276 | nnoremap dd defx#do_action('remove_trash')
277 | nnoremap r defx#do_action('rename')
278 | nnoremap x defx#do_action('execute_system')
279 | nnoremap . defx#do_action('toggle_ignored_files')
280 | nnoremap yy defx#do_action('yank_path')
281 | nnoremap ~ defx#async_action('cd')
282 | nnoremap q defx#do_action('quit')
283 | nnoremap winnr('$') != 1 ?
284 | \ ':wincmd w' :
285 | \ ':Defx -buffer-name=temp -split=vertical'
286 | " Defx's buffer management
287 | nnoremap q defx#do_action('quit')
288 | nnoremap se defx#do_action('save_session')
289 | nnoremap