Skip to content

Commit 6697b6c

Browse files
updated
1 parent d14a02d commit 6697b6c

File tree

1 file changed

+86
-193
lines changed

1 file changed

+86
-193
lines changed

init.lua

Lines changed: 86 additions & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -277,48 +277,51 @@ require('lazy').setup({
277277
-- after the plugin has been loaded:
278278
-- config = function() ... end
279279

280-
{ -- Useful plugin to show you pending keybinds.
281-
'folke/which-key.nvim',
282-
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
283-
opts = {
284-
icons = {
285-
-- set icon mappings to true if you have a Nerd Font
286-
mappings = vim.g.have_nerd_font,
287-
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
288-
-- default which-key.nvim defined Nerd Font icons, otherwise define a string table
289-
keys = vim.g.have_nerd_font and {} or {
290-
Up = '<Up> ',
291-
Down = '<Down> ',
292-
Left = '<Left> ',
293-
Right = '<Right> ',
294-
C = '<C-…> ',
295-
M = '<M-…> ',
296-
D = '<D-…> ',
297-
S = '<S-…> ',
298-
CR = '<CR> ',
299-
Esc = '<Esc> ',
300-
ScrollWheelDown = '<ScrollWheelDown> ',
301-
ScrollWheelUp = '<ScrollWheelUp> ',
302-
NL = '<NL> ',
303-
BS = '<BS> ',
304-
Space = '<Space> ',
305-
Tab = '<Tab> ',
306-
F1 = '<F1>',
307-
F2 = '<F2>',
308-
F3 = '<F3>',
309-
F4 = '<F4>',
310-
F5 = '<F5>',
311-
F6 = '<F6>',
312-
F7 = '<F7>',
313-
F8 = '<F8>',
314-
F9 = '<F9>',
315-
F10 = '<F10>',
316-
F11 = '<F11>',
317-
F12 = '<F12>',
318-
},
280+
281+
282+
{
283+
-- Useful plugin to show you pending keybinds.
284+
'folke/which-key.nvim',
285+
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
286+
opts = {
287+
icons = {
288+
-- set icon mappings to true if you have a Nerd Font
289+
mappings = vim.g.have_nerd_font,
290+
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
291+
-- default which-key.nvim defined Nerd Font icons, otherwise define a string table
292+
keys = vim.g.have_nerd_font and {} or {
293+
Up = '<Up> ',
294+
Down = '<Down> ',
295+
Left = '<Left> ',
296+
Right = '<Right> ',
297+
C = '<C-…> ',
298+
M = '<M-…> ',
299+
D = '<D-…> ',
300+
S = '<S-…> ',
301+
CR = '<CR> ',
302+
Esc = '<Esc> ',
303+
ScrollWheelDown = '<ScrollWheelDown> ',
304+
ScrollWheelUp = '<ScrollWheelUp> ',
305+
NL = '<NL> ',
306+
BS = '<BS> ',
307+
Space = '<Space> ',
308+
Tab = '<Tab> ',
309+
F1 = '<F1>',
310+
F2 = '<F2>',
311+
F3 = '<F3>',
312+
F4 = '<F4>',
313+
F5 = '<F5>',
314+
F6 = '<F6>',
315+
F7 = '<F7>',
316+
F8 = '<F8>',
317+
F9 = '<F9>',
318+
F10 = '<F10>',
319+
F11 = '<F11>',
320+
F12 = '<F12>',
319321
},
320-
321-
-- Document existing key chains
322+
},
323+
-- Document existing key chains
324+
register = function()
322325
require('which-key').register {
323326
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
324327
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
@@ -328,6 +331,7 @@ require('lazy').setup({
328331
}
329332
end,
330333
},
334+
},
331335

332336
-- NOTE: Plugins can specify dependencies.
333337
--
@@ -457,6 +461,7 @@ require('lazy').setup({
457461

458462
-- Allows extra capabilities provided by nvim-cmp
459463
'hrsh7th/cmp-nvim-lsp',
464+
'hrsh7th/nvim-cmp',
460465
},
461466
config = function()
462467
-- Brief aside: **What is LSP?**
@@ -609,7 +614,6 @@ require('lazy').setup({
609614
--
610615
--
611616
local servers = {
612-
-- clangd = {},
613617
-- gopls = {},
614618
-- pyright = {},
615619
-- rust_analyzer = {},
@@ -659,8 +663,6 @@ require('lazy').setup({
659663
--
660664
}
661665

662-
require("neodev").setup({})
663-
664666
-- Ensure the servers and tools above are installed
665667
-- To check the current status of installed tools and/or manually install
666668
-- other tools, you can run
@@ -758,163 +760,54 @@ require('lazy').setup({
758760
},
759761
},
760762
},
761-
{ -- Autoformat
762-
'stevearc/conform.nvim',
763-
event = { 'BufWritePre' },
764-
cmd = { 'ConformInfo' },
765-
keys = {
766-
{
767-
'<leader>f',
768-
function()
769-
require('conform').format { async = true, lsp_format = 'fallback' }
770-
end,
771-
mode = '',
772-
desc = '[F]ormat buffer',
773-
},
774-
},
775-
opts = {
776-
notify_on_error = false,
777-
format_on_save = function(bufnr)
778-
-- Disable "format_on_save lsp_fallback" for languages that don't
779-
-- have a well standardized coding style. You can add additional
780-
-- languages here or re-enable it for the disabled ones.
781-
local disable_filetypes = { c = true, cpp = true }
782-
783-
if vim.g.disable_auto_format or disable_filetypes[vim.bo[bufnr].filetype] then
784-
return false
785-
end
786-
787-
return {
788-
timeout_ms = 500,
789-
lsp_fallback = true,
790-
local lsp_format_opt
791-
if disable_filetypes[vim.bo[bufnr].filetype] then
792-
lsp_format_opt = 'never'
793-
else
794-
lsp_format_opt = 'fallback'
795-
end
796-
return {
797-
timeout_ms = 500,
798-
lsp_format = lsp_format_opt,
799-
}
763+
{
764+
-- Autoformat
765+
'stevearc/conform.nvim',
766+
event = { 'BufWritePre' },
767+
cmd = { 'ConformInfo' },
768+
keys = {
769+
{
770+
'<leader>f',
771+
function()
772+
require('conform').format { async = true, lsp_format = 'fallback' }
800773
end,
801-
formatters_by_ft = {
802-
lua = { 'stylua' },
803-
-- Conform can also run multiple formatters sequentially
804-
-- pyt,on = { "isort", "black" },
805-
--
806-
-- You can use 'stop_after_first' to run the first available formatter from the list
807-
-- javascript = { "prettierd", "prettier", stop_after_first = true },
808-
},
774+
mode = '',
775+
desc = '[F]ormat buffer',
809776
},
810777
},
778+
opts = {
779+
notify_on_error = false,
780+
format_on_save = function(bufnr)
781+
-- Disable "format_on_save lsp_fallback" for languages that don't
782+
-- have a well-standardized coding style. Add more languages here if needed.
783+
local disable_filetypes = { c = true, cpp = true }
784+
785+
if vim.g.disable_auto_format or disable_filetypes[vim.bo[bufnr].filetype] then
786+
return false
787+
end
811788

812-
{ -- Autocompletion
813-
'hrsh7th/nvim-cmp',
814-
event = 'InsertEnter',
815-
dependencies = {
816-
-- Snippet Engine & its associated nvim-cmp source
817-
{
818-
'L3MON4D3/LuaSnip',
819-
build = (function()
820-
-- Build Step is needed for regex support in snippets.
821-
-- This step is not supported in many windows environments.
822-
-- Remove the below condition to re-enable on windows.
823-
return 'make install_jsregexp'
824-
end)(),
825-
dependencies = {
826-
-- `friendly-snippets` contains a variety of premade snippets.
827-
-- See the README about individual language/framework/plugin snippets:
828-
-- https://github.com/rafamadriz/friendly-snippets
829-
-- {
830-
-- 'rafamadriz/friendly-snippets',
831-
-- config = function()
832-
-- require('luasnip.loaders.from_vscode').lazy_load()
833-
-- end,
834-
-- },
835-
},
836-
},
837-
'saadparwaiz1/cmp_luasnip',
838-
839-
-- Adds other completion capabilities.
840-
-- nvim-cmp does not ship with all sources by default. They are split
841-
-- into multiple repos for maintenance purposes.
842-
'hrsh7th/cmp-nvim-lsp',
843-
'hrsh7th/cmp-path',
844-
},
845-
config = function()
846-
-- See `:help cmp`
847-
local cmp = require 'cmp'
848-
local luasnip = require 'luasnip'
849-
luasnip.config.setup {}
850-
851-
cmp.setup {
852-
snippet = {
853-
expand = function(args)
854-
luasnip.lsp_expand(args.body)
855-
end,
856-
},
857-
completion = { completeopt = 'menu,menuone,noinsert' },
789+
-- Determine lsp_format option based on filetype
790+
local lsp_format_opt
791+
if disable_filetypes[vim.bo[bufnr].filetype] then
792+
lsp_format_opt = 'never'
793+
else
794+
lsp_format_opt = 'fallback'
795+
end
858796

859-
-- For an understanding of why these mappings were
860-
-- chosen, you will need to read `:help ins-completion`
861-
--
862-
-- No, but seriously. Please read `:help ins-completion`, it is really good!
863-
mapping = cmp.mapping.preset.insert {
864-
-- Select the [n]ext item
865-
['<C-n>'] = cmp.mapping.select_next_item(),
866-
-- Select the [p]revious item
867-
['<C-p>'] = cmp.mapping.select_prev_item(),
868-
869-
-- Scroll the documentation window [b]ack / [f]orward
870-
['<C-b>'] = cmp.mapping.scroll_docs(-4),
871-
['<C-f>'] = cmp.mapping.scroll_docs(4),
872-
873-
-- Accept ([y]es) the completion.
874-
-- This will auto-import if your LSP supports it.
875-
-- This will expand snippets if the LSP sent a snippet.
876-
['<CR>'] = cmp.mapping.confirm { select = true },
877-
878-
-- Manually trigger a completion from nvim-cmp.
879-
-- Generally you don't need this, because nvim-cmp will display
880-
-- completions whenever it has completion options available.
881-
['<C-Space>'] = cmp.mapping.complete {},
882-
883-
-- Think of <c-l> as moving to the right of your snippet expansion.
884-
-- So if you have a snippet that's like:
885-
-- function $name($args)
886-
-- $body
887-
-- end
888-
--
889-
-- <c-l> will move you to the right of each of the expansion locations.
890-
-- <c-h> is similar, except moving you backwards.
891-
['<C-l>'] = cmp.mapping(function()
892-
if luasnip.expand_or_locally_jumpable() then
893-
luasnip.expand_or_jump()
894-
end
895-
end, { 'i', 's' }),
896-
['<C-h>'] = cmp.mapping(function()
897-
if luasnip.locally_jumpable(-1) then
898-
luasnip.jump(-1)
899-
end
900-
end, { 'i', 's' }),
901-
902-
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
903-
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
904-
},
905-
sources = {
906-
{
907-
name = 'lazydev',
908-
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
909-
group_index = 0,
910-
},
911-
{ name = 'nvim_lsp' },
912-
{ name = 'luasnip' },
913-
{ name = 'path' },
914-
},
797+
return {
798+
timeout_ms = 500,
799+
lsp_format = lsp_format_opt,
915800
}
916801
end,
802+
formatters_by_ft = {
803+
lua = { 'stylua' },
804+
-- Conform can also run multiple formatters sequentially
805+
-- python = { "isort", "black" },
806+
-- You can use 'stop_after_first' to run the first available formatter from the list
807+
-- javascript = { "prettierd", "prettier", stop_after_first = true },
808+
},
917809
},
810+
},
918811

919812
{ -- You can easily change to a different colorscheme.
920813
-- Change the name of the colorscheme plugin below, and then

0 commit comments

Comments
 (0)