-
Notifications
You must be signed in to change notification settings - Fork 0
/
scala-utils.txt
160 lines (128 loc) · 7.17 KB
/
scala-utils.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
*scala-utils.txt* scala-utils.nvim
A nvim plugin offering some utilities to work with Scala and integration with
modern Scala tooling.
As a wise man once said: >
not a ton here, but useful for me
- Derek Wyatt
<
Much of this is just things I wish I had while developing Scala in NeoVim.
Some of it may be useless to the average person, but hopefully some of this
will also be useful to you.
SCALA-UTILS REFERENCE MANUAL
CONTENTS *scala-utils*
1. Setup................. |scala-utils-setup|
2. Configuration......... |scala-utils-configuration|
3. Lua APIS...............|scala-utils-lua-apis|
================================================================================
SETUP *scala-utils-setup*
As an example using Packer, you can install scala-utils like so: >
use {
"ckipp01/scala-utils.nvim",
requires = { "nvim-lua/plenary.nvim" }
}
<
NOTE: that `nvim-lua/plenary.nvim` is required. More than likely you'll
already have this installed for usage in another plugin, but if not this
offers some useful utils written much nicer than I'd have written them.
================================================================================
CONFIGURATION *scala-utils-configuration*
To get started with scala-utils you don't actually need to do anythign but
install it. However, if you'd like to change some of the defaults, you can
pass in a configuration table to a setup function. You'll find all of the
configuration options and their defaults below. >
require("scala-utils").setup({
-- used for all prompts in scala-utils
prompt = "❯",
coursier = {
-- mapping to continue the completion process
continue_completion_mapping = "<CR>",
-- mapping to copy the full output to your clipboad in mill format
-- NOTE: This is only available at the last completion step where the
-- version is being shown
copy_to_mill_mapping = "m",
-- mapping to copy the full output to your clipboad in sbt format
-- NOTE: This is only available at the last completion step where the
-- version is being shown
copy_to_sbt_mapping = "s",
-- mapping to copy the full output to your clipboad in metals worksheet
-- format
-- NOTE: This is only available at the last completion step where the
-- version is being shown
copy_to_worksheet_mapping = "w",
-- mapping to copy only the version to your clipboad
-- NOTE: This is only available at the last completion step where the
-- version is being shown
copy_version_mapping = "v",
},
})
<
================================================================================
LUA APIS *scala-utils-lua-apis*
The aim for scala-utils is to provide different module APIs to interact with
different tools in the ecosystem. The only currently available API is a
minimal coursier API. We'll use that to show some example mappings: >
local api = vim.api
local opts = { noremap = true, silent = true }
api.nvim_set_keymap("n", "<leader>slc", [[require("scala-utils.coursier").complete_from_line()<CR>]], opts)
api.nvim_set_keymap("n", "<leader>sc", [[require("scala-utils.coursier").complete_from_input()<CR>]], opts)
<
The current apis are:
- scala-utils
- Coursier
NOTE: These for sure are not stable for the time being.
*setup()*
setup({config}) Called to pass in a configuration table to
change the default behavior of various modules and
settings.
Parameters:
{config} (table) Configuration table. The full
table can be seen in
|scala-utils-configuration|.
================================================================================
COURSIER API *scala-utils-coursier-api*
*complete()*
complete({to_complete}) Completes a given string. Must be in a valid
format that `cs complete` can understand.
Parameters:
{to_complete} (string) The string to be
completed.
*complete_from_input()*
complete_from_input() Opens up a prompt for input from the user. This
will then function in the same manner that using
`cs complete` from the command line will. So the
expected input should be in one of the following
formats: >
org.scalame
org.scalameta:metal
org.scalameta:metals_2.12:0.
<
All of those would be valid formats to pass into
|complete()|. When it reaches the last step of
completion `<CR>` will copy the version out.
*complete_from_line()*
complete_from_line() Provides the exact functionality as |complete()|
however it will pull the org and artifact from the
current line and start the completion from there.
This will work in sbt build files, Mill build
files, Ammonite scripts, and Metals worksheets.
*copy_to()*
copy_to({format}) If your completion is already in the VERSION stage
this will select the version you're on and create
a dependency string in a specified format that
will be copied to your buffer. NOTE: there are
default mappings for these already, so it's
uncommon that you'll ever actually manually use
this.
Parameters:
{format} (string) The specified format. This is
currently an enum of the following values:
sbt: "org" %% "artifact" % "version"
mill: ivy"org::artifact:version"
worksheet: $dep.`org::artifact:version`
*copy_version()*
copy_version() If your completion is already in the VERSION stage
this will select the version you're on and copy it
buffer. NOTE: there is a default mapping for this
already, so it's uncommon that you'll ever
actually manually use this.
vim:tw=80:ts=2:ft=help: