Compare commits

..

14 Commits

Author SHA1 Message Date
73e1f58a5a Merge branch 'nvim-lua-master' 2024-02-27 14:40:04 +01:00
403077873f Merge branch 'master' of https://github.com/nvim-lua/kickstart.nvim into nvim-lua-master 2024-02-27 14:38:33 +01:00
TJ DeVries
af4fd2355f fixup: change comment to reflect auto_install 2024-02-26 10:46:31 -05:00
TJ DeVries
1c89b024c8 fixup: add autocommand link for help and description 2024-02-26 10:45:32 -05:00
TJ DeVries
8b5d48a199
rewrite: slimmer, trimmer and more lazy kickstart.nvim (#635)
We've removed over 1/3 of the code that was in kickstart previously,
and more than doubled the amount of comments explaining every line
of code (to the best of my ability).

kickstart now properly uses many of the lazy.nvim config and loading
idioms, which should be really helpful for people moving both to
modular configs, as well as extending the kickstart config in one file.

Additional features:
- Beautiful ascii art
- Added some documentation that explains what is an LSP, what is telescope, etc
- There is now a `:checkhealth` for kickstart, which checks some basic information
  and adds useful information for maintainers (for people cloning the repo).
- Improved LSP configuration and tool installation, for easier first time startup
- Changed init.lua ordering, so that it moves from simple options to complicated config

```
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Lua                              1            108            404            298
-------------------------------------------------------------------------------
```
2024-02-26 10:03:53 -05:00
3174961292 manual dap config, using nodejs 2024-02-15 11:19:41 +01:00
89e841b55f enable builtint debug blugin 2024-02-15 11:17:24 +01:00
c9ac476031 refactor: auto format 2024-02-15 11:17:04 +01:00
rgarber11
7af594fd31
Add Build Step to LuaSnip (#611) 2024-02-05 13:49:19 -05:00
Chris Patti
5d2d81b1ea
Fixes #607. Add hints for new neovim users to learn how to learn. (#615) 2024-02-03 19:15:25 -05:00
Micah Effiong
bc4ad1218b
feat: added contexts for code action - source fix-all errors (#599)
* feat: added contexts for code action - source fix-all errors

* fix: resolve stylua checks

* fix: resolve stylua checks
2024-02-02 15:24:46 -05:00
Damjan 9000
c3ae716fb3
issue: #594 stylua workflow only on official kickstart repo (#609)
Only run the github stylua workflow check on the official
kickstart repo (nvim-lua/kickstart.nvim) so that it's not
enforced on any other forks.
As suggested by: @zwergius
2024-02-01 11:01:46 -05:00
Nazar
b115814916
Add Onedark Style (#590)
* Add style options to Onedark setup (init.lua)

* stylua init.lua

* Load onedark through `require`

* Improve commenting
2024-01-29 13:52:50 -05:00
Victor Bertin
deaafcf549
Set status line theme to the global colorscheme (#600) 2024-01-29 07:48:14 -05:00
14 changed files with 376 additions and 164 deletions

View File

@ -4,6 +4,7 @@ on: pull_request_target
jobs:
stylua-check:
if: github.repository == 'nvim-lua/kickstart.nvim'
name: Stylua Check
runs-on: ubuntu-latest
steps:

2
.gitignore vendored
View File

@ -2,4 +2,6 @@ tags
test.sh
.luarc.json
nvim
spell/
lazy-lock.json

View File

@ -11,15 +11,32 @@ cmp.setup {
luasnip.lsp_expand(args.body)
end,
},
completion = {
completeopt = 'menu,menuone,noinsert',
},
completion = { completeopt = 'menu,menuone,noinsert' },
-- For an understanding of why these mappings were
-- chosen, you will need to read `:help ins-completion`
--
-- No, but seriously. Please read `:help ins-completion`, it is really good!
mapping = cmp.mapping.preset.insert {
-- Select the [n]ext item
['<C-n>'] = cmp.mapping.select_next_item(),
-- Select the [p]revious item
['<C-p>'] = cmp.mapping.select_prev_item(),
-- Accept ([y]es) the completion.
-- This will auto-import if your LSP supports it.
-- This will expand snippets if the LSP sent a snippet.
['<C-y>'] = cmp.mapping.confirm { select = true },
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
-- Manually trigger a completion from nvim-cmp.
-- Generally you don't need this, because nvim-cmp will display
-- completions whenever it has completion options available.
['<C-Space>'] = cmp.mapping.complete {},
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
@ -42,6 +59,25 @@ cmp.setup {
fallback()
end
end, { 'i', 's' }),
-- Think of <c-l> as moving to the right of your snippet expansion.
-- So if you have a snippet that's like:
-- function $name($args)
-- $body
-- end
--
-- <c-l> will move you to the right of each of the expansion locations.
-- <c-h> is similar, except moving you backwards.
['<C-l>'] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
end
end, { 'i', 's' }),
['<C-h>'] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
end
end, { 'i', 's' }),
},
sources = {
{ name = 'nvim_lsp' },

View File

@ -14,15 +14,30 @@ vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnos
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
-- [[ Highlight on yank ]]
-- See `:help vim.highlight.on_yank()`
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
-- Disable arrow keys in normal mode
vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')
-- Keybinds to make split navigation easier.
-- 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' })
-- Highlight when yanking (copying) text
-- Try it with `yap` in normal mode
-- See `:help vim.highlight.on_yank()`
vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text',
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
callback = function()
vim.highlight.on_yank()
end,
group = highlight_group,
pattern = '*',
})
-- vim: ts=2 sts=2 sw=2 et

51
lua/kickstart/health.lua Normal file
View File

@ -0,0 +1,51 @@
--[[
--
-- This file is not required for your own configuration,
-- but helps people determine if their system is setup correctly.
--
--]]
local check_version = function()
if not vim.version.cmp then
vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", tostring(vim.version())))
return
end
if vim.version.cmp(vim.version(), { 0, 9, 4 }) >= 0 then
vim.health.ok(string.format("Neovim version is: '%s'", tostring(vim.version())))
else
vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", tostring(vim.version())))
end
end
local check_external_reqs = function()
-- Basic utils: `git`, `make`, `unzip`
for _, exe in ipairs { 'git', 'make', 'unzip', 'rg' } do
local is_executable = vim.fn.executable(exe) == 1
if is_executable then
vim.health.ok(string.format("Found executable: '%s'", exe))
else
vim.health.warn(string.format("Could not find executable: '%s'", exe))
end
end
return true
end
return {
check = function()
vim.health.start 'kickstart.nvim'
vim.health.info [[NOTE: Not every warning is a 'must-fix' in `:checkhealth`
Fix only warnings for plugins and languages you intend to use.
Mason will give warnings for languages that are not installed.
You do not need to install, unless you want to use those languages!]]
local uv = vim.uv or vim.loop
vim.health.info('System Information: ' .. vim.inspect(uv.os_uname()))
check_version()
check_external_reqs()
end,
}

View File

@ -1,59 +0,0 @@
-- Uses installed LSP servers to automatically format code on save.
return {
'neovim/nvim-lspconfig',
config = function()
-- Switch for controlling whether you want autoformatting.
local format_is_enabled = true
vim.api.nvim_create_user_command('KickstartFormatToggle', function()
format_is_enabled = not format_is_enabled
print('Setting autoformatting to: ' .. tostring(format_is_enabled))
end, {})
-- Create an augroup that is used for managing our formatting autocmds.
local _augroups = {}
local get_augroup = function(client)
if not _augroups[client.id] then
local group_name = 'kickstart-lsp-format-' .. client.name
local id = vim.api.nvim_create_augroup(group_name, { clear = true })
_augroups[client.id] = id
end
return _augroups[client.id]
end
-- Whenever an LSP attaches to a buffer, we will run this function.
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }),
-- This is where we attach the autoformatting for reasonable clients
callback = function(args)
local client_id = args.data.client_id
local client = vim.lsp.get_client_by_id(client_id)
local bufnr = args.buf
-- Only attach to clients that support document formatting
if not client.server_capabilities.documentFormattingProvider then
return
end
-- Create an autocmd that will run *before* we save the buffer.
vim.api.nvim_create_autocmd('BufWritePre', {
group = get_augroup(client),
buffer = bufnr,
callback = function()
if not format_is_enabled then
return
end
vim.lsp.buf.format {
async = false,
filter = function(c)
return c.id == client.id
end,
}
end,
})
end,
})
end,
}

View File

@ -16,11 +16,11 @@ return {
local dapui = require 'dapui'
require('mason-nvim-dap').setup {
automatic_setup = true,
automatic_setup = false,
handlers = {},
-- Installed language debuggers
ensure_installed = {
'delve',
'node-debug2-adapter',
},
}
@ -61,6 +61,6 @@ return {
dap.listeners.before.event_exited['dapui_config'] = dapui.close
-- Install golang specific config
require('dap-go').setup()
-- require('dap-go').setup()
end,
}

View File

@ -0,0 +1,9 @@
return {
{ -- Add indentation guides even on blank lines
'lukas-reineke/indent-blankline.nvim',
-- Enable `lukas-reineke/indent-blankline.nvim`
-- See `:help ibl`
main = 'ibl',
opts = {},
},
}

View File

@ -3,15 +3,16 @@
-- `:help lazy.nvim.txt` for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
vim.fn.system {
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable', -- latest stable release
lazypath,
'--branch=stable',
lazyrepo,
lazypath
}
end
end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath)
-- vim: ts=2 sts=2 sw=2 et

View File

@ -1,9 +1,14 @@
-- [[ Configure plugins ]]
-- NOTE: Here is where you install your plugins.
-- You can configure plugins using the `config` key.
-- [[ Configure and install plugins ]]
--
-- You can also configure plugins after the setup call,
-- as they will be available in your neovim runtime.
-- To check the current status of your plugins, run
-- :Lazy
--
-- You can press `?` in this menu for help. Use `:q` to close the window
--
-- To update plugins, you can run
-- :Lazy update
--
-- NOTE: Here is where you install your plugins.
require('lazy').setup({
-- NOTE: First, some plugins that don't require any configuration
-- Discord RPC
@ -19,15 +24,14 @@ require('lazy').setup({
-- Detect tabstop and shiftwidth automatically
'tpope/vim-sleuth',
-- NOTE: This is where your plugins related to LSP can be installed.
-- The configuration is done below. Search for lspconfig to find it below.
{
-- LSP Configuration & Plugins
'neovim/nvim-lspconfig',
dependencies = {
-- Automatically install LSPs to stdpath for neovim
{ 'williamboman/mason.nvim', config = true },
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
'WhoIsSethDaniel/mason-tool-installer.nvim',
-- Useful status updates for LSP
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
@ -43,7 +47,18 @@ require('lazy').setup({
'hrsh7th/nvim-cmp',
dependencies = {
-- Snippet Engine & its associated nvim-cmp source
'L3MON4D3/LuaSnip',
{
'L3MON4D3/LuaSnip',
build = (function()
-- Build Step is needed for regex support in snippets
-- This step is not supported in many windows environments
-- Remove the below condition to re-enable on windows
if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then
return
end
return 'make install_jsregexp'
end)(),
},
'saadparwaiz1/cmp_luasnip',
-- Adds LSP completion capabilities
@ -56,7 +71,22 @@ require('lazy').setup({
},
-- Useful plugin to show you pending keybinds.
{ 'folke/which-key.nvim', opts = {} },
{
'folke/which-key.nvim',
event = 'VeryLazy', -- Sets the loading event to 'VeryLazy'
config = function() -- This is the function that runs, AFTER loading
require('which-key').setup()
-- Document existing key chains
require('which-key').register {
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
}
end,
},
{
-- Adds git related signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',
@ -133,43 +163,82 @@ require('lazy').setup({
},
{
-- Theme inspired by Atom
'navarasu/onedark.nvim',
priority = 1000,
config = function()
vim.cmd.colorscheme 'onedark'
end,
},
{
-- Set lualine as statusline
'nvim-lualine/lualine.nvim',
-- See `:help lualine.txt`
-- Autoformat
'stevearc/conform.nvim',
opts = {
options = {
icons_enabled = false,
theme = 'onedark',
component_separators = '|',
section_separators = '',
notify_on_error = false,
format_on_save = {
timeout_ms = 500,
lsp_fallback = true,
},
formatters_by_ft = {
lua = { 'stylua' },
-- Conform can also run multiple formatters sequentially
python = { "isort", "black" },
--
-- You can use a sub-list to tell conform to run *until* a formatter
-- is found.
javascript = { { "prettierd", "prettier" } },
},
},
},
{
-- Add indentation guides even on blank lines
'lukas-reineke/indent-blankline.nvim',
-- Enable `lukas-reineke/indent-blankline.nvim`
-- See `:help ibl`
main = 'ibl',
opts = {},
-- You can easily change to a different colorscheme.
-- Change the name of the colorscheme plugin below, and then
-- change the command in the config to whatever the name of that colorscheme is
--
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`
'folke/tokyonight.nvim',
lazy = false, -- make sure we load this during startup if it is your main colorscheme
priority = 1000, -- make sure to load this before all the other start plugins
config = function()
-- Load the colorscheme here
vim.cmd.colorscheme 'tokyonight-night'
-- You can configure highlights by doing something like
vim.cmd.hi 'Comment gui=none'
end,
},
-- Highlight todo, notes, etc in comments
{ 'folke/todo-comments.nvim', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
-- "gc" to comment visual regions/lines
{ 'numToStr/Comment.nvim', opts = {} },
{ 'numToStr/Comment.nvim', opts = {} },
-- Fuzzy Finder (files, lsp, etc)
{
-- Collection of various small independent plugins/modules
'echasnovski/mini.nvim',
config = function()
-- Better Around/Inside textobjects
--
-- Examples:
-- - va) - [V]isually select [A]round [)]parenthen
-- - yinq - [Y]ank [I]nside [N]ext [']quote
-- - 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()
-- Simple and easy statusline.
-- You could remove this setup call if you don't like it,
-- and try some other statusline plugin
require('mini.statusline').setup()
-- ... and there is more!
-- Check out: https://github.com/echasnovski/mini.nvim
end,
},
{
-- Fuzzy Finder (files, lsp, etc)
'nvim-telescope/telescope.nvim',
event = 'VeryLazy',
branch = '0.1.x',
dependencies = {
'nvim-lua/plenary.nvim',
@ -177,12 +246,26 @@ require('lazy').setup({
-- Only load if `make` is available. Make sure you have the system
-- requirements installed.
{
-- If encountering errors, see telescope-fzf-native README for install instructions
'nvim-telescope/telescope-fzf-native.nvim',
-- NOTE: If you are having trouble with this installation,
-- refer to the README for telescope-fzf-native for more instructions.
-- `build` is used to run some command when the plugin is installed/updated.
-- This is only run then, not every time Neovim starts up.
build =
'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release; cmake --build build --config Release; cmake --install build --prefix build',
-- `cond` is a condition used to determine whether this plugin should be
-- installed and loaded.
cond = function()
return vim.fn.executable 'make' == 1
end,
},
{ 'nvim-telescope/telescope-ui-select.nvim' },
-- Useful for getting pretty icons, but requires special font.
-- If you already have a Nerd Font, or terminal set up with fallback fonts
-- you can enable this
{ 'nvim-tree/nvim-web-devicons' }
},
},
@ -195,18 +278,24 @@ require('lazy').setup({
build = ':TSUpdate',
},
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
-- These are some example plugins that I've included in the kickstart repository.
-- Uncomment any of the lines below to enable them.
require 'kickstart.plugins.autoformat',
-- require 'kickstart.plugins.debug',
-- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the
-- init.lua. If you want these files, they are in the repository, so you can just download them and
-- put them in the right spots if you want.
-- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for kickstart
--
-- Here are some example plugins that I've included in the kickstart repository.
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
require 'kickstart.plugins.indent_line',
require 'kickstart.plugins.health',
require 'kickstart.plugins.debug',
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping
-- up-to-date with whatever is in the kickstart repo.
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
-- This is the easiest way to modularize your config.
--
-- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
-- For additional information see: :help lazy.nvim-lazy.nvim-structuring-your-plugins
-- { import = 'custom.plugins' },
}, {})

View File

@ -1,6 +1,10 @@
-- [[ Configure LSP ]]
-- This function gets run when an LSP connects to a particular buffer.
local on_attach = function(_, bufnr)
-- See `:help telescope.builtin`
local builtin = require 'telescope.builtin'
local on_attach = function(client, bufnr)
-- 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
-- many times.
@ -18,12 +22,12 @@ local on_attach = function(_, bufnr)
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
nmap('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
nmap('gd', builtin.lsp_definitions, '[G]oto [D]efinition')
nmap('gr', builtin.lsp_references, '[G]oto [R]eferences')
nmap('gI', builtin.lsp_implementations, '[G]oto [I]mplementation')
nmap('<leader>D', builtin.lsp_type_definitions, 'Type [D]efinition')
nmap('<leader>ds', builtin.lsp_document_symbols, '[D]ocument [S]ymbols')
nmap('<leader>ws', builtin.lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
-- See `:help K` for why this keymap
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
@ -41,6 +45,23 @@ local on_attach = function(_, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format()
end, { desc = 'Format current buffer with LSP' })
-- 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).
if client and client.server_capabilities.documentHighlightProvider then
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = event.buf,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
buffer = event.buf,
callback = vim.lsp.buf.clear_references,
})
end
end
-- document existing key chains
@ -82,9 +103,19 @@ local servers = {
svelte = {},
lua_ls = {
Lua = {
workspace = { checkThirdParty = false },
runtime = { version = 'LuaJIT' },
workspace = {
checkThirdParty = false,
-- Tells lua_ls where to find all the Lua files that you have loaded
-- for your neovim configuration.
library = {
'${3rd}/luv/library',
unpack(vim.api.nvim_get_runtime_file('', true)),
},
-- If lua_ls is really slow on your computer, you can try this instead:
-- library = { vim.env.VIMRUNTIME },
},
telemetry = { enable = false },
-- diagnostics = { disable = { 'missing-fields' } },
},
},
}
@ -94,24 +125,33 @@ require('neodev').setup()
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())
-- Ensure the servers above are installed
local mason_lspconfig = require 'mason-lspconfig'
-- 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
})
mason_lspconfig.setup {
ensure_installed = vim.tbl_keys(servers),
}
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
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,
require('mason-lspconfig').setup {
handlers = {
function(server_name)
local server = servers[server_name] or {}
require('lspconfig')[server_name].setup {
cmd = server.cmd,
on_attach = on_attach,
settings = server.settings,
filetypes = server.filetypes,
-- 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)
capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}),
}
end,
}
}
-- vim: ts=2 sts=2 sw=2 et

View File

@ -33,8 +33,9 @@ vim.o.wrap = false
-- Search
vim.o.scrolloff = 8
-- Set highlight on search
vim.o.hlsearch = false
-- Set highlight on search, but clear on pressing <Esc> in normal mode
vim.o.hlsearch = true
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- Make line numbers default
vim.wo.number = true
@ -42,6 +43,9 @@ vim.wo.number = true
-- Enable mouse mode
vim.o.mouse = 'a'
-- Don't show the mode, since it's already in status line
vim.o.showmode = false
-- Sync clipboard between OS and Neovim.
-- Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'`
@ -70,4 +74,14 @@ vim.o.completeopt = 'menuone,noselect'
-- NOTE: You should make sure your terminal supports this
vim.o.termguicolors = true
-- Configure how new splits should be opened
vim.o.splitright = true
vim.o.splitbelow = true
-- Preview substitutions live, as you type!
vim.o.inccommand = 'split'
-- Show which line your cursor is on
vim.opt.cursorline = true
-- vim: ts=2 sts=2 sw=2 et

View File

@ -3,16 +3,22 @@
require('telescope').setup {
defaults = {
mappings = {
i = {
['<C-u>'] = false,
['<C-d>'] = false,
},
i = { ['<c-enter>'] = 'to_fuzzy_refine' },
},
},
extensions = {
['ui-select'] = {
require('telescope.themes').get_dropdown(),
},
},
}
-- Enable telescope fzf native, if installed
-- 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'
-- Telescope live_grep in git root
-- Function to find the git root directory based on the current buffer's path
@ -42,7 +48,7 @@ end
local function live_grep_git_root()
local git_root = find_git_root()
if git_root then
require('telescope.builtin').live_grep {
builtin.live_grep {
search_dirs = { git_root },
}
end
@ -51,31 +57,37 @@ end
vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {})
-- See `:help telescope.builtin`
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
vim.keymap.set('n', '<leader>?', builtin.oldfiles, { desc = '[?] Find recently opened files' })
vim.keymap.set('n', '<leader><space>', builtin.buffers, { desc = '[ ] Find existing buffers' })
vim.keymap.set('n', '<leader>/', function()
-- You can pass additional configuration to telescope to change theme, layout, etc.
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10,
previewer = false,
})
end, { desc = '[/] Fuzzily search in current buffer' })
local function telescope_live_grep_open_files()
require('telescope.builtin').live_grep {
builtin.live_grep {
grep_open_files = true,
prompt_title = 'Live Grep in Open Files',
}
end
vim.keymap.set('n', '<leader>s/', telescope_live_grep_open_files, { desc = '[S]earch [/] in Open Files' })
vim.keymap.set('n', '<leader>ss', require('telescope.builtin').builtin, { desc = '[S]earch [S]elect Telescope' })
vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
vim.keymap.set('n', '<leader>gf', builtin.git_files, { desc = 'Search [G]it [F]iles' })
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
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>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>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
vim.keymap.set('n', '<leader>sG', ':LiveGrepGitRoot<cr>', { desc = '[S]earch by [G]rep on Git Root' })
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' })
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' })
-- Shortcut for searching your neovim configuration files
vim.keymap.set('n', '<leader>sn', function()
builtin.find_files { cwd = vim.fn.stdpath 'config' }
end, { desc = '[S]earch [N]eovim files' })
-- vim: ts=2 sts=2 sw=2 et

View File

@ -2,6 +2,7 @@
-- See `:help nvim-treesitter`
-- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}'
vim.defer_fn(function()
---@diagnostic disable-next-line: missing-fields
require('nvim-treesitter.configs').setup {
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = { 'lua', 'python', 'rust', 'javascript', 'typescript', 'vimdoc', 'vim', 'svelte', 'c_sharp' },