Skip to content
Closed

Test #1856

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
215 changes: 129 additions & 86 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' '

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

-- [[ Setting options ]]
-- See `:help vim.o`
Expand All @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
vim.o.number = true
-- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it!
-- vim.o.relativenumber = true
vim.o.relativenumber = true

-- Enable mouse mode, can be useful for resizing splits for example!
vim.o.mouse = 'a'
Expand Down Expand Up @@ -146,9 +146,16 @@ vim.o.splitbelow = true
-- Notice listchars is set using `vim.opt` instead of `vim.o`.
-- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables.
-- See `:help lua-options`
-- and `:help lua-guide-options`
vim.o.list = true
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
-- and `:help lua-options-guide`
vim.o.list = false
vim.o.autoindent = true -- Enable auto-indentation
vim.o.smartindent = true -- Enable smart indentation
vim.o.cindent = false -- Disable C-style indentation
vim.o.expandtab = true -- Ensure tabs are converted to spaces
vim.o.shiftwidth = 3 -- Set indentation width to 3 spaces
vim.o.tabstop = 3 -- One space per tab
vim.o.softtabstop = 3
--vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }

-- Preview substitutions live, as you type!
vim.o.inccommand = 'split'
Expand Down Expand Up @@ -180,7 +187,7 @@ vim.diagnostic.config {
underline = { severity = vim.diagnostic.severity.ERROR },

-- Can switch between these as you prefer
virtual_text = true, -- Text shows up at the end of the line
virtual_text = true, -- Text shows up at the end of the line
virtual_lines = false, -- Teest shows up underneath the line, with virtual lines

-- Auto open the float, so you can easily read the errors when jumping with `[d` and `]d`
Expand Down Expand Up @@ -310,7 +317,7 @@ require('lazy').setup({

-- Document existing key chains
spec = {
{ '<leader>s', group = '[S]earch', mode = { 'n', 'v' } },
{ '<leader>s', group = '[S]earch', mode = { 'n', 'v' } },
{ '<leader>t', group = '[T]oggle' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
},
Expand Down Expand Up @@ -353,7 +360,7 @@ require('lazy').setup({
{ 'nvim-telescope/telescope-ui-select.nvim' },

-- Useful for getting pretty icons, but requires a Nerd Font.
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
{ 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font },
},
config = function()
-- Telescope is a fuzzy finder that comes with a lot of different things that
Expand Down Expand Up @@ -435,7 +442,8 @@ require('lazy').setup({

-- Fuzzy find all the symbols in your current workspace.
-- Similar to document symbols, except searches over your entire project.
vim.keymap.set('n', 'gW', builtin.lsp_dynamic_workspace_symbols, { buffer = buf, desc = 'Open Workspace Symbols' })
vim.keymap.set('n', 'gW', builtin.lsp_dynamic_workspace_symbols,
{ buffer = buf, desc = 'Open Workspace Symbols' })

-- 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
Expand Down Expand Up @@ -468,7 +476,8 @@ require('lazy').setup({
)

-- 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.keymap.set('n', '<leader>sn', function() builtin.find_files { cwd = vim.fn.stdpath 'config' } end,
{ desc = '[S]earch [N]eovim files' })
end,
},

Expand All @@ -484,7 +493,7 @@ require('lazy').setup({
'WhoIsSethDaniel/mason-tool-installer.nvim',

-- Useful status updates for LSP.
{ 'j-hui/fidget.nvim', opts = {} },
{ 'j-hui/fidget.nvim', opts = {} },

-- Allows extra capabilities provided by blink.cmp
'saghen/blink.cmp',
Expand Down Expand Up @@ -578,7 +587,9 @@ require('lazy').setup({
--
-- This may be unwanted, since they displace some of your code
if client and client:supports_method('textDocument/inlayHint', event.buf) 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')
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,
})
Expand All @@ -593,66 +604,78 @@ require('lazy').setup({
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
-- See `:help lsp-config` for information about keys and how to configure
local servers = {
-- clangd = {},
-- gopls = {},
-- pyright = {},
-- rust_analyzer = {},
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 (`ts_ls`) will work just fine
-- ts_ls = {},
ts_ls = {},
--

lua_ls = {
-- cmd = { ... },
-- filetypes = { ... },
-- capabilities = {},
settings = {
Lua = {
completion = {
callSnippet = 'Replace',
},
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
diagnostics = { disable = { 'missing-fields' } },
},
},
on_init = function(client)
if client.workspace_folders then
local path = client.workspace_folders[1].name
if path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) then return end
end

client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
runtime = {
version = 'LuaJIT',
path = { 'lua/?.lua', 'lua/?/init.lua' },
},
workspace = {
checkThirdParty = false,
-- NOTE: this is a lot slower and will cause issues when working on your own configuration.
-- See https://github.com/neovim/nvim-lspconfig/issues/3189
library = vim.api.nvim_get_runtime_file('', true),
},
})
end,
},
}

-- 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.
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
'lua_ls', -- Lua Language server
'stylua', -- Used to format Lua code
-- You can add other tools here that you want Mason to install
})

-- Map LSP names to Mason names if they differ
local package_mapping = {
rust_analyzer = 'rust-analyzer',
ts_ls = 'typescript-language-server',
lua_ls = 'lua-language-server',
}
for i, name in ipairs(ensure_installed) do
if package_mapping[name] then ensure_installed[i] = package_mapping[name] end
end

require('mason-tool-installer').setup { ensure_installed = ensure_installed }

for name, server in pairs(servers) do
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
vim.lsp.config(name, server)
vim.lsp.enable(name)
end

-- Special Lua Config, as recommended by neovim help docs
vim.lsp.config('lua_ls', {
on_init = function(client)
if client.workspace_folders then
local path = client.workspace_folders[1].name
if path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) then return end
end

client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
runtime = {
version = 'LuaJIT',
path = { 'lua/?.lua', 'lua/?/init.lua' },
},
workspace = {
checkThirdParty = false,
-- NOTE: this is a lot slower and will cause issues when working on your own configuration.
-- See https://github.com/neovim/nvim-lspconfig/issues/3189
library = vim.api.nvim_get_runtime_file('', true),
},
})
end,
settings = {
Lua = {},
},
})
vim.lsp.enable 'lua_ls'
end,
},

Expand Down Expand Up @@ -740,8 +763,9 @@ require('lazy').setup({
-- For an understanding of why the 'default' preset is recommended,
-- you will need to read `:help ins-completion`
--
-- No, but seriously. Please read `:help ins-completion`, it is really good!
--
['<Tab>'] = { 'select_next' }, -- Tab selects next item
['<S-Tab>'] = { 'select_prev' }, -- Shift+Tab selects previous
['<CR>'] = { 'select_and_accept', 'fallback' },
-- All presets have the following mappings:
-- <tab>/<s-tab>: move to right/left of your snippet expansion
-- <c-space>: Open menu or open docs if already open
Expand All @@ -766,6 +790,11 @@ require('lazy').setup({
-- By default, you may press `<c-space>` to show the documentation.
-- Optionally, set `auto_show = true` to show the documentation after a delay.
documentation = { auto_show = false, auto_show_delay_ms = 500 },
menu = {
draw = {
columns = { { 'label', 'label_description', gap = 1 } },
},
},
},

sources = {
Expand All @@ -787,31 +816,30 @@ require('lazy').setup({
signature = { enabled = true },
},
},

{ -- 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',
priority = 1000, -- Make sure to load this before all the other start plugins.
-- {
-- 'ellisonleao/gruvbox.nvim',
-- priority = 1000, -- make sure to load this before all the other start plugins
-- config = function()
-- require('gruvbox').setup {
-- style = 'dark',
-- }
-- Enable theme
-- require('gruvbox').load()
-- end,
-- },
-- Or with configuration
{
'rebelot/kanagawa.nvim',
priority = 1000,
config = function()
---@diagnostic disable-next-line: missing-fields
require('tokyonight').setup {
styles = {
comments = { italic = false }, -- Disable italics in comments
},
require('kanagawa').setup {
commentStyle = { italic = false },
keywordStyle = { italic = false },
}

-- Load the colorscheme here.
-- Like many other themes, this one has different styles, and you could load
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
vim.cmd.colorscheme 'tokyonight-night'
vim.cmd.colorscheme 'kanagawa-wave'
end,
},

-- Highlight todo, notes, etc in comments
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },

{ -- Collection of various small independent plugins/modules
'nvim-mini/mini.nvim',
Expand Down Expand Up @@ -851,14 +879,29 @@ require('lazy').setup({

{ -- Highlight, edit, and navigate code
'nvim-treesitter/nvim-treesitter',
config = function()
local filetypes = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }
require('nvim-treesitter').install(filetypes)
vim.api.nvim_create_autocmd('FileType', {
pattern = filetypes,
callback = function() vim.treesitter.start() end,
})
end,
build = ':TSUpdate',
branch = 'master', -- Add this to stay on the stable branch
-- main = 'nvim-treesitter.configs',
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
opts = {
ensure_installed = { 'bash', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
-- Autoinstall languages that are not installed
auto_install = true,
highlight = {
enable = true,
-- 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' },
},
indent = { enable = true, disable = { 'ruby' } },
},
-- There are additional nvim-treesitter modules that you can use to interact
-- with nvim-treesitter. You should go explore a few and see what interests you:
--
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
},

-- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
Expand All @@ -871,11 +914,11 @@ require('lazy').setup({
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
--
-- require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint',
-- require 'kickstart.plugins.autopairs',
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
require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps

-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- This is the easiest way to modularize your config.
Expand Down
Loading
Loading