Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix sql format #33

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
fa29851
Initial settings
SafetyMary Aug 2, 2024
62f4a32
Add manual format command
SafetyMary Aug 1, 2024
f521b16
Now default to no autoformat on write
SafetyMary Aug 2, 2024
e728df1
add todo
SafetyMary Aug 4, 2024
34067ca
add ruff in mason and state ruff as python formater in conform
SafetyMary Aug 4, 2024
649fd45
fixed clipboard by installing xclip
SafetyMary Aug 5, 2024
4992e8d
add sql formater
SafetyMary Aug 5, 2024
db902ce
update docs
SafetyMary Aug 7, 2024
5232766
add markdownlint-cli2 and markdown-toc for md file formating
SafetyMary Aug 6, 2024
aaebf31
update TODO
SafetyMary Aug 7, 2024
5743988
add prettier as additional md formatter
SafetyMary Aug 7, 2024
2056158
set up ruff formatter
SafetyMary Aug 8, 2024
dee2b02
Update todo
SafetyMary Aug 12, 2024
d404a1a
try making telescope into vertical mode
SafetyMary Aug 14, 2024
8f3831b
add back ruff fix and organize imports
SafetyMary Aug 14, 2024
0a95f11
Revert "add back ruff fix and organize imports"
SafetyMary Aug 14, 2024
d67bb47
fix ruff organize improts
SafetyMary Aug 15, 2024
f992a4c
fix ruff oranize imports again
SafetyMary Aug 15, 2024
87f7fba
replace pyright with pylsp and mypy
SafetyMary Aug 28, 2024
ffb17ee
remove mypy and linter, replace with a good pylsp setup
SafetyMary Aug 31, 2024
ce64687
use traditional auto completion keymaps and remove quick keymaps for …
SafetyMary Aug 28, 2024
4e9e4e2
add pylsp install plugin commands and MasonToolsClean at VimEnter
SafetyMary Aug 31, 2024
4eebb44
add todo
SafetyMary Aug 28, 2024
776437e
track lazy-lock
SafetyMary Aug 31, 2024
35ee624
add todo
SafetyMary Aug 30, 2024
9f96ad4
update private changes
SafetyMary Aug 31, 2024
71741a4
Merge pull request #16 from SafetyMary/dev_lsp
SafetyMary Aug 31, 2024
144919c
treesitter parser and modules
SafetyMary Aug 31, 2024
66d639f
Add treesitter-context
SafetyMary Sep 1, 2024
f0a3bd3
add textobjects
SafetyMary Sep 1, 2024
f27b43d
update docs and lock
SafetyMary Sep 1, 2024
5ceada5
Merge pull request #17 from SafetyMary/dev_treesit
SafetyMary Sep 1, 2024
6762996
add prettier and jq as json formater
SafetyMary Sep 1, 2024
1cdb59f
Merge pull request #18 from SafetyMary/dev_json
SafetyMary Sep 1, 2024
34a7641
hotfix leader f key does not follow cli line length setting
SafetyMary Sep 1, 2024
91a3fd7
Merge pull request #19 from SafetyMary/hotfix_leader_f
SafetyMary Sep 1, 2024
e3cbc1a
hotfix pylsp install script
SafetyMary Sep 2, 2024
4762e1b
hotfix for auto lsp setup, fall back to manual setup
SafetyMary Sep 2, 2024
b96a454
toggle spell check at start
SafetyMary Sep 2, 2024
214dd7e
remove auto import and dupe called plugins to increase speed
SafetyMary Sep 3, 2024
6dc5555
Merge pull request #20 from SafetyMary/dev_spelling
SafetyMary Sep 5, 2024
8cb6d23
add bash lsp and formatter
SafetyMary Sep 10, 2024
2506bc7
Merge pull request #21 from SafetyMary/dev_sh
SafetyMary Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ test.sh
nvim

spell/
lazy-lock.json
36 changes: 36 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# TODO items

- Major issues:

- No check for classmethod vs abstractmethod sequence
- Warn if a class method is static
- Use LSP to rename/delete files
- Auto setup for pylsp (e.g. PyslpInstall)

- Minor issues:

- Make LSP errors/warnings appear on next line
- Implement vim.diagnostic.open_float()
- Add spelling check
- Allow indenting/unindenting multiple lines
- Add auto close brackets
- Set up LSP and formatter for bash script
- shfmt, shellcheck, bash LSP
- Add preview capability for markdown files
- leader f formating does not use current line length setting
- Auto detect vertical/horizontal monitor for telescope layout
- Auto clean up unlisted lsp servers

- Miscellaneous issues:

- Formater character limit
- Add visual guide to 120 character limit
- Add highlight support for line diff for git commit and merge requests
- Allow highlighting and moving the line
(like hightlight with 'shift'+'ctrl'+up/down arrow key)
- Fix TODO highlight in docstring

- Nice to have
- SQL LSP through local dll files
- Go through LazyVim language setup for python/SQL/md
- Set up treesitter-textobjects keymaps (currently no example on lazy.vim)
14 changes: 13 additions & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' '

-- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = false
vim.g.have_nerd_font = true

-- [[ Setting options ]]
require 'options'
Expand All @@ -105,5 +105,17 @@ require 'lazy-bootstrap'
-- [[ Configure and install plugins ]]
require 'lazy-plugins'

-- Run some neovim commands after setup
vim.api.nvim_create_autocmd('VimEnter', {
callback = function()
-- in case pylsp is not working as expected, try reinstalling through Mason
-- vim.cmd.PylspInstall { 'pyls-flake8' }
-- vim.cmd.PylspInstall { 'pylsp-mypy' }
-- vim.cmd.PylspInstall { 'pylsp-rope' }
-- vim.cmd 'MasonToolsClean'
vim.cmd.setlocal { 'spell', 'spelllang=en_us' }
end,
})

-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et
31 changes: 31 additions & 0 deletions lazy-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"LuaSnip": { "branch": "master", "commit": "45db5addf8d0a201e1cf247cae4cdce605ad3768" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "0ebe875d9c306f5fc829db38492ffff2a70d8e9d" },
"fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" },
"gitsigns.nvim": { "branch": "main", "commit": "899e993850084ea33d001ec229d237bc020c19ae" },
"lazy.nvim": { "branch": "main", "commit": "48b52b5cfcf8f88ed0aff8fde573a5cc20b1306d" },
"lazydev.nvim": { "branch": "main", "commit": "491452cf1ca6f029e90ad0d0368848fac717c6d2" },
"luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "482350b050bd413931c2cdd4857443c3da7d57cb" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"mini.nvim": { "branch": "main", "commit": "73f2e7a596bbb4e6ae6728d3a4426221ffc9512d" },
"nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" },
"nvim-lspconfig": { "branch": "master", "commit": "3ad562700d0615818bf358268ac8914f6ce2b079" },
"nvim-treesitter": { "branch": "master", "commit": "64cc1ef764a0b137a642d05cacdfe1126124fb35" },
"nvim-treesitter-context": { "branch": "master", "commit": "0ec9a8e00cedfb52e3c2259b55f46a7c18fc2429" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "3a3c6244553f13fdd92d312c82722b57ce6c4bec" },
"nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" },
"plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
"telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"todo-comments.nvim": { "branch": "main", "commit": "319c01b99b7a8c9ac2066bf0efd4d6ec68fef444" },
"tokyonight.nvim": { "branch": "main", "commit": "4b386e66a9599057587c30538d5e6192e3d1c181" },
"trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" },
"vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" },
"which-key.nvim": { "branch": "main", "commit": "bfec3d6bc0a9b0b2cb11644642f78c2c3915eef0" }
}
60 changes: 59 additions & 1 deletion lua/custom/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,62 @@
-- I promise not to create any merge conflicts in this directory :)
--
-- See the kickstart.nvim README for more information
return {}
return {
{
'folke/trouble.nvim',
opts = {}, -- for default options, refer to the configuration section for custom setup.
cmd = 'Trouble',
keys = {
{
'<leader>xx',
'<cmd>Trouble diagnostics toggle<cr>',
desc = 'Diagnostics (Trouble)',
},
{
'<leader>xX',
'<cmd>Trouble diagnostics toggle filter.buf=0<cr>',
desc = 'Buffer Diagnostics (Trouble)',
},
{
'<leader>cs',
'<cmd>Trouble symbols toggle focus=false<cr>',
desc = 'Symbols (Trouble)',
},
{
'<leader>cl',
'<cmd>Trouble lsp toggle focus=false win.position=right<cr>',
desc = 'LSP Definitions / references / ... (Trouble)',
},
{
'<leader>xL',
'<cmd>Trouble loclist toggle<cr>',
desc = 'Location List (Trouble)',
},
{
'<leader>xQ',
'<cmd>Trouble qflist toggle<cr>',
desc = 'Quickfix List (Trouble)',
},
},
},
{
'nvim-treesitter/nvim-treesitter-context',
opts = {
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit.
line_numbers = true,
multiline_threshold = 20, -- Maximum number of lines to show for a single context
trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline'
-- Separator between context and content. Should be a single character string, like '-'.
-- When separator is set, the context will only show up when there are at least 2 lines above cursorline.
separator = nil,
zindex = 20, -- The Z-index of the context window
on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching
},
},
{
'nvim-treesitter/nvim-treesitter-textobjects', -- TODO: set up keymaps
},
}
8 changes: 4 additions & 4 deletions lua/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' }
-- Use CTRL+<hjkl> to switch between windows
--
-- See `:help wincmd` for a list of all window commands
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
-- vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
-- vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
-- vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
-- vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })

-- [[ Basic Autocommands ]]
-- See `:help lua-guide-autocommands`
Expand Down
6 changes: 3 additions & 3 deletions lua/kickstart/plugins/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ return {

-- If you prefer more traditional completion keymaps,
-- you can uncomment the following lines
--['<CR>'] = cmp.mapping.confirm { select = true },
--['<Tab>'] = cmp.mapping.select_next_item(),
--['<S-Tab>'] = cmp.mapping.select_prev_item(),
['<CR>'] = cmp.mapping.confirm { select = true },
['<Tab>'] = cmp.mapping.select_next_item(),
['<S-Tab>'] = cmp.mapping.select_prev_item(),

-- Manually trigger a completion from nvim-cmp.
-- Generally you don't need this, because nvim-cmp will display
Expand Down
53 changes: 53 additions & 0 deletions lua/kickstart/plugins/conform.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
-- Add format command
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
-- Use CLI args instead of LSP server settings
require('conform').formatters.ruff_format = { append_args = { '--line-length', '120' } }
require('conform').format { async = true, lsp_format = 'fallback', range = range }
end, { range = true })

-- Add toggle command to format-on-save
vim.api.nvim_create_user_command('FormatDisable', function(args)
if args.bang then
-- FormatDisable! will disable formatting just for this buffer
vim.b.disable_autoformat = true
else
vim.g.disable_autoformat = true
end
end, {
desc = 'Disable autoformat-on-save',
bang = true,
})
vim.api.nvim_create_user_command('FormatEnable', function()
vim.b.disable_autoformat = false
vim.g.disable_autoformat = false
end, {
desc = 'Re-enable autoformat-on-save',
})

-- kickstart config
return {
{ -- Autoformat
'stevearc/conform.nvim',
Expand All @@ -7,6 +42,7 @@ return {
{
'<leader>f',
function()
require('conform').formatters.ruff_format = { append_args = { '--line-length', '120' } }
require('conform').format { async = true, lsp_format = 'fallback' }
end,
mode = '',
Expand All @@ -16,6 +52,14 @@ return {
opts = {
notify_on_error = false,
format_on_save = function(bufnr)
-- Define default behaviour here (default disable autoformat)
if (vim.g.disable_autoformat == nil) or (vim.b[bufnr].disable_autoformat == nil) then
return
end
-- Disable autoformat with a global or buffer-local variable
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
-- Disable "format_on_save lsp_fallback" for languages that don't
-- have a well standardized coding style. You can add additional
-- languages here or re-enable it for the disabled ones.
Expand All @@ -33,6 +77,15 @@ return {
end,
formatters_by_ft = {
lua = { 'stylua' },
-- use ruff as formatter, conform with 'ruff_format' uses ruff binary and ignores server settings/configs
-- https://github.com/astral-sh/ruff/issues/12778
-- currently ruff_organize_imports uses linter rather than formater, a unified interface is planned
-- https://github.com/astral-sh/ruff/issues/8232
python = { 'ruff_fix', 'ruff_organize_imports', 'ruff_format' },
sql = { 'sqlfluff' },
markdown = { 'prettier', 'markdown-toc', 'markdownlint-cli2' },
json = { 'prettier', 'jq' },
sh = { 'bashls', 'shfmt' },
-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
Expand Down
3 changes: 2 additions & 1 deletion lua/kickstart/plugins/lint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ return {
config = function()
local lint = require 'lint'
lint.linters_by_ft = {
markdown = { 'markdownlint' },
markdown = { 'markdownlint-cli2' },
python = { 'mypy', 'ruff' },
}

-- To allow other plugins to add linters to require('lint').linters_by_ft,
Expand Down
53 changes: 53 additions & 0 deletions lua/kickstart/plugins/lspconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,49 @@ return {
-- tsserver = {},
--

-- make sure to manually install jpylsp plugins
-- https://github.com/williamboman/mason-lspconfig.nvim/tree/main/lua/mason-lspconfig/server_configurations/pylsp
pylsp = {
settings = {
pylsp = {
plugins = {
flake8 = {
enabled = true,
maxLineLength = 120,
},
pycodestyle = {
enabled = false, -- Included in flake8
maxLineLength = 120,
},
mccabe = {
enabled = false, -- Included in flake8
},
pyflakes = {
enabled = false, -- Included in flake8
},
pydocstyle = {
enabled = true,
convention = 'google',
},
pylint = {
enabled = true,
args = {
'--max-line-length',
'120',
},
},
rope_autoimport = {
enabled = false,
},
rope_completion = {
enabled = true,
eager = true,
},
},
},
},
},

lua_ls = {
-- cmd = {...},
-- filetypes = { ...},
Expand Down Expand Up @@ -209,6 +252,16 @@ return {
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
'stylua', -- Used to format Lua code
'pylsp',
'ruff',
'sqlfluff',
'prettier',
'markdownlint-cli2',
'markdown-toc',
'jq',
'shellcheck',
'shfmt',
'bashls',
})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }

Expand Down
9 changes: 9 additions & 0 deletions lua/kickstart/plugins/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ return {
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
-- },
-- },

-- set vertical file preview
defaults = {
layout_strategy = 'vertical',
layout_config = {
vertical = { width = 0.8 },
},
},

-- pickers = {}
extensions = {
['ui-select'] = {
Expand Down
Loading