Skip to content

Commit 0c065b0

Browse files
committed
Sync with master
1 parent 1860184 commit 0c065b0

File tree

1 file changed

+65
-28
lines changed

1 file changed

+65
-28
lines changed

init.lua

Lines changed: 65 additions & 28 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.
@@ -470,8 +505,9 @@ require('lazy').setup({
470505
--
471506
-- In this case, we create a function that lets us more easily define mappings specific
472507
-- for LSP related items. It sets the mode, buffer and description for us each time.
473-
local map = function(keys, func, desc)
474-
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 })
475511
end
476512

477513
-- Jump to the definition of the word under your cursor.
@@ -505,7 +541,7 @@ require('lazy').setup({
505541

506542
-- Execute a code action, usually your cursor needs to be on top of an error
507543
-- or a suggestion from your LSP for this to activate.
508-
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' })
509545

510546
-- WARN: This is not Goto Definition, this is Goto Declaration.
511547
-- For example, in C this would take you to the header.
@@ -578,8 +614,8 @@ require('lazy').setup({
578614
-- Some languages (like typescript) have entire language plugins that can be useful:
579615
-- https://github.com/pmizio/typescript-tools.nvim
580616
--
581-
-- But for many setups, the LSP (`tsserver`) will work just fine
582-
-- tsserver = {},
617+
-- But for many setups, the LSP (`ts_ls`) will work just fine
618+
-- ts_ls = {},
583619
--
584620

585621
lua_ls = {
@@ -620,7 +656,7 @@ require('lazy').setup({
620656
local server = servers[server_name] or {}
621657
-- This handles overriding only values explicitly passed
622658
-- by the server configuration above. Useful when disabling
623-
-- certain features of an LSP (for example, turning off formatting for tsserver)
659+
-- certain features of an LSP (for example, turning off formatting for ts_ls)
624660
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
625661
require('lspconfig')[server_name].setup(server)
626662
end,
@@ -637,7 +673,7 @@ require('lazy').setup({
637673
{
638674
'<leader>f',
639675
function()
640-
require('conform').format { async = true, lsp_fallback = true }
676+
require('conform').format { async = true, lsp_format = 'fallback' }
641677
end,
642678
mode = '',
643679
desc = '[F]ormat buffer',
@@ -650,9 +686,15 @@ require('lazy').setup({
650686
-- have a well standardized coding style. You can add additional
651687
-- languages here or re-enable it for the disabled ones.
652688
local disable_filetypes = { c = true, cpp = true }
689+
local lsp_format_opt
690+
if disable_filetypes[vim.bo[bufnr].filetype] then
691+
lsp_format_opt = 'never'
692+
else
693+
lsp_format_opt = 'fallback'
694+
end
653695
return {
654696
timeout_ms = 500,
655-
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
697+
lsp_format = lsp_format_opt,
656698
}
657699
end,
658700
formatters_by_ft = {
@@ -843,6 +885,8 @@ require('lazy').setup({
843885
{ -- Highlight, edit, and navigate code
844886
'nvim-treesitter/nvim-treesitter',
845887
build = ':TSUpdate',
888+
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
889+
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
846890
opts = {
847891
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
848892
-- Autoinstall languages that are not installed
@@ -856,19 +900,12 @@ require('lazy').setup({
856900
},
857901
indent = { enable = true, disable = { 'ruby' } },
858902
},
859-
config = function(_, opts)
860-
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
861-
862-
---@diagnostic disable-next-line: missing-fields
863-
require('nvim-treesitter.configs').setup(opts)
864-
865-
-- There are additional nvim-treesitter modules that you can use to interact
866-
-- with nvim-treesitter. You should go explore a few and see what interests you:
867-
--
868-
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
869-
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
870-
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
871-
end,
903+
-- There are additional nvim-treesitter modules that you can use to interact
904+
-- with nvim-treesitter. You should go explore a few and see what interests you:
905+
--
906+
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
907+
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
908+
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
872909
},
873910

874911
-- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the

0 commit comments

Comments
 (0)