Skip to content

Commit af21c78

Browse files
authored
Add files via upload
1 parent b98a370 commit af21c78

File tree

4 files changed

+36
-26
lines changed

4 files changed

+36
-26
lines changed

init.lua

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -477,23 +477,14 @@ require('lazy').setup({
477477
local servers = {
478478
clangd = {},
479479
-- gopls = {},
480-
ruff = {
481-
trace = 'messages',
482-
on_attach = on_attach,
483-
init_options = {
484-
settings = {
485-
logLevel = 'info',
486-
},
487-
},
488-
},
489480
-- rust_analyzer = {},
490481
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
491482
--
492483
-- Some languages (like typescript) have entire language plugins that can be useful:
493484
-- https://github.com/pmizio/typescript-tools.nvim
494485
--
495486
-- But for many setups, the LSP (`tsserver`) will work just fine
496-
tsserver = {
487+
ts_ls = {
497488
init_options = {
498489
plugins = {
499490
{
@@ -511,8 +502,15 @@ require('lazy').setup({
511502
},
512503
},
513504
},
514-
--
515-
pylsp = {},
505+
pylsp = {
506+
plugins = {
507+
ruff = {
508+
enabled = true,
509+
formatEnabled = true,
510+
},
511+
autopep8 = { enabled = false },
512+
},
513+
},
516514
cmake = {},
517515
lua_ls = {
518516
-- cmd = {...},
@@ -567,39 +565,38 @@ require('lazy').setup({
567565
cmd = { 'ConformInfo' },
568566
keys = {
569567
{
570-
'<leader>f',
568+
'<leader>ff',
571569
function()
572570
require('conform').format { async = true, lsp_format = 'fallback' }
573571
end,
574572
mode = '',
575-
desc = '[F]ormat buffer',
573+
desc = '[F]ormat [F]ile buffer',
576574
},
577575
},
578576
opts = {
579-
notify_on_error = false,
577+
notify_on_error = true,
580578
format_on_save = function(bufnr)
581579
-- Disable "format_on_save lsp_fallback" for languages that don't
582580
-- have a well standardized coding style. You can add additional
583581
-- languages here or re-enable it for the disabled ones.
584582
local disable_filetypes = { c = true, cpp = true, py = true, ts = true, vue = true }
585-
local lsp_format_opt
586-
if disable_filetypes[vim.bo[bufnr].filetype] then
587-
lsp_format_opt = 'never'
583+
if disable_filetypes[vim.bo[bufnr].filetype] or vim.g.disable_autoformat then
584+
return
588585
else
589-
lsp_format_opt = 'fallback'
586+
return {
587+
timeout_ms = 500,
588+
lsp_format = 'fallback',
589+
}
590590
end
591-
return {
592-
timeout_ms = 500,
593-
lsp_format = lsp_format_opt,
594-
}
595591
end,
596592
formatters_by_ft = {
597593
cmake = { 'cmakelang' },
598594
cpp = { 'clang-format-15' },
599595
json = { 'clang-format-15' },
600596
lua = { 'stylua' },
601597
-- Conform can also run multiple formatters sequentially
602-
python = { 'ruff_format', 'ruff_fix' },
598+
python = { 'ruff_format', 'ruff_fix', 'ruff_organize_imports' },
599+
['*'] = { 'codespell' },
603600
--
604601
-- You can use a sub-list to tell conform to run *until* a formatter
605602
-- is found.
@@ -818,7 +815,7 @@ require('lazy').setup({
818815
end,
819816
},
820817

821-
-- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
818+
-- The following comments only work if you have downloaded the kickstart repo, not just copy pasted thefals
822819
-- init.lua. If you want these files, they are in the repository, so you can just download them and
823820
-- place them in the correct locations.
824821

lua/custom/autocommands.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,13 @@ vim.api.nvim_create_autocmd('TextYankPost', {
1111
vim.highlight.on_yank()
1212
end,
1313
})
14+
vim.api.nvim_create_user_command('FormatDisable', function()
15+
vim.g.disable_autoformat = true
16+
end, {
17+
desc = 'Disable autoformat-on-save',
18+
})
19+
vim.api.nvim_create_user_command('FormatEnable', function()
20+
vim.g.disable_autoformat = false
21+
end, {
22+
desc = 'Re-enable autoformat-on-save',
23+
})

lua/custom/keymap.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagn
1212
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
1313
vim.keymap.set('n', '<leader>z', require('telescope').extensions.zoxide.list, { desc = '[Z]oxide to different dir' })
1414
vim.keymap.set('n', '<leader>jl', require('telescope.builtin').jumplist, { desc = '[J]ump [L]ist' })
15+
vim.keymap.set('n', '<leader>ft', function()
16+
vim.g.disable_format = not vim.g.disable_autoformat
17+
end, { desc = 'Auto[F]ormat [T]oggle ' })
1518
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
1619
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
1720
-- is not what someone will guess without a bit more experience.

lua/kickstart/plugins/lint.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ return {
66
config = function()
77
local lint = require 'lint'
88
lint.linters_by_ft = {
9-
python = { 'pylint' },
9+
python = { 'ruff' },
1010
markdown = { 'markdownlint' },
1111
}
1212
-- To allow other plugins to add linters to require('lint').linters_by_ft,

0 commit comments

Comments
 (0)