diff --git a/init.lua b/init.lua index 961ea8fc..65041de4 100644 --- a/init.lua +++ b/init.lua @@ -663,12 +663,24 @@ require('lazy').setup({ -- -- You can use a sub-list to tell conform to run *until* a formatter -- is found. - javascript = { { 'prettierd', 'prettier' } }, - typescript = { { 'prettierd', 'prettier' } }, - ruby = { { 'rubocop' } }, - go = { { 'gofmt' } }, + -- javascript = { { 'prettierd', 'prettier' } } + javascript = { 'prettierd' }, + typescript = { 'prettierd' }, + ruby = { 'rubocop' }, + go = { 'gofmt' }, }, formatters = {}, + vim.api.nvim_create_user_command('Format', function(args) + local range = nil + if args.count ~= -1 then + local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1] + range = { + start = { args.line1, 0 }, + ['end'] = { args.line2, end_line:len() }, + } + end + require('conform').format { async = true, lsp_fallback = true, range = range } + end, { range = true }), }, }, @@ -692,12 +704,12 @@ require('lazy').setup({ -- `friendly-snippets` contains a variety of premade snippets. -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, }, }, 'saadparwaiz1/cmp_luasnip', @@ -791,7 +803,7 @@ require('lazy').setup({ -- Load the colorscheme here. -- Like many other themes, this one has different styles, and you could load -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'catppuccin-macchiato' + vim.cmd.colorscheme 'catppuccin' -- You can configure highlights by doing something like: vim.cmd.hi 'Comment gui=none'