This commit is contained in:
sankalp committed 2024-11-05 14:07:43 +05:45
1 parent bd932cf5e1
commit a4647b1cae
69 files changed
+12974 -5399

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
-- autopairs
-- https://github.com/windwp/nvim-autopairs
return {
'windwp/nvim-autopairs',
event = 'InsertEnter',
enabled = false,
-- Optional dependency
dependencies = { 'hrsh7th/nvim-cmp' },
config = function()
local npairs = require('nvim-autopairs')
npairs.setup({
-- The string you provided appears to be a pattern or sequence of characters enclosed within [=[[ and ]]=].
-- This syntax is used in Lua to create long string literals that can span multiple lines.
-- Here's what the pattern [=[[%w%%%'%[%"%.%%$]]=]` represents:
--
-- %w matches any alphanumeric character (letters and digits) and underscore.
-- %% matches a literal percent sign %.
-- %' matches a literal single quote '.
-- %[ matches a literal opening square bracket [.
-- %" matches a literal double quote ".
-- %. matches a literal period or dot ..
-- %`` matches a literal backtick `` ``.
-- %$ matches a literal dollar sign $.
--
-- So, this pattern would match any string that contains alphanumeric characters, underscores, percent signs,
-- single quotes, square brackets, double quotes, periods, backticks, and dollar signs.
-- ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=]
-- Add { and ( to the list so it won't add the pair when we're adding a function around
-- existing text
ignored_next_char = [=[[%w%%%'%[%"%.%`%$%{%(]]=],
fast_wrap = {},
check_ts = true,
ts_config = {
lua = { 'string' }, -- it will not add a pair on that treesitter node
javascript = { 'template_string' },
java = false, -- don't check treesitter on java
},
})
-- If you want to automatically add `(` after selecting a function or method
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp')
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
local Rule = require('nvim-autopairs.rule')
local cond = require('nvim-autopairs.conds')
vim.notify(vim.inspect(npairs.get_rules('"')))
npairs.remove_rule('`')
npairs.add_rule(Rule('`', '`'):with_pair(cond.not_before_regex('[%w%p]')))
end,
}
+19 -32
View File
@@ -1,7 +1,5 @@
--Coding related
return {
{
'max397574/better-escape.nvim',
event = 'InsertEnter',
@@ -27,7 +25,6 @@ return {
vim.g.VM_maps = {
['Find Under'] = '',
}
vim.g.VM_maps['I BS'] = ''
vim.g.VM_maps['I CtrlC'] = ''
vim.g.VM_maps['I CtrlN'] = ''
@@ -46,7 +43,6 @@ return {
terminal_width = 45,
notification_timeout = 5,
},
inline_messages = 0,
borders = 'single',
})
@@ -108,37 +104,29 @@ return {
vim.g.codeium_manual = false
vim.fn['codeium#Complete']()
end)
vim.g.codeium_filetypes = {
TelescopePrompt = false,
DressingInput = false,
['neo-tree-popup'] = false,
['dap-repl'] = false,
}
local opts = { expr = true, silent = true }
vim.g.codeium_disable_bindings = 1
vim.keymap.set('i', '<M-CR>', function()
return vim.fn['codeium#Accept']()
end, opts)
-- vim.keymap.set('n', '<leader>ch', function()
-- return vim.fn['codeium#Chat']()
-- end, { desc = 'Chat with IA (Codeium)' })
vim.keymap.set('i', '<M-]>', function()
return vim.fn['codeium#CycleCompletions'](1)
end, opts)
vim.keymap.set('i', '<M-[>', function()
return vim.fn['codeium#CycleCompletions'](-1)
end, opts)
vim.keymap.set('i', '<M-c>', function()
return vim.fn['codeium#Clear']()
end, opts)
vim.keymap.set('n', '<leader>cI', '<cmd>CodeiumToggle<cr>', { desc = 'Toggle IA (Codeium)' })
end,
},
@@ -147,6 +135,18 @@ return {
lazy = true,
ft = { 'cpp', 'h', 'hpp', 'c' },
},
{
'linux-cultist/venv-selector.nvim',
branch = 'regexp',
cmd = { 'VenvSelect', 'VenvSelectCached' },
init = function()
vim.keymap.set('n', '<leader>cv', '<cmd>VenvSelect<cr>', { desc = 'Venv Selector | Select Python venv' })
end,
opts = {},
config = function(_, opts)
require('venv-selector').setup(opts)
end,
},
{
'nacro90/numb.nvim',
event = 'CmdlineEnter',
@@ -161,27 +161,14 @@ return {
end,
},
{
'NStefan002/screenkey.nvim',
cmd = 'Screenkey',
version = '*',
config = function()
require('screenkey').setup({
win_opts = {
relative = 'editor',
anchor = 'SE',
width = 40,
height = 1,
border = 'single',
},
compress_after = 3,
clear_after = 3,
disable = {
filetypes = {}, -- for example: "toggleterm"
buftypes = {}, -- for example: "terminal"
},
})
end,
'nvchad/showkeys',
cmd = 'ShowkeysToggle',
opts = {
timeout = 1,
maxkeys = 8,
},
},
-- { 'rachartier/tiny-inline-diagnostic.nvim', event = 'BufReadPost', opts = {} },
{
'gbprod/yanky.nvim',
event = 'BufReadPost',
-205
View File
@@ -1,205 +0,0 @@
-- Define nvim-lspconfig LSP servers here
local lsp_servers = {
-- 'basedpyright',
'pyright',
'pylsp',
'lua_ls',
'ts_ls',
'tailwindcss',
'emmet_ls',
'bashls',
'jdtls',
'clangd',
'html',
'cssls',
}
local lspconfig = require('lspconfig')
-- import cmp-nvim-lsp plugin
local cmp_nvim_lsp = require('cmp_nvim_lsp')
-- import mason_lspconfig plugin
local mason_lspconfig = require('mason-lspconfig')
-- local keymap = vim.keymap -- for conciseness
-- vim.api.nvim_create_autocmd('LspAttach', {
-- group = vim.api.nvim_create_augroup('UserLspConfig', {}),
-- callback = function(ev)
-- -- Buffer local mappings.
-- -- See `:help vim.lsp.*` for documentation on any of the below functions
-- local opts = { buffer = ev.buf, silent = true }
--
-- -- set keybinds
-- opts.desc = 'Show LSP references'
-- keymap.set('n', 'lR', '<cmd>Telescope lsp_references<CR>', opts) -- show definition, references
--
-- opts.desc = 'Go to declaration'
-- keymap.set('n', 'lD', vim.lsp.buf.declaration, opts) -- go to declaration
--
-- opts.desc = 'Inlay hint'
-- keymap.set(
-- 'n',
-- '<leader>lh',
-- '<cmd>lua vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())<CR>',
-- opts
-- )
--
-- opts.desc = 'Show LSP definitions'
-- keymap.set('n', 'ld', '<cmd>Telescope lsp_definitions<CR>', opts) -- show lsp definitions
--
-- opts.desc = 'Show LSP implementations'
-- keymap.set('n', 'li', '<cmd>Telescope lsp_implementations<CR>', opts) -- show lsp implementations
--
-- opts.desc = 'Show LSP type definitions'
-- keymap.set('n', 'lt', '<cmd>Telescope lsp_type_definitions<CR>', opts) -- show lsp type definitions
--
-- opts.desc = 'See available code actions'
-- keymap.set({ 'n', 'v' }, '<leader>ca', vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection
--
-- opts.desc = 'Smart rename'
-- keymap.set('n', '<leader>mR', vim.lsp.buf.rename, opts) -- smart rename
--
-- opts.desc = 'Show buffer diagnostics'
-- keymap.set('n', '<leader>lD', '<cmd>Telescope diagnostics bufnr=0<CR>', opts) -- show diagnostics for file
--
-- opts.desc = 'Show line diagnostics'
-- keymap.set('n', '<leader>ld', vim.diagnostic.open_float, opts) -- show diagnostics for line
--
-- opts.desc = 'Show documentation for what is under cursor'
-- keymap.set('n', 'K', vim.lsp.buf.hover, opts) -- show documentation for what is under cursor
--
-- opts.desc = 'Restart LSP'
-- keymap.set('n', '<leader>ls', ':LspRestart<CR>', opts) -- mapping to restart lsp if necessary
-- end,
-- })
-- used to enable autocompletion (assign to every lsp server config)
local capabilities = cmp_nvim_lsp.default_capabilities()
-- Change the Diagnostic symbols in the sign column (gutter)
local signs = { Error = '', Warn = '', Hint = '󰠠 ', Info = '' }
for type, icon in pairs(signs) do
local hl = 'DiagnosticSign' .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' })
end
-- Set Mason LSPs Here
mason_lspconfig.setup({
ensure_installed = lsp_servers,
automatic_installation = true,
handlers = {
-- default handler for installed servers
function(server_name)
lspconfig[server_name].setup({
capabilities = capabilities,
})
end,
['lua_ls'] = function()
-- configure lua server (with special settings)
lspconfig['lua_ls'].setup({
capabilities = capabilities,
settings = {
Lua = {
-- make the language server recognize "vim" global
diagnostics = {
globals = { 'vim' },
},
completion = {
callSnippet = 'Replace',
},
workspace = {
library = {
[vim.fn.expand('$VIMRUNTIME/lua')] = true,
[vim.fn.stdpath('config') .. '/lua'] = true,
},
},
},
},
})
end,
['pyright'] = function()
-- configure pyright server (with special settings)
lspconfig['pyright'].setup({
capabilities = capabilities,
settings = {
python = {
hint = { enable = true },
analysis = {
ignore = { '*' },
autoImportCompletions = false,
},
},
-- pyright = {
-- -- Using Ruff's import organizer
-- disableOrganizeImports = true,
-- },
},
handlers = {
['textDocument/publishDiagnostics'] = function() end,
},
})
end,
-- ['pylsp'] = function()
-- lspconfig['pylsp'].setup({
-- capabilities = capabilities,
-- settings = {
-- pylsp = {
-- plugins = {
-- autopep8 = {
-- enabled = true,
-- },
-- pycodestyle = {
-- enabled = true,
-- ignore = { 'E501', 'E231', 'W503' },
-- maxLineLength = 79,
-- },
-- pylint = {
-- enabled = true,
-- executable = 'pylint',
-- args = {
-- '--enable=W0611,W0614',
-- },
-- },
-- },
-- },
-- },
-- })
-- end,
['emmet_ls'] = function()
-- configure emmet language server
lspconfig['emmet_ls'].setup({
capabilities = capabilities,
filetypes = {
'html',
'javascript',
'typescript',
'javascriptreact',
'typescriptreact',
'css',
'less',
},
})
end,
['cssls'] = function()
lspconfig.cssls.setup({
capabilities = capabilities,
settings = {
css = {
validate = true,
lint = {
unknownAtRules = 'ignore',
},
},
scss = {
validate = true,
lint = {
unknownAtRules = 'ignore',
},
},
},
})
end,
},
})
+1 -1
View File
@@ -59,9 +59,9 @@ local n_mappings = {
{ '<leader>cR', '<cmd>ReloadConfig<cr>', desc = 'Reload Configs' },
{ '<leader>cc', '<cmd>CccHighlighterToggle<cr>', desc = 'Highlight Colors' },
{ '<leader>cd', '<cmd>RootDir<cr>', desc = 'Root Directory' },
{ '<leader>ce', '<cmd>:g/^\\s*$/d<cr>', desc = 'Clean Empty Lines' },
{ '<leader>cf', group = 'Formate File' },
{ '<leader>ch', '<cmd>Hardtime toggle<cr>', desc = 'Hardtime' },
{ '<leader>cl', '<cmd>:g/^\\s*$/d<cr>', desc = 'Clean Empty Lines' },
{ '<leader>cm', '<cmd>MarkdownPreviewToggle<cr>', desc = 'Markdown Preview' },
{ '<leader>cn', '<cmd>Telescope notify<cr>', desc = 'Notifications' },
{ '<leader>co', '<cmd>Dashboard<cr>', desc = 'Dashboard' },
+146
View File
@@ -0,0 +1,146 @@
-- Define conform.nvim formatting servers here
local formatting_servers = {
'prettier',
'isort',
'uncrustify',
'black',
'stylua',
'shfmt',
'php-cs-fixer',
'google-java-formatter',
'codespell',
'autoflake',
'djlint',
}
return {
'stevearc/conform.nvim',
dependencies = { 'zapling/mason-conform.nvim' },
event = { 'BufReadPre', 'BufNewFile' },
cmd = { 'ConformInfo' },
keys = {
{
'<leader>cfF',
function()
require('conform').format({ async = true, lsp_format = 'fallback' })
end,
mode = '',
desc = 'Format Buffer',
},
{
'<leader>cff',
function()
if vim.b.disable_autoformat then
vim.cmd('FormatEnable!')
vim.notify('Formatting enabled')
else
vim.cmd('FormatDisable!')
vim.notify('Formatting disabled')
end
end,
mode = '',
desc = 'Toggle Format on save',
},
},
config = function()
local conform = require('conform')
require('mason-conform').setup({
ensure_installed = formatting_servers,
automatic_installation = true,
})
conform.setup({
notify_on_error = true,
formatters_by_ft = {
cpp = { 'uncrustify' },
c = { 'uncrustify' },
-- Conform can also run multiple formatters sequentially
-- You can use a sub-list to tell conform to run *until* a formatter is found.
javascript = { 'eslint_d', 'prettierd', 'prettier', stop_after_first = true },
typescript = { 'eslint_d', 'prettierd', 'prettier', stop_after_first = true },
javascriptreact = { 'eslint_d', 'prettierd', 'prettier', stop_after_first = true },
typescriptreact = { 'eslint_d', 'prettierd', 'prettier', stop_after_first = true },
css = { 'prettierd', 'prettier', stop_after_first = true },
html = { 'prettierd', 'prettier', stop_after_first = true },
json = { 'prettierd', 'prettier', stop_after_first = true },
yaml = { 'prettierd', 'prettier', stop_after_first = true },
markdown = { 'prettierd', 'prettier', stop_after_first = true },
lua = { 'stylua' },
python = { 'isort', 'black' },
php = { 'php-cs-fixer' },
htmldjango = { 'djlint' },
java = { 'google-java-formatter' },
graphql = { 'prettierd', 'prettier', stop_after_first = true },
liquid = { 'prettierd', 'prettier', stop_after_first = true },
bash = { 'beautysh' },
sh = { 'beautysh' },
-- yaml = {'yamlfix'},
['*'] = { 'codespell' },
['_'] = { 'trim_whitespace' },
},
formatters = {
prettier = {
javascript = {
args = { '--single-quote' },
},
},
eslint_d = {
require_cwd = true,
},
yamlfix = {
env = {
YAMLFIX_SEQUENCE_STYLE = 'block_style',
YAMLFIX_preserve_quotes = 'true',
},
},
},
-- support a global format disable
format_on_save = function(bufnr)
-- Disable 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.
local disable_filetypes = {
c = true,
cpp = true,
liquid = true,
}
local lsp_format_opt
if disable_filetypes[vim.bo[bufnr].filetype] then
lsp_format_opt = 'never'
else
lsp_format_opt = 'fallback'
end
return {
timeout_ms = 2000,
lsp_format = lsp_format_opt,
}
end,
})
-- From: https://github.com/stevearc/conform.nvim/blob/master/doc/recipes.md#command-to-toggle-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(args)
if args.bang then
vim.b.disable_autoformat = false
else
vim.g.disable_autoformat = false
end
end, {
desc = 'Re-enable autoformat-on-save',
bang = true,
})
end,
}
+43 -16
View File
@@ -2,7 +2,10 @@ return {
{
'mfussenegger/nvim-dap',
dependencies = {
-- Creates a beautiful debugger UI
'rcarriga/nvim-dap-ui',
-- Required dependency for nvim-dap-ui
'nvim-neotest/nvim-nio',
},
cmd = { 'DapUIToggle', 'DapToggleRepl', 'DapToggleBreakpoint' },
config = function()
@@ -94,27 +97,51 @@ return {
end,
},
}
-- local dap_utils = require 'user.plugins.configs.dap.utils'
local BASH_DEBUG_ADAPTER_BIN = vim.fn.stdpath('data')
.. '/mason/packages/bash-debug-adapter/bash-debug-adapter'
local BASHDB_DIR = vim.fn.stdpath('data') .. '/mason/packages/bash-debug-adapter/extension/bashdb_dir'
-- dap.adapters.ruby = {
-- type = 'executable',
-- command = 'bundle',
-- args = { 'exec', 'readapt', 'stdio' },
-- }
-- dap.configurations.ruby = {
-- {
-- type = 'ruby',
-- request = 'launch',
-- name = 'Rails',
-- program = 'bundle',
-- programArgs = { 'exec', 'rails', 's' },
-- useBundler = true,
-- },
-- }
dap.adapters.sh = {
type = 'executable',
command = BASH_DEBUG_ADAPTER_BIN,
}
dap.configurations.sh = {
{
name = 'Launch Bash debugger',
type = 'sh',
request = 'launch',
program = '${file}',
cwd = '${fileDirname}',
pathBashdb = BASHDB_DIR .. '/bashdb',
pathBashdbLib = BASHDB_DIR,
pathBash = 'bash',
pathCat = 'cat',
pathMkfifo = 'mkfifo',
pathPkill = 'pkill',
env = {},
args = {},
-- showDebugOutput = true,
-- trace = true,
},
}
vim.api.nvim_create_user_command('DapUIToggle', function()
require('dapui').toggle()
end, {})
end,
},
{
'mfussenegger/nvim-dap-python',
ft = 'python',
dependencies = {
'mfussenegger/nvim-dap',
'rcarriga/nvim-dap-ui',
'nvim-neotest/nvim-nio',
},
config = function(_, _)
local path = '~/.local/share/nvim/mason/packages/debugpy/venv/bin/python'
require('dap-python').setup(path)
end,
},
}
+8 -1
View File
@@ -30,6 +30,7 @@ return {
},
{
'folke/flash.nvim',
enabled = false,
keys = {
{
's',
@@ -71,7 +72,13 @@ return {
lazy = true,
dependencies = {
{ 'nvim-tree/nvim-web-devicons' },
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'zig' },
{
'nvim-telescope/telescope-fzf-native.nvim',
build = 'make',
cond = function()
return vim.fn.executable('make') == 1
end,
},
{ 'nvim-telescope/telescope-ui-select.nvim' },
{ 'nvim-telescope/telescope-symbols.nvim' },
{ 'nvim-telescope/telescope-file-browser.nvim' },
+54
View File
@@ -6,6 +6,60 @@ return {
require('leap').add_default_mappings()
end,
},
{
'cvigilv/esqueleto.nvim',
event = 'VeryLazy',
opts = {
directories = {
vim.fn.stdpath('config') .. '/templates',
},
patterns = {
-- File
'README',
'LICENSE',
-- Filetype
'sh',
'markdown',
'python',
'lua',
'html',
'vue',
},
},
},
{
'kawre/leetcode.nvim',
cmd = 'Leet',
build = ':TSUpdate html',
dependencies = {
'nvim-telescope/telescope.nvim',
'nvim-lua/plenary.nvim', -- required by telescope
'MunifTanjim/nui.nvim',
-- optional
'nvim-treesitter/nvim-treesitter',
'rcarriga/nvim-notify',
'nvim-tree/nvim-web-devicons',
},
opts = {},
},
{
'epwalsh/pomo.nvim',
cmd = { 'TimerStart', 'TimerStop', 'TimerRepeat' },
dependencies = {
'rcarriga/nvim-notify',
},
opts = {
notifiers = {
{
name = 'Default',
opts = {
sticky = false,
},
},
},
},
},
{
'ThePrimeagen/refactoring.nvim',
config = function()
-106
View File
@@ -1,106 +0,0 @@
-- Define conform.nvim formatting servers here
local formatting_servers = {
'prettier',
'isort',
'clang-format',
'black',
'stylua',
'shfmt',
'php-cs-fixer',
'google-java-formatter',
'codespell',
'autoflake',
'djlint',
}
return {
'stevearc/conform.nvim',
dependencies = { 'zapling/mason-conform.nvim' },
event = { 'BufReadPre', 'BufNewFile' },
cmd = { 'ConformInfo' },
config = function()
local conform = require('conform')
require('mason-conform').setup({
ensure_installed = formatting_servers,
automatic_installation = true,
})
conform.setup({
formatters_by_ft = {
cpp = { 'clang-format' },
c = { 'clang-format' },
javascript = { 'prettier' },
typescript = { 'prettier' },
javascriptreact = { 'prettier' },
typescriptreact = { 'prettier' },
css = { 'prettier' },
html = { 'prettier' },
json = { 'prettier' },
yaml = { 'prettier' },
markdown = { 'prettier', 'markdownlint' },
lua = { 'stylua' },
python = { 'isort', 'black' },
php = { 'php-cs-fixer' },
htmldjango = { 'djlint' },
java = { 'google-java-formatter' },
graphql = { 'prettier' },
liquid = { 'prettier' },
bash = { 'shfmt' },
sh = { 'shfmt' },
['*'] = { 'codespell' },
['_'] = { 'trim_whitespace' },
},
formatters = {
prettier = {
javascript = {
args = { '--single-quote' },
},
},
isort = {
python = {
args = { '--profile', 'black' },
},
},
black = {
python = {
args = { '--fast', '--line-length', '80' },
},
},
},
format_on_save = function(bufnr)
-- Disable with a global or buffer-local variable
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
return {
lsp_fallback = true,
async = false,
timeout_ms = 2500,
}
end,
})
vim.keymap.set({ 'n', 'v' }, '<leader>cff', function()
conform.format({
lsp_fallback = true,
async = true,
timeout_ms = 2500,
})
end, { desc = 'Format file or range (in visual mode)' })
vim.keymap.set({ 'n' }, '<leader>cfb', function()
vim.b.disable_autoformat = not vim.b.disable_autoformat
vim.notify(
'Buffer auto-format on-save: ' .. (vim.b.disable_autoformat and 'OFF' or 'ON'),
vim.log.levels.INFO
)
end, { desc = 'Toggle auto-format on-save for buffer.' })
vim.keymap.set({ 'n' }, '<leader>cft', function()
vim.g.disable_autoformat = not vim.g.disable_autoformat
vim.notify(
'Global auto-format on-save: ' .. (vim.g.disable_autoformat and 'OFF' or 'ON'),
vim.log.levels.INFO
)
end, { desc = 'Toggle auto-format on-save globally.' })
end,
}
+61 -7
View File
@@ -2,12 +2,13 @@
local linting_servers = {
'eslint_d',
'cspell',
'ruff',
'mypy',
-- 'ruff',
-- 'mypy',
'trivy',
'phpcs',
'markdownlint',
'pylint',
-- 'shellcheck',
}
return {
@@ -25,27 +26,80 @@ return {
})
lint.linters_by_ft = {
-- lua = { 'selene' },
lua = { 'selene' },
javascript = { 'eslint_d' },
typescript = { 'eslint_d' },
javascriptreact = { 'eslint_d' },
typescriptreact = { 'eslint_d' },
python = { 'ruff', 'mypy' },
python = { 'pylint' },
markdown = { 'markdownlint' },
java = { 'trivy' },
php = { 'phpcs' },
-- bash = { 'shellcheck' },
}
-- Run pylint in the venv
-- https://gist.github.com/Norbiox/652befc91ca0f90014aec34eccee27b2
lint.linters.pylint.cmd = 'python'
lint.linters.pylint.args = {
'-m',
'pylint',
'-f',
'json',
'--from-stdin',
function()
return vim.api.nvim_buf_get_name(0)
end,
}
-- To allow other plugins to add linters to require('lint').linters_by_ft,
-- instead set linters_by_ft like this:
-- lint.linters_by_ft = lint.linters_by_ft or {}
-- lint.linters_by_ft['markdown'] = { 'markdownlint' }
--
-- However, note that this will enable a set of default linters,
-- which will cause errors unless these tools are available:
-- {
-- clojure = { "clj-kondo" },
-- dockerfile = { "hadolint" },
-- inko = { "inko" },
-- janet = { "janet" },
-- json = { "jsonlint" },
-- markdown = { "vale" },
-- rst = { "vale" },
-- ruby = { "ruby" },
-- terraform = { "tflint" },
-- text = { "vale" }
-- }
--
-- You can disable the default linters by setting their filetypes to nil:
-- lint.linters_by_ft['clojure'] = nil
-- lint.linters_by_ft['dockerfile'] = nil
-- lint.linters_by_ft['inko'] = nil
-- lint.linters_by_ft['janet'] = nil
-- lint.linters_by_ft['json'] = nil
-- lint.linters_by_ft['markdown'] = nil
-- lint.linters_by_ft['rst'] = nil
-- lint.linters_by_ft['ruby'] = nil
-- lint.linters_by_ft['terraform'] = nil
-- lint.linters_by_ft['text'] = nil
local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true })
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
group = lint_augroup,
callback = function()
lint.try_lint()
if not vim.g.disable_linting then
if not vim.b.disable_linting then
lint.try_lint()
end
end
end,
})
vim.keymap.set('n', '<leader>cl', function()
vim.b.disable_linting = not (vim.b.disable_linting == true)
end, { desc = 'Toggle linting for file' })
vim.keymap.set('n', '<leader>cL', function()
lint.try_lint()
end, { desc = 'Trigger linting for current file' })
vim.g.disable_linting = not (vim.g.disable_linting == true)
end, { desc = 'Toggle linting for all files' })
end,
}
+361 -13
View File
@@ -1,19 +1,7 @@
return {
{
'neovim/nvim-lspconfig',
event = { 'BufReadPost', 'BufNewFile', 'BufWritePre' },
dependencies = {
'hrsh7th/cmp-nvim-lsp',
{ 'antosha417/nvim-lsp-file-operations', config = true },
'williamboman/mason-lspconfig.nvim',
},
config = function()
require('plugins.configs.lsp')
end,
},
{
'williamboman/mason.nvim',
cmd = { 'Mason', 'MasonInstall', 'MasonInstallAll', 'MasonUpdate' },
cmd = { 'Mason', 'MasonInstall', 'MasonUninstall', 'MasonInstallAll', 'MasonUpdate' },
config = function()
-- import mason
local mason = require('mason')
@@ -30,4 +18,364 @@ return {
})
end,
},
{
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
-- used for completion, annotations and signatures of Neovim apis
'folke/lazydev.nvim',
ft = 'lua',
opts = {
library = {
-- Load luvit types when the `vim.uv` word is found
{ path = 'luvit-meta/library', words = { 'vim%.uv' } },
},
},
},
{ 'Bilal2453/luvit-meta', lazy = true },
{
-- Main LSP Configuration
'neovim/nvim-lspconfig',
event = { 'BufReadPre', 'BufNewFile' },
dependencies = {
-- Automatically install LSPs and related tools to stdpath for Neovim
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
-- Useful status updates for LSP.
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
{ 'j-hui/fidget.nvim', opts = {} },
-- Allows extra capabilities provided by nvim-cmp
'hrsh7th/cmp-nvim-lsp',
},
config = function()
-- Brief aside: **What is LSP?**
--
-- LSP is an initialism you've probably heard, but might not understand what it is.
--
-- LSP stands for Language Server Protocol. It's a protocol that helps editors
-- and language tooling communicate in a standardized fashion.
--
-- In general, you have a "server" which is some tool built to understand a particular
-- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers
-- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone
-- processes that communicate with some "client" - in this case, Neovim!
--
-- LSP provides Neovim with features like:
-- - Go to definition
-- - Find references
-- - Autocompletion
-- - Symbol Search
-- - and more!
--
-- Thus, Language Servers are external tools that must be installed separately from
-- Neovim. This is where `mason` and related plugins come into play.
--
-- If you're wondering about lsp vs treesitter, you can check out the wonderfully
-- and elegantly composed help section, `:help lsp-vs-treesitter`
-- This function gets run when an LSP attaches to a particular buffer.
-- That is to say, every time a new file is opened that is associated with
-- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
-- function will be executed to configure the current buffer
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
callback = function(event)
-- NOTE: Remember that Lua is a real programming language, and as such it is possible
-- to define small helper and utility functions so you don't have to repeat yourself.
--
-- In this case, we create a function that lets us more easily define mappings specific
-- for LSP related items. It sets the mode, buffer and description for us each time.
local map = function(keys, func, desc, mode)
mode = mode or 'n'
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end
-- Jump to the definition of the word under your cursor.
-- This is where a variable was first declared, or where a function is defined, etc.
-- To jump back, press <C-t>.
map('gd', function()
require('telescope.builtin').lsp_definitions()
end, 'Goto definition')
-- Find references for the word under your cursor.
map('gr', function()
require('telescope.builtin').lsp_references()
end, 'Goto references')
-- Jump to the implementation of the word under your cursor.
-- Useful when your language has ways of declaring types without an actual implementation.
map('gI', function()
require('telescope.builtin').lsp_implementations()
end, 'Goto implementation')
-- Jump to the type of the word under your cursor.
-- Useful when you're not sure what type a variable is and you want to see
-- the definition of its *type*, not where it was *defined*.
map('<leader>cD', function()
require('telescope.builtin').lsp_type_definitions()
end, 'Code Type definition')
-- Fuzzy find all the symbols in your current document.
-- Symbols are things like variables, functions, types, etc.
map('<leader>ss', function()
require('telescope.builtin').lsp_document_symbols()
end, 'Document symbols')
-- Fuzzy find all the symbols in your current workspace.
-- Similar to document symbols, except searches over your entire project.
map('<leader>sS', function()
require('telescope.builtin').lsp_dynamic_workspace_symbols()
end, 'Workspace symbols')
-- Rename the variable under your cursor.
-- Most Language Servers support renaming across files, etc.
map('<leader>cR', vim.lsp.buf.rename, 'Code: rename')
-- Execute a code action, usually your cursor needs to be on top of an error
-- or a suggestion from your LSP for this to activate.
-- map('<leader>ca', vim.lsp.buf.code_action, 'Code action')
map('<leader>ca', vim.lsp.buf.code_action, 'Code action', { 'n', 'x' })
-- map('<leader>ca', function() require('tiny-code-action').code_action() end, 'Code action', { 'n', 'x' })
map('<leader>vR', '<cmd>LspRestart<CR>', 'Restart LSP')
-- Opens a popup that displays documentation about the word under your cursor
-- See `:help K` for why this keymap.
map('K', vim.lsp.buf.hover, 'Hover Documentation')
-- WARN: This is not Goto Definition, this is Goto Declaration.
-- For example, in C this would take you to the header.
map('gD', vim.lsp.buf.declaration, 'Goto declaration')
-- The following two autocommands are used to highlight references of the
-- word under your cursor when your cursor rests there for a little while.
-- See `:help CursorHold` for information about when this is executed
--
-- When you move your cursor, the highlights will be cleared (the second autocommand).
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
local highlight_augroup =
vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = event.buf,
group = highlight_augroup,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
buffer = event.buf,
group = highlight_augroup,
callback = vim.lsp.buf.clear_references,
})
vim.api.nvim_create_autocmd('LspDetach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
callback = function(event2)
vim.lsp.buf.clear_references()
vim.api.nvim_clear_autocmds({ group = 'kickstart-lsp-highlight', buffer = event2.buf })
end,
})
end
-- The following code creates a keymap to toggle inlay hints in your
-- code, if the language server you are using supports them
--
-- This may be unwanted, since they displace some of your code
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
map('<leader>vH', function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf }))
end, 'Toggle inlay hints')
vim.lsp.inlay_hint.enable()
end
end,
})
-- LSP servers and clients are able to communicate to each other what features they support.
-- By default, Neovim doesn't support everything that is in the LSP specification.
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
-- So, we create new capabilities with nvim cmp, and then broadcast that to the servers.
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())
-- Change the Diagnostic symbols in the sign column (gutter)
-- local signs = { Error = '󰅚 ', Warn = '󰀪 ', Info = ' ', Hint = '󰌶 ' }
local signs = { Error = '', Warn = '', Info = '', Hint = '' }
for type, icon in pairs(signs) do
local hl = 'DiagnosticSign' .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' })
end
-- Change border of documentation hover window, See https://github.com/neovim/neovim/pull/13998.
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
border = 'rounded',
})
-- Enable the following language servers
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
--
-- Add any additional override configuration in the following tables. Available keys are:
-- - cmd (table): Override the default command used to start the server
-- - filetypes (table): Override the default list of associated filetypes for the server
-- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
-- - settings (table): Override the default settings passed when initializing the server.
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local servers = {
-- clangd = {},
-- gopls = {},
-- pyright = {},
-- rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
--
-- Some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim
--
-- But for many setups, the LSP (`tsserver`) will work just fine
-- tsserver = {},
--
lua_ls = {
-- cmd = {...},
-- filetypes = { ...},
-- capabilities = {},
settings = {
Lua = {
workspace = {
checkThirdParty = false,
},
completion = {
callSnippet = 'Replace',
},
codeLens = {
enable = true,
},
doc = {
privateName = { '^_' },
},
hint = {
enable = true,
setType = false,
paramType = true,
paramName = 'Disable',
semicolon = 'Disable',
arrayIndex = 'Disable',
},
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
-- diagnostics = { disable = { 'missing-fields' } },
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = {
'vim',
'it',
'describe',
'before_each',
'after_each',
},
},
},
},
},
-- Bash
bashls = {
filetypes = { 'sh', 'bash' },
},
-- HTML / CSS
html = {},
cssls = {},
tailwindcss = {},
-- Javascript/Typescript
ts_ls = {},
-- Java
jdtls = {},
-- Python
pyright = {},
ruff = {},
-- C/C++
clangd = {},
-- Ruby for Shopify
-- ruby_lsp = {
-- init_options = {
-- formatter = 'standard',
-- linters = { 'standard' },
-- },
-- },
rust_analyzer = {
cargo = {
allFeatures = true,
loadOutDirsFromCheck = true,
buildScripts = {
enable = true,
},
},
-- Add clippy lints for Rust.
checkOnSave = true,
procMacro = {
enable = true,
ignored = {
['async-trait'] = { 'async_trait' },
['napi-derive'] = { 'napi' },
['async-recursion'] = { 'async_recursion' },
},
},
},
-- TOML
taplo = {},
-- Shopify
-- theme_check = {},
-- Typo is too noisy for me without a simple way to override
-- typos_lsp = {},
-- YAML
yamlls = {},
}
-- Ensure the servers and tools above are installed
-- To check the current status of installed tools and/or manually install
-- other tools, you can run
-- :Mason
--
-- You can press `g?` for help in this menu.
-- You can add other tools here that you want Mason to install
-- for you, so that they are available from within Neovim.
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
'pyright', -- Used to format Lua code
})
if not vim.g.no_mason_autoinstall then
require('mason-lspconfig').setup({ ensure_installed = ensure_installed })
end
require('mason-lspconfig').setup({
handlers = {
function(server_name)
-- https://github.com/neovim/nvim-lspconfig/pull/3232#issuecomment-2331025714
-- if server_name == 'tsserver' then server_name = 'ts_ls' end
local server = servers[server_name] or {}
-- This handles overriding only values explicitly passed
-- by the server configuration above. Useful when disabling
-- certain features of an LSP (for example, turning off formatting for tsserver)
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
require('lspconfig')[server_name].setup(server)
end,
},
})
-- Border for LSPInfo
require('lspconfig.ui.windows').default_options.border = 'single'
end,
},
}
+101 -79
View File
@@ -1,82 +1,104 @@
return {
{
"echasnovski/mini.nvim",
event = { "BufReadPost", "BufAdd", "BufNewFile" },
version = false,
config = function()
require("mini.comment").setup({})
require("mini.ai").setup({})
require("mini.cursorword").setup()
require("mini.bracketed").setup({
file = { suffix = "" },
window = { suffix = "" },
quickfix = { suffix = "" },
yank = { suffix = "" },
treesitter = { suffix = "n" },
})
require("mini.surround").setup({
mappings = {
add = "gsa", -- Add surrounding in Normal and Visual modes
delete = "gsd", -- Delete surrounding
replace = "gsr", -- Replace surrounding
find = "gsf", -- Find surrounding (to the right)
find_left = "gsF", -- Find surrounding (to the left)
highlight = "gsh", -- Highlight surrounding
update_n_lines = "gsn", -- Update `n_lines`
},
keys = {
{ "gz", "", desc = "+surround" },
},
})
require("mini.pairs").setup({
-- odes = { command = true },
-- mappings = {
-- ['<'] = { action = 'open', pair = '<>', neigh_pattern = '[^\\].' },
-- ['>'] = { action = 'close', pair = '<>', neigh_pattern = '[^\\].' },
-- },
})
require("mini.move").setup({
keys = {
{ "<M-Left>", mode = { "n", "v" } },
{ "<M-Down>", mode = { "n", "v" } },
{ "<M-Up>", mode = { "n", "v" } },
{ "<M-Right>", mode = { "n", "v" } },
},
{
'echasnovski/mini.nvim',
event = 'VeryLazy',
-- event = { "BufReadPost", "BufAdd", "BufNewFile" },
version = false,
config = function()
require('mini.comment').setup({})
require('mini.ai').setup({})
require('mini.cursorword').setup()
require('mini.bracketed').setup({
file = { suffix = '' },
window = { suffix = '' },
quickfix = { suffix = '' },
yank = { suffix = '' },
treesitter = { suffix = 'n' },
})
local ai = require('mini.ai')
ai.setup({
n_lines = 500,
custom_textobjects = {
s = ai.gen_spec.treesitter({ -- code block
a = { '@block.outer', '@conditional.outer', '@loop.outer' },
i = { '@block.inner', '@conditional.inner', '@loop.inner' },
}),
f = ai.gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' }), -- function
i = require('mini.extra').gen_ai_spec.indent(),
g = require('mini.extra').gen_ai_spec.buffer(),
},
})
require('mini.surround').setup({
mappings = {
add = 'gsa', -- Add surrounding in Normal and Visual modes
delete = 'gsd', -- Delete surrounding
replace = 'gsr', -- Replace surrounding
find = 'gsf', -- Find surrounding (to the right)
find_left = 'gsF', -- Find surrounding (to the left)
highlight = 'gsh', -- Highlight surrounding
update_n_lines = 'gsn', -- Update `n_lines`
},
keys = {
{ 'gz', '', desc = '+surround' },
},
})
require('mini.pairs').setup({
-- odes = { command = true },
-- mappings = {
-- ['<'] = { action = 'open', pair = '<>', neigh_pattern = '[^\\].' },
-- ['>'] = { action = 'close', pair = '<>', neigh_pattern = '[^\\].' },
-- },
mappings = {
['('] = { action = 'open', pair = '()', neigh_pattern = '[^\\][%s)}%]]' },
['['] = { action = 'open', pair = '[]', neigh_pattern = '[^\\][%s)}%]]' },
['{'] = { action = 'open', pair = '{}', neigh_pattern = '[^\\][%s)}%]]' },
['`'] = { neigh_pattern = '[^%a%d\\%-`][%s)}%]]' },
['"'] = { neigh_pattern = '[^%a%d\\%-"][%s)}%]]' },
["'"] = { neigh_pattern = "[^%a%d\\%-'][%s)}%]]" },
},
})
require('mini.move').setup({
keys = {
{ '<M-Left>', mode = { 'n', 'v' } },
{ '<M-Down>', mode = { 'n', 'v' } },
{ '<M-Up>', mode = { 'n', 'v' } },
{ '<M-Right>', mode = { 'n', 'v' } },
},
mappings = {
left = "<M-Left>",
line_left = "<M-Left>",
right = "<M-Right>",
line_right = "<M-Right>",
down = "<M-Down>",
line_down = "<M-Down>",
up = "<M-Up>",
line_up = "<M-Up>",
},
})
end,
},
{
"echasnovski/mini.files",
version = false,
keys = {
{ "-", "<cmd>lua require('mini.files').open(vim.api.nvim_buf_get_name(0))<CR>", { silent = true } },
},
},
{
"echasnovski/mini.icons",
opts = {},
lazy = true,
specs = {
{ "nvim-tree/nvim-web-devicons", enabled = false, optional = true },
},
init = function()
package.preload["nvim-web-devicons"] = function()
-- needed since it will be false when loading and mini will fail
package.loaded["nvim-web-devicons"] = {}
require("mini.icons").mock_nvim_web_devicons()
return package.loaded["nvim-web-devicons"]
end
end,
},
mappings = {
left = '<M-Left>',
line_left = '<M-Left>',
right = '<M-Right>',
line_right = '<M-Right>',
down = '<M-Down>',
line_down = '<M-Down>',
up = '<M-Up>',
line_up = '<M-Up>',
},
})
end,
},
{
'echasnovski/mini.files',
version = false,
keys = {
{ '-', "<cmd>lua require('mini.files').open(vim.api.nvim_buf_get_name(0))<CR>", { silent = true } },
},
},
{
'echasnovski/mini.icons',
opts = {},
lazy = true,
specs = {
{ 'nvim-tree/nvim-web-devicons', enabled = false, optional = true },
},
init = function()
package.preload['nvim-web-devicons'] = function()
-- needed since it will be false when loading and mini will fail
package.loaded['nvim-web-devicons'] = {}
require('mini.icons').mock_nvim_web_devicons()
return package.loaded['nvim-web-devicons']
end
end,
},
}
+55 -7
View File
@@ -3,20 +3,18 @@ return {
{
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
event = 'FileType',
event = 'VeryLazy',
cmd = { 'TSInstall', 'TSBufEnable', 'TSBufDisable', 'TSModuleInfo' },
dependencies = {
'nvim-treesitter/nvim-treesitter-textobjects',
{ 'windwp/nvim-ts-autotag', event = { 'BufReadPost', 'BufNewFile', 'BufWritePre' } },
{ 'windwp/nvim-ts-autotag', ft = { 'html', 'xml', 'tsx' }, opts = {} },
},
config = function()
require('nvim-ts-autotag').setup()
require('nvim-treesitter.configs').setup({
highlight = {
enable = true,
},
indent = {
enable = true,
disable = { 'ruby' },
},
ensure_installed = {
'vim',
@@ -25,21 +23,58 @@ return {
'markdown_inline',
'bash',
'c',
'cpp',
'java',
'javascript',
'typescript',
'tsx',
'json',
'toml',
'html',
'css',
'scss',
'lua',
'luadoc',
'diff',
'gitcommit',
'python',
'liquid',
},
auto_install = true,
highlight = {
enable = true,
disable = function(_, buf)
local line_count = vim.api.nvim_buf_line_count(buf)
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
-- vim.notify('stats: ' .. vim.inspect(stats))
-- if file is at least 10k and the average bytes per line is > 250, then disable treesitter
if ok and stats and (stats.size > (10 * 1024)) and (stats.size / line_count) > 250 then
vim.notify(
'Disabling treesitter, bytes: '
.. stats.size
.. ', lines: '
.. line_count
.. ', bytes / lines: '
.. math.floor(stats.size / line_count)
)
return true
end
return false
end,
-- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
-- If you are experiencing weird indenting issues, add the language to
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
additional_vim_regex_highlighting = { 'ruby' },
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<C-space>',
node_incremental = '<C-space>',
scope_incremental = false,
node_decremental = '<bs>',
},
},
playground = {
enable = true,
disable = {},
@@ -55,6 +90,19 @@ return {
['ic'] = { query = '@class.inner', desc = 'Select inner part of a class region' },
},
},
move = {
enable = true,
-- don't include classes to not conflict with conflicts in a diff
-- (LazyVim has some clever code but i don't think we need it right now)
-- goto_next_start = { [']f'] = '@function.outer', [']c'] = '@class.outer', [']a'] = '@parameter.inner' },
-- goto_next_end = { [']F'] = '@function.outer', [']C'] = '@class.outer', [']A'] = '@parameter.inner' },
-- goto_previous_start = { ['[f'] = '@function.outer', ['[c'] = '@class.outer', ['[a'] = '@parameter.inner' },
-- goto_previous_end = { ['[F'] = '@function.outer', ['[C'] = '@class.outer', ['[A'] = '@parameter.inner' },
goto_next_start = { [']f'] = '@function.outer', [']a'] = '@parameter.inner' },
goto_next_end = { [']F'] = '@function.outer', [']A'] = '@parameter.inner' },
goto_previous_start = { ['[f'] = '@function.outer', ['[a'] = '@parameter.inner' },
goto_previous_end = { ['[F'] = '@function.outer', ['[A'] = '@parameter.inner' },
},
swap = {
enable = true,
swap_next = {
+1
View File
@@ -144,6 +144,7 @@ return {
})
end,
},
{},
{
'nvim-lualine/lualine.nvim',
event = { 'BufReadPost', 'BufNewFile' },