Skip to content

Commit 185d210

Browse files
committed
indentation fix, linting, terminal toggleable
1 parent 7fbda8b commit 185d210

File tree

8 files changed

+181
-15
lines changed

8 files changed

+181
-15
lines changed

.markdownlint.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
2+
default: true
3+
MD013: false

init.lua

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -681,17 +681,31 @@ require('lazy').setup({
681681
-- https://github.com/pmizio/typescript-tools.nvim
682682
--
683683
-- But for many setups, the LSP (`ts_ls`) will work just fine
684+
685+
-- LSPs
684686
ts_ls = {},
685-
ruff = {},
686687
csharp_ls = {},
687-
debugpy = {},
688688
intelephense = {},
689689
html = {},
690690
cssls = {},
691691
docker_compose_language_service = {},
692692
dockerls = {},
693+
694+
-- Formatters
695+
ruff = {},
696+
prettierd = {},
697+
prettier = {},
698+
pint = {},
699+
700+
-- linters
693701
tombi = {},
694-
--
702+
['markdownlint-cli2'] = {},
703+
htmlhint = {},
704+
eslint_d = {},
705+
phpstan = {},
706+
707+
-- debuggers
708+
debugpy = {},
695709

696710
lua_ls = {
697711
-- cmd = { ... },
@@ -770,7 +784,7 @@ require('lazy').setup({
770784
return nil
771785
else
772786
return {
773-
timeout_ms = 500,
787+
timeout_ms = 5000,
774788
lsp_format = 'fallback',
775789
}
776790
end
@@ -781,7 +795,17 @@ require('lazy').setup({
781795
python = { 'ruff_fix', 'ruff_format', 'ruff_organize_imports' },
782796

783797
-- You can use 'stop_after_first' to run the first available formatter from the list
784-
-- javascript = { "prettierd", "prettier", stop_after_first = true },
798+
javascript = { 'prettierd', 'prettier', stop_after_first = true },
799+
javascriptreact = { 'prettierd', 'prettier', stop_after_first = true },
800+
typescript = { 'prettierd', 'prettier', stop_after_first = true },
801+
typescriptreact = { 'prettierd', 'prettier', stop_after_first = true },
802+
css = { 'prettierd', 'prettier', stop_after_first = true },
803+
html = { 'prettierd', 'prettier', stop_after_first = true },
804+
json = { 'prettierd', 'prettier', stop_after_first = true },
805+
markdown = { 'prettierd', 'prettier', stop_after_first = true },
806+
yaml = { 'prettierd', 'prettier', stop_after_first = true },
807+
graphql = { 'prettierd', 'prettier', stop_after_first = true },
808+
php = { 'pint' }, -- https://laravel.com/docs/12.x/pint
785809
},
786810
},
787811
},
@@ -958,6 +982,7 @@ require('lazy').setup({
958982
'c',
959983
'diff',
960984
'html',
985+
'css',
961986
'lua',
962987
'luadoc',
963988
'markdown',
@@ -969,6 +994,17 @@ require('lazy').setup({
969994
'c_sharp',
970995
'javascript',
971996
'php',
997+
'php_only',
998+
'phpdoc',
999+
'json',
1000+
'json5',
1001+
'razor',
1002+
'typescript',
1003+
'vue',
1004+
'xml',
1005+
'csv',
1006+
'dockerfile',
1007+
'powershell',
9721008
},
9731009
-- Autoinstall languages that are not installed
9741010
auto_install = true,
@@ -977,9 +1013,9 @@ require('lazy').setup({
9771013
-- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
9781014
-- If you are experiencing weird indenting issues, add the language to
9791015
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
980-
additional_vim_regex_highlighting = { 'ruby' },
1016+
additional_vim_regex_highlighting = { 'ruby', 'php' },
9811017
},
982-
indent = { enable = true, disable = { 'ruby' } },
1018+
indent = { enable = true, disable = { 'ruby', 'php' } },
9831019
},
9841020
-- There are additional nvim-treesitter modules that you can use to interact
9851021
-- with nvim-treesitter. You should go explore a few and see what interests you:
@@ -1000,8 +1036,8 @@ require('lazy').setup({
10001036
--
10011037
require 'kickstart.plugins.debug',
10021038
require 'kickstart.plugins.indent_line',
1003-
-- require 'kickstart.plugins.lint',
1004-
-- require 'kickstart.plugins.autopairs',
1039+
require 'kickstart.plugins.lint',
1040+
require 'kickstart.plugins.autopairs',
10051041
require 'kickstart.plugins.neo-tree',
10061042
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
10071043

lazy-lock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
"mini.nvim": { "branch": "main", "commit": "3f71fd3573981bf18f76b2bfb6518c4ae728638d" },
1818
"neo-tree.nvim": { "branch": "main", "commit": "cea666ef965884414b1b71f6b39a537f9238bdb2" },
1919
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
20+
"nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" },
2021
"nvim-dap": { "branch": "master", "commit": "cc77338e6e34c79f1c638f51ae4160dc9bfb05de" },
2122
"nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" },
2223
"nvim-dap-python": { "branch": "master", "commit": "261ce649d05bc455a29f9636dc03f8cdaa7e0e2c" },
2324
"nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" },
24-
"nvim-lint": { "branch": "master", "commit": "3c5e34c24834a67b1cb37600ab7663eefd2b0390" },
2525
"nvim-lspconfig": { "branch": "master", "commit": "dbdb80d3bd311989d21029c63918d67a786d5013" },
2626
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
2727
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },

lua/custom/indentation.lua

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
-- lua/indentation.lua
2+
local M = {}
3+
4+
-- global default
5+
M.default = {
6+
tabstop = 4,
7+
shiftwidth = 4,
8+
expandtab = true,
9+
}
10+
11+
-- per-filetype overrides
12+
M.by_ft = {
13+
javascript = { tabstop = 2, shiftwidth = 2, expandtab = true },
14+
typescript = { tabstop = 2, shiftwidth = 2, expandtab = true },
15+
typescriptreact = { tabstop = 2, shiftwidth = 2, expandtab = true },
16+
javascriptreact = { tabstop = 2, shiftwidth = 2, expandtab = true },
17+
json = { tabstop = 2, shiftwidth = 2, expandtab = true },
18+
yaml = { tabstop = 2, shiftwidth = 2, expandtab = true },
19+
html = { tabstop = 2, shiftwidth = 2, expandtab = true },
20+
css = { tabstop = 2, shiftwidth = 2, expandtab = true },
21+
scss = { tabstop = 2, shiftwidth = 2, expandtab = true },
22+
lua = { tabstop = 2, shiftwidth = 2, expandtab = true },
23+
24+
python = { tabstop = 4, shiftwidth = 4, expandtab = true },
25+
rust = { tabstop = 4, shiftwidth = 4, expandtab = true },
26+
php = { tabstop = 4, shiftwidth = 4, expandtab = true },
27+
java = { tabstop = 4, shiftwidth = 4, expandtab = true },
28+
29+
cpp = { tabstop = 2, shiftwidth = 2, expandtab = true },
30+
c = { tabstop = 2, shiftwidth = 2, expandtab = true },
31+
32+
sh = { tabstop = 2, shiftwidth = 2, expandtab = true },
33+
bash = { tabstop = 2, shiftwidth = 2, expandtab = true },
34+
zsh = { tabstop = 2, shiftwidth = 2, expandtab = true },
35+
36+
go = { tabstop = 8, shiftwidth = 8, expandtab = false },
37+
}
38+
39+
-- fallback check: if filetype not in `by_ft`, use default
40+
function M.setup()
41+
vim.opt.tabstop = M.default.tabstop
42+
vim.opt.shiftwidth = M.default.shiftwidth
43+
vim.opt.expandtab = M.default.expandtab
44+
45+
for ft, opts in pairs(M.by_ft) do
46+
vim.api.nvim_create_autocmd('FileType', {
47+
pattern = ft,
48+
callback = function()
49+
vim.bo.tabstop = opts.tabstop
50+
vim.bo.shiftwidth = opts.shiftwidth
51+
vim.bo.expandtab = opts.expandtab
52+
end,
53+
})
54+
end
55+
56+
-- catch-all fallback for unspecified filetypes
57+
vim.api.nvim_create_autocmd('FileType', {
58+
pattern = '*',
59+
callback = function()
60+
local ts = vim.bo.tabstop
61+
if ts ~= 2 and ts ~= 8 then
62+
vim.bo.tabstop = M.default.tabstop
63+
vim.bo.shiftwidth = M.default.shiftwidth
64+
vim.bo.expandtab = M.default.expandtab
65+
end
66+
end,
67+
})
68+
end
69+
70+
return M

lua/custom/plugins/bufferline.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ return {
44
dependencies = 'nvim-tree/nvim-web-devicons',
55
config = function()
66
vim.opt.termguicolors = true
7-
require('bufferline').setup {}
7+
require('bufferline').setup {
8+
-- set up terminal buffer hiding.
9+
options = {
10+
custom_filter = function(bufnr)
11+
return vim.bo[bufnr].filetype ~= 'terminal' and vim.api.nvim_get_option_value('buflisted', { buf = bufnr })
12+
end,
13+
},
14+
}
815
vim.keymap.set('n', '<leader>.', '<cmd>BufferLineMoveNext<CR>', { desc = 'Move buffer right' })
916
vim.keymap.set('n', '<leader>,', '<cmd>BufferLineMovePrev<CR>', { desc = 'Move buffer left' })
1017
vim.keymap.set('n', '[b', '<cmd>BufferLineCyclePrev<cr>', { desc = 'Previous buffer (BufferLine order)' })

lua/custom/plugins/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ return {
88
require 'custom.plugins.vim-be-good', -- in empty file run :VimBeGood
99
require 'custom.plugins.harpoon2',
1010
require 'custom.plugins.jp-terminal',
11+
require('custom.indentation').setup(),
1112
}

lua/custom/plugins/jp-terminal.lua

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,46 @@
11
return {
2-
-- open and add terminal to harpoon buffer.
32
vim.keymap.set('n', '<leader>tt', function()
3+
local term_buf_name = 'Powershell'
4+
local existing_buf = nil
5+
local visible_win = nil
6+
7+
-- Search all buffers for one named 'Woot Terminal'
8+
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
9+
if vim.api.nvim_buf_get_name(buf):match(term_buf_name) then
10+
existing_buf = buf
11+
break
12+
end
13+
end
14+
15+
-- Check if the terminal is currently visible in any window
16+
if existing_buf then
17+
for _, win in ipairs(vim.api.nvim_list_wins()) do
18+
if vim.api.nvim_win_get_buf(win) == existing_buf then
19+
visible_win = win
20+
break
21+
end
22+
end
23+
end
24+
25+
-- If the terminal is visible, close the window
26+
if visible_win then
27+
vim.api.nvim_win_close(visible_win, true)
28+
return
29+
end
30+
31+
-- If the buffer exists but not visible, open it in split
32+
if existing_buf then
33+
vim.cmd 'split'
34+
vim.cmd 'resize 15'
35+
vim.api.nvim_win_set_buf(0, existing_buf)
36+
return
37+
end
38+
39+
-- Otherwise, create a new terminal buffer
440
vim.cmd 'split term://pwsh.exe'
541
vim.cmd 'resize 15'
6-
vim.api.nvim_buf_set_name(0, 'New Terminal')
7-
end, { desc = 'New terminal' }),
42+
vim.api.nvim_buf_set_name(0, term_buf_name)
43+
vim.api.nvim_set_option_value('buflisted', false, { scope = 'local' })
44+
vim.bo.filetype = 'terminal'
45+
end, { desc = 'Toggle Woot Terminal' }),
846
}

lua/kickstart/plugins/lint.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,24 @@ return {
33
{ -- Linting
44
'mfussenegger/nvim-lint',
55
event = { 'BufReadPre', 'BufNewFile' },
6+
67
config = function()
78
local lint = require 'lint'
9+
810
lint.linters_by_ft = {
9-
markdown = { 'markdownlint' },
11+
markdown = { 'markdownlint-cli2' },
1012
html = { 'htmlhint' },
1113
javascript = { 'eslint_d' },
1214
typescript = { 'eslint_d' },
1315
python = { 'ruff' },
16+
php = { 'phpstan' },
17+
}
18+
19+
-- configure linters like this:
20+
lint.linters['markdownlint-cli2'].args = {
21+
'--config',
22+
vim.fn.stdpath 'config' .. '/.markdownlint.yaml',
23+
'--',
1424
}
1525

1626
-- To allow other plugins to add linters to require('lint').linters_by_ft,
@@ -48,6 +58,7 @@ return {
4858
-- Create autocommand which carries out the actual linting
4959
-- on the specified events.
5060
local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true })
61+
5162
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
5263
group = lint_augroup,
5364
callback = function()

0 commit comments

Comments
 (0)