configure python
This commit is contained in:
parent
b045d7c627
commit
b9d9f7e264
9 changed files with 96 additions and 12 deletions
|
|
@ -1,7 +1,67 @@
|
|||
-- Non-plugin autocommands (minimal placeholder for bootstrap)
|
||||
local aug = vim.api.nvim_create_augroup('UserDefaults', { clear = true })
|
||||
|
||||
-- Add specific autocmds in later phases
|
||||
-- Phase 9.4: Per-filetype indentation settings to match formatters
|
||||
|
||||
-- PHP: WordPress coding standards (tabs, displayed as 2 spaces)
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = aug,
|
||||
pattern = "php",
|
||||
callback = function()
|
||||
vim.opt_local.expandtab = false -- Use actual tabs (WordPress standard)
|
||||
vim.opt_local.tabstop = 2 -- Display tabs as 2 spaces wide
|
||||
vim.opt_local.shiftwidth = 2 -- Indent/outdent by 2 columns (one tab)
|
||||
vim.opt_local.softtabstop = 2 -- Tab key inserts 2 columns (one tab)
|
||||
end,
|
||||
})
|
||||
|
||||
-- JavaScript, TypeScript, JSON, CSS: Prettier defaults (2 spaces)
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = aug,
|
||||
pattern = { "javascript", "javascriptreact", "typescript", "typescriptreact", "json", "css", "scss", "html" },
|
||||
callback = function()
|
||||
vim.opt_local.expandtab = true -- Use spaces (Prettier default)
|
||||
vim.opt_local.tabstop = 2 -- Display as 2 spaces
|
||||
vim.opt_local.shiftwidth = 2 -- Indent by 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
end,
|
||||
})
|
||||
|
||||
-- Lua: stylua defaults (2 spaces)
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = aug,
|
||||
pattern = "lua",
|
||||
callback = function()
|
||||
vim.opt_local.expandtab = true -- Use spaces (common for Lua configs)
|
||||
vim.opt_local.tabstop = 2 -- Display as 2 spaces
|
||||
vim.opt_local.shiftwidth = 2 -- Indent by 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
end,
|
||||
})
|
||||
|
||||
-- Markdown: Prettier defaults (2 spaces)
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = aug,
|
||||
pattern = "markdown",
|
||||
callback = function()
|
||||
vim.opt_local.expandtab = true -- Use spaces
|
||||
vim.opt_local.tabstop = 2 -- Display as 2 spaces
|
||||
vim.opt_local.shiftwidth = 2 -- Indent by 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
end,
|
||||
})
|
||||
|
||||
-- Python: Black defaults (4 spaces)
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = aug,
|
||||
pattern = "python",
|
||||
callback = function()
|
||||
vim.opt_local.expandtab = true -- Use spaces (PEP 8)
|
||||
vim.opt_local.tabstop = 4 -- Display as 4 spaces
|
||||
vim.opt_local.shiftwidth = 4 -- Indent by 4
|
||||
vim.opt_local.softtabstop = 4
|
||||
end,
|
||||
})
|
||||
|
||||
return {}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,8 +95,9 @@ return {
|
|||
configure("intelephense", {
|
||||
single_file_support = false,
|
||||
})
|
||||
configure("pyright") -- Python LSP
|
||||
|
||||
-- Enable all configured servers
|
||||
vim.lsp.enable({ "lua_ls", "ts_ls", "html", "cssls", "jsonls", "bashls", "marksman", "intelephense" })
|
||||
vim.lsp.enable({ "lua_ls", "ts_ls", "html", "cssls", "jsonls", "bashls", "marksman", "intelephense", "pyright" })
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ return {
|
|||
"bashls",
|
||||
"marksman",
|
||||
"intelephense",
|
||||
"pyright",
|
||||
},
|
||||
automatic_installation = true,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@ return {
|
|||
-- Formatters
|
||||
"prettier", -- JS, TS, CSS, JSON, Markdown, HTML
|
||||
"stylua", -- Lua
|
||||
"black", -- Python
|
||||
-- Note: phpcbf already installed globally
|
||||
|
||||
-- Linters
|
||||
"eslint_d", -- JS, TS (daemon version for speed)
|
||||
"markdownlint", -- Markdown
|
||||
"ruff", -- Python (fast linter + import sorter)
|
||||
-- Note: phpcs already installed globally
|
||||
},
|
||||
auto_update = false,
|
||||
|
|
|
|||
|
|
@ -74,6 +74,11 @@ return {
|
|||
formatting.stylua.with({
|
||||
command = find_executable({ "stylua" }),
|
||||
}),
|
||||
|
||||
-- black (Python)
|
||||
formatting.black.with({
|
||||
command = find_executable({ "black" }),
|
||||
}),
|
||||
},
|
||||
|
||||
-- Format on save
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ return {
|
|||
typescriptreact = { "eslint_d" },
|
||||
markdown = { "markdownlint" },
|
||||
php = { "phpcs" },
|
||||
python = { "ruff" },
|
||||
}
|
||||
|
||||
-- Helper: Find project-local executable, fallback to global
|
||||
|
|
@ -68,6 +69,9 @@ return {
|
|||
-- Configure markdownlint
|
||||
lint.linters.markdownlint.cmd = find_executable({ "markdownlint" }) or "markdownlint"
|
||||
|
||||
-- Configure ruff for Python
|
||||
lint.linters.ruff.cmd = find_executable({ "ruff" }) or "ruff"
|
||||
|
||||
-- Auto-lint on these events
|
||||
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ return {
|
|||
"markdown",
|
||||
"markdown_inline",
|
||||
"bash",
|
||||
"python",
|
||||
"regex",
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -35,3 +35,9 @@ vim.opt.relativenumber = true
|
|||
vim.opt.signcolumn = 'yes' -- Always show sign column (for LSP diagnostics, git signs, etc.)
|
||||
vim.opt.cursorline = true -- Highlight current line
|
||||
vim.opt.colorcolumn = '80,120' -- Visual guides at 80 and 120 characters
|
||||
|
||||
-- Phase 9.4: Default indentation (per-filetype overrides in after/ftplugin/)
|
||||
vim.opt.tabstop = 4 -- Display tabs as 4 spaces
|
||||
vim.opt.shiftwidth = 4 -- Indent by 4
|
||||
vim.opt.softtabstop = 4 -- Backspace removes 4 spaces
|
||||
vim.opt.expandtab = true -- Use spaces by default (overridden per-filetype)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue