Skip to content

Commit 643789d

Browse files
Refactor LSP configuration and remove Kite plugin. Updated key mappings for comments and added Python-specific tab settings. Enhanced Treesitter installation list and integrated Ruff LSP for Python. Cleaned up Kite-related files and configurations.
1 parent de2d52b commit 643789d

13 files changed

Lines changed: 108 additions & 981 deletions

File tree

init.lua

Lines changed: 80 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ require('lazy').setup({
151151
'numToStr/Comment.nvim',
152152
opts = {
153153
toggler = {
154-
line = '<leader>/', -- Changed from <gc>
155-
block = '<leader>b', -- Changed from <gb>
154+
line = 'gc',
155+
block = 'gb',
156156
},
157157
opleader = {
158-
line = '<leader>/', -- Optional
159-
block = '<leader>B', -- Optional
158+
line = 'gc',
159+
block = 'gb',
160160
},
161161
}
162162
},
@@ -216,6 +216,15 @@ vim.o.softtabstop = 2
216216
vim.o.shiftwidth = 2
217217
vim.o.expandtab = true
218218

219+
vim.api.nvim_create_autocmd('FileType', {
220+
pattern = { 'python' },
221+
callback = function()
222+
vim.bo.tabstop = 4
223+
vim.bo.softtabstop = 4
224+
vim.bo.shiftwidth = 4
225+
end,
226+
})
227+
219228
-- Basic keymaps
220229
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
221230
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
@@ -257,7 +266,27 @@ end, { desc = '[/] Fuzzily search in current buffer' })
257266
-- Treesitter configuration
258267
vim.defer_fn(function()
259268
require('nvim-treesitter.configs').setup {
260-
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' },
269+
ensure_installed = {
270+
'c',
271+
'cpp',
272+
'go',
273+
'lua',
274+
'python',
275+
'rust',
276+
'tsx',
277+
'javascript',
278+
'typescript',
279+
'vimdoc',
280+
'vim',
281+
'bash',
282+
'html',
283+
'css',
284+
'json',
285+
'toml',
286+
'yaml',
287+
'dockerfile',
288+
'htmldjango',
289+
},
261290
auto_install = false,
262291
highlight = { enable = true },
263292
indent = { enable = true },
@@ -357,12 +386,54 @@ end
357386

358387
require('mason').setup()
359388
require('mason-lspconfig').setup()
360-
local servers = { lua_ls = { Lua = { workspace = { checkThirdParty = false }, telemetry = { enable = false } } } }
389+
local lspconfig = require 'lspconfig'
390+
local servers = {
391+
pyright = {
392+
python = {
393+
analysis = {
394+
autoSearchPaths = true,
395+
diagnosticMode = 'openFilesOnly',
396+
useLibraryCodeForTypes = true,
397+
},
398+
},
399+
},
400+
lua_ls = {
401+
Lua = {
402+
workspace = { checkThirdParty = false },
403+
telemetry = { enable = false },
404+
},
405+
},
406+
}
361407
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
362408
local mason_lspconfig = require 'mason-lspconfig'
363409
mason_lspconfig.setup { ensure_installed = vim.tbl_keys(servers) }
364410
mason_lspconfig.setup_handlers { function(server_name) require('lspconfig')[server_name].setup { capabilities = capabilities, on_attach = on_attach, settings = servers[server_name], filetypes = (servers[server_name] or {}).filetypes, } end }
365411

412+
-- Ruff installation via Mason can fail on some Python setups.
413+
-- If a system ruff binary exists, attach Ruff LSP directly.
414+
local ruff_server = nil
415+
if lspconfig.ruff then
416+
ruff_server = 'ruff'
417+
elseif lspconfig.ruff_lsp then
418+
ruff_server = 'ruff_lsp'
419+
end
420+
421+
if vim.fn.executable 'ruff' == 1 and ruff_server then
422+
lspconfig[ruff_server].setup {
423+
capabilities = capabilities,
424+
on_attach = on_attach,
425+
}
426+
end
427+
428+
vim.api.nvim_create_autocmd('LspAttach', {
429+
callback = function(args)
430+
local client = vim.lsp.get_client_by_id(args.data.client_id)
431+
if client and (client.name == 'ruff' or client.name == 'ruff_lsp') then
432+
client.server_capabilities.hoverProvider = false
433+
end
434+
end,
435+
})
436+
366437
-- CMP setup
367438
local cmp = require 'cmp'
368439
local luasnip = require 'luasnip'
@@ -408,13 +479,10 @@ cmp.setup {
408479
{ name = 'nvim_lsp' },
409480
{ name = 'luasnip' },
410481
},
411-
}
412-
413-
require("cmp").setup({
414482
formatting = {
415-
format = require("tailwindcss-colorizer-cmp").formatter
416-
}
417-
})
483+
format = require('tailwindcss-colorizer-cmp').formatter,
484+
},
485+
}
418486

419487
require("colorizer").setup {
420488
user_default_options = {

lua/custom/plugins/init.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
-- See the kickstart.nvim README for more information
55

66
return {
7-
{
8-
'neovim/nvim-lspconfig',
9-
config = function()
10-
require('custom.plugins.lspconfig') -- This simply loads the lspconfig.lua file
11-
end,
12-
},
13-
147
-- nvim-autopairs configuration
158
{
169
"windwp/nvim-autopairs",

lua/kickstart/plugins/autoformat.lua

Lines changed: 25 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4,90 +4,47 @@
44
-- Adds additional commands as well to manage the behavior
55

66
return {
7-
'neovim/nvim-lspconfig',
8-
'jose-elias-alvarez/null-ls.nvim',
7+
'stevearc/conform.nvim',
8+
event = { 'BufReadPre', 'BufNewFile' },
9+
cmd = { 'ConformInfo' },
910
config = function()
1011
-- Force .html files to be recognized as htmldjango for Jinja compatibility
11-
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
12-
pattern = "*.html",
12+
vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
13+
pattern = '*.html',
1314
callback = function()
14-
vim.bo.filetype = "htmldjango"
15+
vim.bo.filetype = 'htmldjango'
1516
end,
1617
})
1718

18-
-- Switch for controlling whether you want autoformatting.
1919
-- Use :KickstartFormatToggle to toggle autoformatting on or off
2020
local format_is_enabled = true
2121
vim.api.nvim_create_user_command('KickstartFormatToggle', function()
2222
format_is_enabled = not format_is_enabled
2323
print('Setting autoformatting to: ' .. tostring(format_is_enabled))
2424
end, {})
2525

26-
-- Create an augroup that is used for managing our formatting autocmds.
27-
-- We need one augroup per client to make sure that multiple clients
28-
-- can attach to the same buffer without interfering with each other.
29-
local _augroups = {}
30-
local get_augroup = function(client)
31-
if not _augroups[client.id] then
32-
local group_name = 'kickstart-lsp-format-' .. client.name
33-
local id = vim.api.nvim_create_augroup(group_name, { clear = true })
34-
_augroups[client.id] = id
35-
end
36-
37-
return _augroups[client.id]
38-
end
39-
40-
-- Whenever an LSP attaches to a buffer, we will run this function.
41-
--
42-
-- See `:help LspAttach` for more information about this autocmd event.
43-
vim.api.nvim_create_autocmd('LspAttach', {
44-
group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }),
45-
-- This is where we attach the autoformatting for reasonable clients
46-
callback = function(args)
47-
local client_id = args.data.client_id
48-
local client = vim.lsp.get_client_by_id(client_id)
49-
local bufnr = args.buf
50-
51-
-- Only attach to clients that support document formatting
52-
if not client.server_capabilities.documentFormattingProvider then
53-
return
54-
end
55-
56-
-- Tsserver usually works poorly. Sorry you work with bad languages
57-
-- You can remove this line if you know what you're doing :)
58-
if client.name == 'tsserver' then
59-
return
26+
require('conform').setup {
27+
formatters_by_ft = {
28+
python = { 'ruff_organize_imports', 'ruff_format' },
29+
htmldjango = { 'djlint' },
30+
html = { 'prettier' },
31+
css = { 'prettier' },
32+
javascript = { 'prettier' },
33+
json = { 'prettier' },
34+
yaml = { 'prettier' },
35+
},
36+
format_on_save = function(bufnr)
37+
if not format_is_enabled then
38+
return nil
6039
end
6140

62-
-- Create an autocmd that will run *before* we save the buffer.
63-
-- Run the formatting command for the LSP that has just attached.
64-
vim.api.nvim_create_autocmd('BufWritePre', {
65-
group = get_augroup(client),
66-
buffer = bufnr,
67-
callback = function()
68-
if not format_is_enabled then
69-
return
70-
end
71-
72-
vim.lsp.buf.format {
73-
async = false,
74-
filter = function(c)
75-
return c.id == client.id
76-
end,
77-
}
78-
end,
79-
})
41+
return {
42+
timeout_ms = 1000,
43+
lsp_format = 'fallback',
44+
bufnr = bufnr,
45+
}
8046
end,
81-
})
82-
83-
-- Set up null-ls for additional formatting needs
84-
null_ls.setup({
85-
sources = {
86-
null_ls.builtins.formatting.prettier.with({
87-
filetypes = { "html", "jinja", "htmldjango" },
88-
}),
89-
},
90-
})
47+
}
9148
end,
9249
}
9350

lua/kickstart/plugins/debug.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ return {
2020

2121
-- Add your own debuggers here
2222
'leoluz/nvim-dap-go',
23+
'mfussenegger/nvim-dap-python',
2324
},
2425
config = function()
2526
local dap = require 'dap'
@@ -39,6 +40,7 @@ return {
3940
ensure_installed = {
4041
-- Update this to ensure that you have the debuggers for the langs you want
4142
'delve',
43+
'debugpy',
4244
},
4345
}
4446

@@ -83,5 +85,6 @@ return {
8385

8486
-- Install golang specific config
8587
require('dap-go').setup()
88+
require('dap-python').setup(vim.fn.exepath 'python3')
8689
end,
8790
}

pack/kite/start/vim-plugin/.travis.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

pack/kite/start/vim-plugin/LICENSE

Lines changed: 0 additions & 4 deletions
This file was deleted.

pack/kite/start/vim-plugin/autoload/kite/docs.vim

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)