aboutsummaryrefslogtreecommitdiff
path: root/readme.md
blob: a585cda7d04d29e1643e7beb47da8e4010496aff (plain)
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<div align="center">
<img src="https://user-images.githubusercontent.com/81827001/140657509-1199b444-687f-4f6b-b10a-2eeca35040aa.png" width=315>

# 🔧startup.nvim

The fully customizable greeter for neovim

</div>

 I don't have time to maintain this atm.
 If someone wants to do so feel free to do.
 I'll accept new PRs.

✨Features
--------

* Fully customizable
* Themes
* Easier customization with building blocks

📦Installation
------------

Use your favourite package manager and call setup function.
Plenary.nvim is a dependency and must be installed.
For the default setup telescope.nvim is needed.

```lua
use {
  "startup-nvim/startup.nvim",
  requires = {"nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim"},
  config = function()
    require"startup".setup()
  end
}
```

⚙️Customization
-------------

Call the setup function with your configurations.

```lua
require"startup".setup({
  section_1 = <section> -- for the structure of a section see below
  section_2 = <section> -- as much sections as you like
  options = {
      mapping_keys = true, -- display mapping (e.g. <leader>ff)

      -- if < 0 fraction of screen width
      -- if > 0 numbers of column
      cursor_column = 0.5

      after = function() -- function that gets executed at the end
        <lua commands>
      end
      empty_lines_between_mappings = true, -- add an empty line between mapping/commands
      disable_statuslines = true -- disable status-, buffer- and tablines
      paddings = {1,2}, -- amount of empty lines before each section (must be equal to amount of sections)
  }
  mappings = {
    execute_command = "<CR>",
    open_file = "o",
    open_file_split = "<c-o>",
    open_section = "<TAB>",
    open_help = "?",
  },
  colors = {
    background = "#1f2227",
    folded_section = "#56b6c2", -- the color of folded sections
      -- this can also be changed with the `StartupFoldedSection` highlight group
  }
  parts = {"section_1", "section_2"} -- all sections in order
})
```

You could also put the configurations into a file.
For example `/lua/config/startup_nvim.lua`.
The file should then look like this:
```lua
local settings = {<settings>}
return settings
```
The plugin setup should then require the file:
```lua
use {
  "startup-nvim/startup.nvim",
  requires = {"nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim"},
  config = function()
    require"startup".setup(require"configs.startup_nvim")
  end
}
```


The filetype of the startup screen is `startup`.
You can use this to disable plugins like statuslines.

### The Structure of a section

```lua
section = {
    -- "text" -> text that will be displayed
    -- "mapping" -> create mappings for commands that can be used
    -- use mappings.execute_command on the commands to execute
    -- "oldfiles" -> display oldfiles (can be opened with mappings.open_file/open_file_split)
    type = "text", -- can be mappings or oldfiles
    oldfiles_directory = false, -- if the oldfiles of the current directory should be displayed
    align = "center", -- "center", "left" or "right"
    fold_section = false, -- whether to fold or not
    title = "title", title for the folded section
    -- if < 0 fraction of screen width
    -- if > 0 numbers of column
    margin = 5, the margin for left or right alignment
    -- type of content depends on `type`
    -- "text" -> a table with string or a function that requires a function that returns a table of strings
    -- "mapping" -> a table with tables in the format:
    -- {
    --   {<displayed_command_name>, <command>, <mapping>}
    --   {<displayed_command_name>, <command>, <mapping>}
    -- }
    -- e.g. {" Find File", "Telescope find_files", "<leader>ff" }
    -- "oldfiles" -> ""
    content = <content>
    highlight = "String", -- highlight group in which the section text should be highlighted
    default_color = "#FF0000", -- a hex color that gets used if you don't specify `highlight`
    oldfiles_amount = 5, -- the amount of oldfiles to be displayed
}
```

### User Mappings
You can easily add your own mappings with a function.
You just have to provide a table with keys, command pairs like this:
```lua
require"startup".create_mappings({
  ["<leader>ff"]="<cmd>Telescope find_files<CR>",
  ["<leader>lg"]="<cmd>Telescope live_grep<CR>"
})
```
Those mappings will automatically be added to the help.

### Buildingblocks

You can use some functions from `lua/startup/functions.lua`.
For that you would use:
```lua
type = "text",
content = function()
    require("startup.functions").function_name()
  end,
```

The functions are documented in `:help startup_nvim.functions`.

### Examples
<details>
<summary>
Content for type = "text", table
</summary>
<p>

```lua
content = {
    "This is:",
    "Startup.nvim",
    "by max397574"
}
```

</p>
</details>
<details>
<summary>
Content for type = "text", function
</summary>
<p>

```lua
content = function()
    local clock = " " .. os.date "%H:%M"
    local date = " " .. os.date "%d-%m-%y"
    return {clock,date}
end
```

With a separate function:

```lua
local function time()
    local clock = " " .. os.date "%H:%M"
    local date = " " .. os.date "%d-%m-%y"
    return {clock,date}
end

settings = {
    ...
    content = time()
    ...
}
```

</p>
</details>

<details>
<summary>
Content for type = "mapping"
</summary>
<p>

```lua
content = {
  [" Find File"] = { "Telescope find_files", "<leader>ff" },
  [" Find Word"] = { "Telescope live_grep", "<leader>lg" },
  [" Recent Files"] = { "Telescope oldfiles", "<leader>of" },
  [" File Browser"] = { "Telescope file_browser", "<leader>fb" },
  [" Colorschemes"] = { "Telescope colorscheme", "<leader>cs" },
  [" New File"] = { "lua require'startup'.new_file()", "<leader>nf" },
},
```

</p>
</details>

Check out the [themes](https://github.com/startup-nvim/startup.nvim/tree/master/lua/startup/themes) for full examples.


🎨Themes
----------

At the moment there are three themes:
- dashboard (default)
- evil
- startify

You can use themes like this:

```lua
require("startup").setup({theme = "dashboard"}) -- put theme name here
```

### Dashboard

The dashboard theme is a simple theme with some commands and a header.
  
![dashboard theme](https://user-images.githubusercontent.com/81827001/146725450-5c3ddc5b-e4aa-47b9-88b1-446810bebcea.png)

### Startify

The startify theme is a theme like `vim-startify`.
It has oldfiles, bookmarks and a random quote.
You can open the oldfiles with the number written before it (`[2] ~/.config/nvim/init.lua` can be opened by pressing `2`).
You can open a bookmark with the key written in front of it.

Customize bookmarks with `vim.g.startup_booksmarks`:
```lua
vim.g.startup_bookmarks = {
  ["Q"] = '~/.config/qtile/config.py',
  ["I"] = '~/.config/nvim/init.lua',
  ["F"] = '~/.config/fish/config.fish',
  ["K"] = '~/.config/kitty/kitty.conf',
  ["A"] = '~/.config/alacritty/alacritty.yml',
}
```
![startify](https://user-images.githubusercontent.com/81827001/146543552-1224495e-329f-49f1-bcbf-7414f929f9e0.jpg)


### Evil

The evil theme is just a bloated theme with oldfiles, commands, additional info and a quote.
  
![evil theme](https://user-images.githubusercontent.com/81827001/145632108-04c5d972-0d51-42fc-ad92-91ea716b92a7.png)

### Custom theme

You can put your theme in `lua/startup/themes/my_theme.lua`
The file has to return settings with the structure like you put them into `setup()`.
You can also overwrite a theme (e.g. `dashboard`).
Just copy all the setting from it and change whatever you want.
You can use some functions from `lua/startup/functions.lua` with `require("startup.functions").function_name()`.
They are documented in `:help startup_nvim.functions`.
The same applies to headers.
Here you can use them with `require("startup.headers").header_name`.
They are documented in `:help startup_nvim.headers`.
A good tool to create your own headers is [image to braille](https://505e06b2.github.io/Image-to-Braille/).

Conflicts with other plugins like auto-session
----------------------------------------------
If this plugin conflict with other plugins you can disable it on startup.
For this you need to set `vim.g.startup_disable_on_startup` to `true`.
You can do that like this:
```lua
config = function()
    vim.g.startup_disable_on_startup = true
    require("startup").setup(require("configs.startup_nvim"))
end
```

You can still display it later then with `:Startup display`.
  
👀 Screenshots
--------------
  
### Easily open Files (in splits)
  
![file_split](https://user-images.githubusercontent.com/81827001/146543610-cf700baa-0e72-4c13-9be8-02d8e7f12c14.jpg)

  
### Builtin Key Help (user mappings included)

  ![key help](https://user-images.githubusercontent.com/81827001/145632803-71bf8e78-43d7-4230-b46e-9fd6ae621d3a.png)
  
### Folds and commands with mappings
 
![folds mappings](https://user-images.githubusercontent.com/81827001/145632434-9cdba6e6-c381-43a6-8a60-3af201fda1da.png)

Credits
-------

- Thanks to Binx, for making that logo for free!
  - [Github](https://github.com/Binx-Codes/)
  - [Reddit](https://www.reddit.com/u/binxatmachine)


Similar plugins:
* [dashboard-nvim](https://github.com/glepnir/dashboard-nvim)
* [alpha-nvim](https://github.com/goolord/alpha-nvim)
* [vim-startify](https://github.com/mhinz/vim-startify)