refactor plugins into directory

This commit is contained in:
Jason Miller 2024-12-07 03:41:14 -05:00
parent 2ffe0d20cd
commit 29efb5d532
16 changed files with 541 additions and 474 deletions

View File

@ -72,4 +72,4 @@ nvim commands to help you track down key bindings and resolve conflicts:
Kickstart: [kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim) Kickstart: [kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim)
Kickstart Video: [Get Started with Neovim](https://youtu.be/m8C0Cq9Uv9o) Kickstart Video: [Get Started with Neovim](https://youtu.be/m8C0Cq9Uv9o)
Docs: [https://neovim.io/doc/user/](Manual)

489
init.lua
View File

@ -104,489 +104,32 @@ vim.opt.rtp:prepend(lazypath)
-- :Lazy -- :Lazy
require('lazy').setup({ require('lazy').setup({
-- Detect tabstop and shiftwidth automatically
'tpope/vim-sleuth',
-- Emacs-style keybindings in insert mode require 'plugins.indentguess', -- Detects tabstop and shiftwidth to match orig
{ require 'plugins.neovimacs', -- Emacs-style keybindings while in insert mode
'millerjason/neovimacs.nvim', require 'plugins.gitsigns', -- Add git changes to gutter
opts = {}, require 'plugins.which-key', -- Show keybindings as you go
}, require 'plugins.telescope', -- Fuzzy finder (file & LSP search)
-- { require 'plugins.lsp', -- Language server (types, errors, signatures)
-- dir = '/Users/jason/github/neovimacs.nvim', require 'plugins.conform', -- Auto-reformat files on save
-- name = 'neovimacs.nvim', require 'plugins.venv', -- Virtual environment selection
-- opts = {}, require 'plugins.autocomplete', -- Auto-completion
-- }, require 'plugins.colorscheme', -- Color scheme
require 'plugins.misc', -- Misc small plugins
require 'plugins.treesitter', -- Code highlights and reference navigation
require 'plugins.todo', -- Highlight todo, notes in comments
require 'plugins.tabnine', -- Tabnine LLM coding assistant
-- Add git changes to gutter -- Treesitter navigation
{ -- :help nvim-treesitter
'lewis6991/gitsigns.nvim',
opts = {
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
},
},
},
-- Shows keybindings as you go
-- this technically requires >= 0.9.4
unpack(nvim_ver(0, 10) and {
'folke/which-key.nvim',
event = 'VimEnter',
config = function()
require('which-key').setup()
-- Document existing key chains
require('which-key').add {
{ '<leader>c', group = '[C]ode' },
{ '<leader>d', group = '[D]ocument' },
{ '<leader>r', group = '[R]ename' },
{ '<leader>s', group = '[S]earch' },
{ '<leader>w', group = '[W]orkspace' },
{ '<leader>t', group = '[T]oggle' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
}
end,
} or {}),
-- Fuzzy finder (file & lsp)
-- :Telescope help_tags -- :Telescope help_tags
-- See `:help telescope` and `:help telescope.setup()` -- See `:help telescope` and `:help telescope.setup()`
-- To see keymaps do this: -- To see keymaps do this:
-- - Insert mode: <c-/> -- - Insert mode: <c-/>
-- - Normal mode: ? -- - Normal mode: ?
{
'nvim-telescope/telescope.nvim',
event = 'VimEnter',
branch = '0.1.x',
dependencies = {
'nvim-lua/plenary.nvim',
{
'nvim-telescope/telescope-fzf-native.nvim',
build = 'make',
cond = function()
return vim.fn.executable 'make' == 1
end,
},
{ 'nvim-telescope/telescope-ui-select.nvim' },
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
},
config = function()
require('telescope').setup {
-- defaults = {
-- mappings = {
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
-- },
-- },
-- pickers = {}
extensions = {
['ui-select'] = {
require('telescope.themes').get_dropdown(),
},
},
}
-- Enable Telescope extensions if they are installed
pcall(require('telescope').load_extension, 'fzf')
pcall(require('telescope').load_extension, 'ui-select')
-- See `:help telescope.builtin`
local builtin = require 'telescope.builtin'
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Find [F]iles' })
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Find [G]rep' })
vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = 'Find [B]uffers' })
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = 'Find [H]elp tags' })
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
-- Slightly advanced example of overriding default behavior and theme
vim.keymap.set('n', '<leader>/', function()
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10,
previewer = false,
})
end, { desc = '[/] Fuzzily search in current buffer' })
-- Prompting
vim.keymap.set('n', '<leader>fG', function()
builtin.grep_string { search = vim.fn.input 'grep> ' }
end)
-- It's also possible to pass additional configuration options.
-- See `:help telescope.builtin.live_grep()` for information about particular keys
vim.keymap.set('n', '<leader>s/', function()
builtin.live_grep {
grep_open_files = true,
prompt_title = 'Live Grep in Open Files',
}
end, { desc = '[S]earch [/] in Open Files' })
end,
},
-- LSP Plugins
{
'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',
dependencies = {
-- Automatically install LSPs and related tools to stdpath for Neovim
{ 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants
'williamboman/mason-lspconfig.nvim',
'WhoIsSethDaniel/mason-tool-installer.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()
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
callback = function(event)
local map = function(keys, func, desc)
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
map('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
map('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
-- :help CursorHold
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
-- Inlay hints
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
map('<leader>th', function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
end, '[T]oggle Inlay [H]ints')
end
end,
})
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())
local servers = {
clangd = {},
pyright = {},
black = {},
isort = {},
taplo = {},
-- rust_analyzer = {},
lua_ls = {
-- cmd = {...},
-- filetypes = { ...},
-- capabilities = {},
settings = {
Lua = {
completion = {
callSnippet = 'Replace',
},
},
},
},
}
-- Ensure the servers and tools above are installed
-- :Mason
require('mason').setup()
-- 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, {
'stylua', -- Used to format Lua code
'ruff', -- lint and format for python
'debugpy', -- debugger
'taplo', -- LSP for toml files
})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
require('mason-lspconfig').setup {
handlers = {
function(server_name)
local server = servers[server_name] or {}
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
require('lspconfig')[server_name].setup(server)
end,
},
}
end,
},
-- Auto-format
{
'stevearc/conform.nvim',
event = { 'BufWritePre' },
cmd = { 'ConformInfo' },
keys = {
{
'<leader>f',
function()
require('conform').format { async = true, lsp_fallback = true }
end,
mode = '',
desc = '[F]ormat buffer',
},
},
opts = {
notify_on_error = false,
format_on_save = function(bufnr)
-- 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 }
return {
timeout_ms = 500,
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
}
end,
formatters_by_ft = {
lua = { 'stylua' },
python = { 'pyright', 'isort', 'black' },
md = { 'prettier' },
},
},
},
-- Venv selector -- Venv selector
-- WIP: https://github.com/linux-cultist/venv-selector.nvim/tree/regexp -- WIP: https://github.com/linux-cultist/venv-selector.nvim/tree/regexp
-- Wait for a updated release -- Wait for a updated release
-- Auto-completion
{
'hrsh7th/nvim-cmp',
event = 'InsertEnter',
dependencies = {
{
'L3MON4D3/LuaSnip',
build = (function()
if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then
return
end
return 'make install_jsregexp'
end)(),
dependencies = {
-- `friendly-snippets` contains a variety of premade snippets.
-- See the README about individual language/framework/plugin snippets:
-- https://github.com/rafamadriz/friendly-snippets
-- {
-- 'rafamadriz/friendly-snippets',
-- config = function()
-- require('luasnip.loaders.from_vscode').lazy_load()
-- end,
-- },
},
},
'saadparwaiz1/cmp_luasnip',
-- Other completions
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-path',
},
config = function()
-- See `:help cmp`
local cmp = require 'cmp'
local luasnip = require 'luasnip'
luasnip.config.setup {}
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
completion = {
autocomplete = false, -- Use C-Space
completeopt = 'menu,menuone,noinsert',
},
-- `:help ins-completion`
mapping = cmp.mapping.preset.insert {
['<down>'] = cmp.mapping.select_next_item(),
['<up>'] = cmp.mapping.select_prev_item(),
['<left>'] = cmp.mapping.scroll_docs(-4),
['<right>'] = cmp.mapping.scroll_docs(4),
['<Tab>'] = cmp.mapping.confirm { select = true },
['<C-g>'] = cmp.mapping.abort(),
['<C-h>'] = cmp.mapping.complete {},
['<C-right>'] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
end
end, { 'i', 's' }),
['<C-left>'] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
end
end, { 'i', 's' }),
['<C-n>'] = cmp.config.disable,
['<C-p>'] = cmp.config.disable,
},
sources = {
{
name = 'lazydev',
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
group_index = 0,
},
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' },
},
}
end,
},
-- Color scheme
{
'folke/tokyonight.nvim',
priority = 1000, -- Make sure to load this before all the other start plugins.
init = function()
vim.cmd.colorscheme 'tokyonight-night'
-- vim.cmd.hi 'Comment gui=none'
end,
},
-- Highlight todo, notes, etc in comments
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
-- Small plugings
{
'echasnovski/mini.nvim',
config = function()
-- Better Around/Inside textobjects
--
-- Examples:
-- - va) - [V]isually select [A]round [)]paren
-- - yinq - [Y]ank [I]nside [N]ext [Q]uote
-- - ci' - [C]hange [I]nside [']quote
require('mini.ai').setup { n_lines = 500 }
-- Add/delete/replace surroundings (brackets, quotes, etc.)
--
-- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
-- - sd' - [S]urround [D]elete [']quotes
-- - sr)' - [S]urround [R]eplace [)] [']
require('mini.surround').setup()
local statusline = require 'mini.statusline'
statusline.setup { use_icons = vim.g.have_nerd_font }
---@diagnostic disable-next-line: duplicate-set-field
statusline.section_location = function()
return '%2l:%-2v'
end
end,
},
-- Treesitter navigation
-- :help nvim-treesitter
{
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
opts = {
ensure_installed = {
'bash',
'c',
'cmake',
'cpp',
'css',
'cuda',
'diff',
'dockerfile',
'dot',
'go',
'gomod',
'html',
'java',
'javascript',
'json',
'json5',
'latex',
'llvm',
'lua',
'luadoc',
'make',
'markdown',
'markdown_inline',
'nix',
'python',
'query',
'rst',
'toml',
'vim',
'vimdoc',
'yaml',
},
auto_install = true,
highlight = {
enable = true,
additional_vim_regex_highlighting = { 'ruby' },
},
indent = { enable = true, disable = { 'ruby' } },
},
config = function(_, opts)
---@diagnostic disable-next-line: missing-fields
require('nvim-treesitter.configs').setup(opts)
end,
},
-- require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint',
-- require 'kickstart.plugins.autopairs',
-- require 'kickstart.plugins.neo-tree',
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
}, { }, {
ui = { ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the -- If you are using a Nerd Font: set icons to an empty table which will use the

View File

@ -0,0 +1,83 @@
return {
{
'hrsh7th/nvim-cmp',
event = 'InsertEnter',
dependencies = {
{
'L3MON4D3/LuaSnip',
build = (function()
if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then
return
end
return 'make install_jsregexp'
end)(),
dependencies = {
-- `friendly-snippets` contains a variety of premade snippets.
-- See the README about individual language/framework/plugin snippets:
-- https://github.com/rafamadriz/friendly-snippets
-- {
-- 'rafamadriz/friendly-snippets',
-- config = function()
-- require('luasnip.loaders.from_vscode').lazy_load()
-- end,
-- },
},
},
'saadparwaiz1/cmp_luasnip',
-- Other completions
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-path',
},
config = function()
-- See `:help cmp`
local cmp = require 'cmp'
local luasnip = require 'luasnip'
luasnip.config.setup {}
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
completion = {
autocomplete = false, -- Use C-Space
completeopt = 'menu,menuone,noinsert',
},
-- `:help ins-completion`
mapping = cmp.mapping.preset.insert {
['<down>'] = cmp.mapping.select_next_item(),
['<up>'] = cmp.mapping.select_prev_item(),
['<left>'] = cmp.mapping.scroll_docs(-4),
['<right>'] = cmp.mapping.scroll_docs(4),
['<Tab>'] = cmp.mapping.confirm { select = true },
['<C-g>'] = cmp.mapping.abort(),
['<C-h>'] = cmp.mapping.complete {},
['<C-right>'] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
end
end, { 'i', 's' }),
['<C-left>'] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
end
end, { 'i', 's' }),
['<C-n>'] = cmp.config.disable,
['<C-p>'] = cmp.config.disable,
},
sources = {
{
name = 'lazydev',
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
group_index = 0,
},
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' },
},
}
end,
},
}

View File

@ -0,0 +1,10 @@
return {
{
'folke/tokyonight.nvim',
priority = 1000, -- Make sure to load this before all the other start plugins.
init = function()
vim.cmd.colorscheme 'tokyonight-night'
-- vim.cmd.hi 'Comment gui=none'
end,
},
}

35
lua/plugins/conform.lua Normal file
View File

@ -0,0 +1,35 @@
return {
{
'stevearc/conform.nvim',
event = { 'BufWritePre' },
cmd = { 'ConformInfo' },
keys = {
{
'<leader>fo',
function()
require('conform').format { async = true, lsp_fallback = true }
end,
mode = '',
desc = '[Fo]rmat Buffer',
},
},
opts = {
notify_on_error = false,
format_on_save = function(bufnr)
local disable_filetypes = { c = true, cpp = true, sh = true }
return {
timeout_ms = 500,
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
}
end,
formatters_by_ft = {
lua = { 'stylua' },
python = { 'pyright', 'isort', 'black' },
md = { 'prettier' },
nix = { 'nixfmt' },
yaml = { 'yamlfmt' },
sh = { 'shfmt' },
},
},
},
}

14
lua/plugins/gitsigns.lua Normal file
View File

@ -0,0 +1,14 @@
return {
{ -- Add git changes to gutter
'lewis6991/gitsigns.nvim',
opts = {
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
},
},
},
}

View File

@ -0,0 +1,3 @@
return {
'tpope/vim-sleuth',
}

153
lua/plugins/lsp.lua Normal file
View File

@ -0,0 +1,153 @@
return {
{
'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',
dependencies = {
-- Automatically install LSPs and related tools to stdpath for Neovim
{ 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants
'williamboman/mason-lspconfig.nvim',
'WhoIsSethDaniel/mason-tool-installer.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()
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
callback = function(event)
local map = function(keys, func, desc)
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
map('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
map('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
-- :help CursorHold
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
-- Inlay hints
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
map('<leader>th', function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
end, '[T]oggle Inlay [H]ints')
end
end,
})
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())
local servers = {
clangd = {},
pyright = {},
black = {},
isort = {},
taplo = {},
-- rust_analyzer = {},
lua_ls = {
-- cmd = {...},
-- filetypes = { ...},
-- capabilities = {},
settings = {
Lua = {
completion = {
callSnippet = 'Replace',
},
},
},
},
}
-- Ensure the servers and tools above are installed
-- :Mason
require('mason').setup()
-- 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, {
'bashls', -- bash
'black', -- python format
'cmake', -- cmake
'clangd', -- cpp
'debugpy', -- debugger
'dockerls', -- docker
'golangci-lint', -- go
'isort', -- python sorting
'jedi-language-server', -- jedi completion
'jsonls', -- json
'lua_ls', -- lua
'marksman', -- markdown
'mypy', -- python checking
'nixpkgs-fmt', -- Nix
'prettier', -- md
'pyright', -- python lsp
'ruff', -- lint and format for python
'rust-analyzer', -- rust
'shfmt', -- shell
'stylua', -- Used to format Lua code
'taplo', -- LSP for toml files
'tree-sitter-cli', -- treesitter
'ts_ls', -- typescript
'yamllint', -- yaml
'yamlfmt', -- yaml
'yamlls', -- yaml
})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
require('mason-lspconfig').setup {
handlers = {
function(server_name)
local server = servers[server_name] or {}
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
require('lspconfig')[server_name].setup(server)
end,
},
}
end,
},
}

28
lua/plugins/misc.lua Normal file
View File

@ -0,0 +1,28 @@
return {
{
'echasnovski/mini.nvim',
config = function()
-- Better Around/Inside textobjects
--
-- Examples:
-- - va) - [V]isually select [A]round [)]paren
-- - yinq - [Y]ank [I]nside [N]ext [Q]uote
-- - ci' - [C]hange [I]nside [']quote
require('mini.ai').setup { n_lines = 500 }
-- Add/delete/replace surroundings (brackets, quotes, etc.)
--
-- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
-- - sd' - [S]urround [D]elete [']quotes
-- - sr)' - [S]urround [R]eplace [)] [']
require('mini.surround').setup()
local statusline = require 'mini.statusline'
statusline.setup { use_icons = vim.g.have_nerd_font }
---@diagnostic disable-next-line: duplicate-set-field
statusline.section_location = function()
return '%2l:%-2v'
end
end,
},
}

View File

@ -0,0 +1,6 @@
return {
{ -- Emacs-style keybindings in insert mode
'millerjason/neovimacs.nvim',
opts = {},
},
}

24
lua/plugins/tabnine.lua Normal file
View File

@ -0,0 +1,24 @@
return {
'codota/tabnine-nvim',
name = 'tabnine',
build = './dl_binaries.sh',
config = function()
require('tabnine').setup {
disable_auto_comment = true,
accept_keymap = '<Tab>',
dismiss_keymap = '<C-]>',
debounce_ms = 800,
suggestion_color = { gui = '#808080', cterm = 244 },
exclude_filetypes = { 'TelescopePrompt', 'NvimTree' },
log_file_path = nil,
ignore_certificate_errors = false,
}
require('tabnine.status').disable_tabnine()
end,
lazy = false,
keys = {
{ '<leader>lc', '<cmd>TabnineChat<cr>', desc = '[L]LM [C]hat' },
{ '<leader>lt', '<cmd>TabnineToggle<cr>', desc = '[L]LM [T]oggle' },
{ '<leader>ls', '<cmd>TabnineStatus<cr>', desc = '[L]LM [S]tatus' },
},
}

78
lua/plugins/telescope.lua Normal file
View File

@ -0,0 +1,78 @@
return {
{
'nvim-telescope/telescope.nvim',
event = 'VimEnter',
branch = '0.1.x',
dependencies = {
'nvim-lua/plenary.nvim',
{
'nvim-telescope/telescope-fzf-native.nvim',
build = 'make',
cond = function()
return vim.fn.executable 'make' == 1
end,
},
{ 'nvim-telescope/telescope-ui-select.nvim' },
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
},
config = function()
require('telescope').setup {
-- defaults = {
-- mappings = {
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
-- },
-- },
-- pickers = {}
extensions = {
['ui-select'] = {
require('telescope.themes').get_dropdown(),
},
},
}
-- Enable Telescope extensions if they are installed
pcall(require('telescope').load_extension, 'fzf')
pcall(require('telescope').load_extension, 'ui-select')
-- See `:help telescope.builtin`
local builtin = require 'telescope.builtin'
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Find [F]iles' })
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Find [G]rep' })
vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = 'Find [B]uffers' })
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = 'Find [H]elp tags' })
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
-- Slightly advanced example of overriding default behavior and theme
vim.keymap.set('n', '<leader>/', function()
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10,
previewer = false,
})
end, { desc = '[/] Fuzzily search in current buffer' })
-- Prompting
vim.keymap.set('n', '<leader>fG', function()
builtin.grep_string { search = vim.fn.input 'grep> ' }
end)
-- It's also possible to pass additional configuration options.
-- See `:help telescope.builtin.live_grep()` for information about particular keys
vim.keymap.set('n', '<leader>s/', function()
builtin.live_grep {
grep_open_files = true,
prompt_title = 'Live Grep in Open Files',
}
end, { desc = '[S]earch [/] in Open Files' })
end,
},
}

3
lua/plugins/todo.lua Normal file
View File

@ -0,0 +1,3 @@
return {
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
}

View File

@ -0,0 +1,51 @@
return {
{
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
opts = {
ensure_installed = {
'bash',
'c',
'cmake',
'cpp',
'css',
'cuda',
'diff',
'dockerfile',
'dot',
'go',
'gomod',
'html',
'java',
'javascript',
'json',
'json5',
'latex',
'llvm',
'lua',
'luadoc',
'make',
'markdown',
'markdown_inline',
'nix',
'python',
'query',
'rst',
'toml',
'vim',
'vimdoc',
'yaml',
},
auto_install = true,
highlight = {
enable = true,
additional_vim_regex_highlighting = { 'ruby' },
},
indent = { enable = true, disable = { 'ruby' } },
},
config = function(_, opts)
---@diagnostic disable-next-line: missing-fields
require('nvim-treesitter.configs').setup(opts)
end,
},
}

17
lua/plugins/venv.lua Normal file
View File

@ -0,0 +1,17 @@
return {
'linux-cultist/venv-selector.nvim',
branch = 'regexp',
dependencies = {
'neovim/nvim-lspconfig',
'mfussenegger/nvim-dap',
'mfussenegger/nvim-dap-python',
'nvim-telescope/telescope.nvim',
},
lazy = false,
config = function()
require('venv-selector').setup()
end,
keys = {
{ ',v', '<cmd>VenvSelect<cr>' },
},
}

19
lua/plugins/which-key.lua Normal file
View File

@ -0,0 +1,19 @@
return {
{ -- Shows keybindings as you go
'folke/which-key.nvim',
event = 'VimEnter',
config = function()
require('which-key').setup()
-- Document existing key chains
require('which-key').add {
{ '<leader>c', group = '[C]ode' },
{ '<leader>d', group = '[D]ocument' },
{ '<leader>r', group = '[R]ename' },
{ '<leader>s', group = '[S]earch' },
{ '<leader>w', group = '[W]orkspace' },
{ '<leader>t', group = '[T]oggle' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
}
end,
},
}