Skip to content

Commit 6685852

Browse files
Merge pull request #2 from nvim-lua/master
update with parent
2 parents bb9f84c + 2ba39c6 commit 6685852

File tree

5 files changed

+111
-37
lines changed

5 files changed

+111
-37
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ External Requirements:
2828
- A [Nerd Font](https://www.nerdfonts.com/): optional, provides various icons
2929
- if you have it set `vim.g.have_nerd_font` in `init.lua` to true
3030
- Language Setup:
31-
- If want to write Typescript, you need `npm`
32-
- If want to write Golang, you will need `go`
31+
- If you want to write Typescript, you need `npm`
32+
- If you want to write Golang, you will need `go`
3333
- etc.
3434

3535
> **NOTE**
@@ -59,6 +59,10 @@ fork to your machine using one of the commands below, depending on your OS.
5959
> Your fork's url will be something like this:
6060
> `https://github.com/<your_github_username>/kickstart.nvim.git`
6161
62+
You likely want to remove `lazy-lock.json` from your fork's `.gitignore` file
63+
too - it's ignored in the kickstart repo to make maintenance easier, but it's
64+
[recommmended to track it in version control](https://lazy.folke.io/usage/lockfile).
65+
6266
#### Clone kickstart.nvim
6367
> **NOTE**
6468
> If following the recommended step above (i.e., forking the repo), replace
@@ -77,13 +81,13 @@ git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HO
7781
If you're using `cmd.exe`:
7882

7983
```
80-
git clone https://github.com/nvim-lua/kickstart.nvim.git %localappdata%\nvim\
84+
git clone https://github.com/nvim-lua/kickstart.nvim.git "%localappdata%\nvim"
8185
```
8286

8387
If you're using `powershell.exe`
8488

8589
```
86-
git clone https://github.com/nvim-lua/kickstart.nvim.git $env:LOCALAPPDATA\nvim\
90+
git clone https://github.com/nvim-lua/kickstart.nvim.git "${env:LOCALAPPDATA}\nvim"
8791
```
8892

8993
</details>
@@ -126,7 +130,7 @@ examples of adding popularly requested plugins.
126130
`~/.local/share/nvim-kickstart`. You can apply this approach to any Neovim
127131
distribution that you would like to try out.
128132
* What if I want to "uninstall" this configuration:
129-
* See [lazy.nvim uninstall](https://github.com/folke/lazy.nvim#-uninstalling) information
133+
* See [lazy.nvim uninstall](https://lazy.folke.io/usage#-uninstalling) information
130134
* Why is the kickstart `init.lua` a single file? Wouldn't it make sense to split it into multiple files?
131135
* The main purpose of kickstart is to serve as a teaching tool and a reference
132136
configuration that someone can easily use to `git clone` as a basis for their own.

init.lua

Lines changed: 83 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ vim.api.nvim_create_autocmd('TextYankPost', {
207207
-- [[ Install `lazy.nvim` plugin manager ]]
208208
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
209209
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
210-
if not vim.uv.fs_stat(lazypath) then
210+
if not (vim.uv or vim.loop).fs_stat(lazypath) then
211211
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
212212
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
213213
if vim.v.shell_error ~= 0 then
@@ -274,20 +274,55 @@ require('lazy').setup({
274274
{ -- Useful plugin to show you pending keybinds.
275275
'folke/which-key.nvim',
276276
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
277-
config = function() -- This is the function that runs, AFTER loading
278-
require('which-key').setup()
277+
opts = {
278+
icons = {
279+
-- set icon mappings to true if you have a Nerd Font
280+
mappings = vim.g.have_nerd_font,
281+
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
282+
-- default whick-key.nvim defined Nerd Font icons, otherwise define a string table
283+
keys = vim.g.have_nerd_font and {} or {
284+
Up = '<Up> ',
285+
Down = '<Down> ',
286+
Left = '<Left> ',
287+
Right = '<Right> ',
288+
C = '<C-…> ',
289+
M = '<M-…> ',
290+
D = '<D-…> ',
291+
S = '<S-…> ',
292+
CR = '<CR> ',
293+
Esc = '<Esc> ',
294+
ScrollWheelDown = '<ScrollWheelDown> ',
295+
ScrollWheelUp = '<ScrollWheelUp> ',
296+
NL = '<NL> ',
297+
BS = '<BS> ',
298+
Space = '<Space> ',
299+
Tab = '<Tab> ',
300+
F1 = '<F1>',
301+
F2 = '<F2>',
302+
F3 = '<F3>',
303+
F4 = '<F4>',
304+
F5 = '<F5>',
305+
F6 = '<F6>',
306+
F7 = '<F7>',
307+
F8 = '<F8>',
308+
F9 = '<F9>',
309+
F10 = '<F10>',
310+
F11 = '<F11>',
311+
F12 = '<F12>',
312+
},
313+
},
279314

280315
-- Document existing key chains
281-
require('which-key').add {
282-
{ '<leader>c', group = '[C]ode' },
316+
spec = {
317+
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
283318
{ '<leader>d', group = '[D]ocument' },
284319
{ '<leader>r', group = '[R]ename' },
285320
{ '<leader>s', group = '[S]earch' },
286321
{ '<leader>w', group = '[W]orkspace' },
287322
{ '<leader>t', group = '[T]oggle' },
288323
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
289-
}
290-
end,
324+
},
325+
},
291326
},
292327

293328
-- NOTE: Plugins can specify dependencies.
@@ -428,6 +463,9 @@ require('lazy').setup({
428463
-- Useful status updates for LSP.
429464
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
430465
{ 'j-hui/fidget.nvim', opts = {} },
466+
467+
-- Allows extra capabilities provided by nvim-cmp
468+
'hrsh7th/cmp-nvim-lsp',
431469
},
432470
config = function()
433471
-- Brief aside: **What is LSP?**
@@ -467,8 +505,9 @@ require('lazy').setup({
467505
--
468506
-- In this case, we create a function that lets us more easily define mappings specific
469507
-- for LSP related items. It sets the mode, buffer and description for us each time.
470-
local map = function(keys, func, desc)
471-
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
508+
local map = function(keys, func, desc, mode)
509+
mode = mode or 'n'
510+
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
472511
end
473512

474513
-- Jump to the definition of the word under your cursor.
@@ -502,7 +541,7 @@ require('lazy').setup({
502541

503542
-- Execute a code action, usually your cursor needs to be on top of an error
504543
-- or a suggestion from your LSP for this to activate.
505-
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
544+
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })
506545

507546
-- WARN: This is not Goto Definition, this is Goto Declaration.
508547
-- For example, in C this would take you to the header.
@@ -549,6 +588,15 @@ require('lazy').setup({
549588
end,
550589
})
551590

591+
-- Change diagnostic symbols in the sign column (gutter)
592+
-- if vim.g.have_nerd_font then
593+
-- local signs = { Error = '', Warn = '', Hint = '', Info = '' }
594+
-- for type, icon in pairs(signs) do
595+
-- local hl = 'DiagnosticSign' .. type
596+
-- vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
597+
-- end
598+
-- end
599+
552600
-- LSP servers and clients are able to communicate to each other what features they support.
553601
-- By default, Neovim doesn't support everything that is in the LSP specification.
554602
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
@@ -575,8 +623,8 @@ require('lazy').setup({
575623
-- Some languages (like typescript) have entire language plugins that can be useful:
576624
-- https://github.com/pmizio/typescript-tools.nvim
577625
--
578-
-- But for many setups, the LSP (`tsserver`) will work just fine
579-
-- tsserver = {},
626+
-- But for many setups, the LSP (`ts_ls`) will work just fine
627+
-- ts_ls = {},
580628
--
581629

582630
lua_ls = {
@@ -617,7 +665,7 @@ require('lazy').setup({
617665
local server = servers[server_name] or {}
618666
-- This handles overriding only values explicitly passed
619667
-- by the server configuration above. Useful when disabling
620-
-- certain features of an LSP (for example, turning off formatting for tsserver)
668+
-- certain features of an LSP (for example, turning off formatting for ts_ls)
621669
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
622670
require('lspconfig')[server_name].setup(server)
623671
end,
@@ -634,7 +682,7 @@ require('lazy').setup({
634682
{
635683
'<leader>f',
636684
function()
637-
require('conform').format { async = true, lsp_fallback = true }
685+
require('conform').format { async = true, lsp_format = 'fallback' }
638686
end,
639687
mode = '',
640688
desc = '[F]ormat buffer',
@@ -647,9 +695,15 @@ require('lazy').setup({
647695
-- have a well standardized coding style. You can add additional
648696
-- languages here or re-enable it for the disabled ones.
649697
local disable_filetypes = { c = true, cpp = true }
698+
local lsp_format_opt
699+
if disable_filetypes[vim.bo[bufnr].filetype] then
700+
lsp_format_opt = 'never'
701+
else
702+
lsp_format_opt = 'fallback'
703+
end
650704
return {
651705
timeout_ms = 500,
652-
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
706+
lsp_format = lsp_format_opt,
653707
}
654708
end,
655709
formatters_by_ft = {
@@ -840,6 +894,8 @@ require('lazy').setup({
840894
{ -- Highlight, edit, and navigate code
841895
'nvim-treesitter/nvim-treesitter',
842896
build = ':TSUpdate',
897+
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
898+
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
843899
opts = {
844900
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
845901
-- Autoinstall languages that are not installed
@@ -853,22 +909,15 @@ require('lazy').setup({
853909
},
854910
indent = { enable = true, disable = { 'ruby' } },
855911
},
856-
config = function(_, opts)
857-
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
858-
859-
---@diagnostic disable-next-line: missing-fields
860-
require('nvim-treesitter.configs').setup(opts)
861-
862-
-- There are additional nvim-treesitter modules that you can use to interact
863-
-- with nvim-treesitter. You should go explore a few and see what interests you:
864-
--
865-
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
866-
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
867-
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
868-
end,
912+
-- There are additional nvim-treesitter modules that you can use to interact
913+
-- with nvim-treesitter. You should go explore a few and see what interests you:
914+
--
915+
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
916+
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
917+
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
869918
},
870919

871-
-- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the
920+
-- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
872921
-- init.lua. If you want these files, they are in the repository, so you can just download them and
873922
-- place them in the correct locations.
874923

@@ -888,8 +937,12 @@ require('lazy').setup({
888937
-- This is the easiest way to modularize your config.
889938
--
890939
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
891-
-- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
892940
-- { import = 'custom.plugins' },
941+
--
942+
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
943+
-- Or use telescope!
944+
-- In normal mode type `<space>sh` then write `lazy.nvim-plugin`
945+
-- you can continue same window with `<space>sr` which resumes last telescope search
893946
}, {
894947
ui = {
895948
-- If you are using a Nerd Font: set icons to an empty table which will use the

lua/kickstart/plugins/debug.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ return {
8989
},
9090
}
9191

92+
-- Change breakpoint icons
93+
-- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' })
94+
-- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' })
95+
-- local breakpoint_icons = vim.g.have_nerd_font
96+
-- and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' }
97+
-- or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' }
98+
-- for type, icon in pairs(breakpoint_icons) do
99+
-- local tp = 'Dap' .. type
100+
-- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak'
101+
-- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl })
102+
-- end
103+
92104
dap.listeners.after.event_initialized['dapui_config'] = dapui.open
93105
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
94106
dap.listeners.before.event_exited['dapui_config'] = dapui.close

lua/kickstart/plugins/lint.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ return {
4747
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
4848
group = lint_augroup,
4949
callback = function()
50-
lint.try_lint()
50+
-- Only run the linter in buffers that you can modify in order to
51+
-- avoid superfluous noise, notably within the handy LSP pop-ups that
52+
-- describe the hovered symbol using Markdown.
53+
if vim.opt_local.modifiable:get() then
54+
lint.try_lint()
55+
end
5156
end,
5257
})
5358
end,

lua/kickstart/plugins/neo-tree.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ return {
1111
},
1212
cmd = 'Neotree',
1313
keys = {
14-
{ '\\', ':Neotree reveal<CR>', desc = 'NeoTree reveal' },
14+
{ '\\', ':Neotree reveal<CR>', desc = 'NeoTree reveal', silent = true },
1515
},
1616
opts = {
1717
filesystem = {

0 commit comments

Comments
 (0)