Changed a couple of nvim settings, added some keybinds, disabled treej, and added conform.nvim

This commit is contained in:
Dreaded_X 2024-04-13 05:38:25 +02:00
parent f2d0e639b4
commit b19f90dc7f
Signed by: Dreaded_X
GPG Key ID: FA5F485356B0D2D4
5 changed files with 605 additions and 475 deletions

View File

@ -38,147 +38,188 @@ P.S. You can delete this when you're done too. It's your config now :)
-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- Install package manager
-- https://github.com/folke/lazy.nvim
-- `:help lazy.nvim.txt` for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system {
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable', -- latest stable release
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
}
})
end
vim.opt.rtp:prepend(lazypath)
local symbols = require('constant.symbols');
local border = 'rounded';
local symbols = require("constant.symbols")
local border = "rounded"
-- Helper function for staging selection
local function gitsigns_visual_op(op)
return function()
return require("gitsigns")[op]({ vim.fn.line("."), vim.fn.line("v") })
end
end
-- NOTE: Here is where you install your plugins.
-- You can configure plugins using the `config` key.
--
-- You can also configure plugins after the setup call,
-- as they will be available in your neovim runtime.
require('lazy').setup({
require("lazy").setup({
-- 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',
"neovim/nvim-lspconfig",
dependencies = {
-- Automatically install LSPs to stdpath for neovim
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
"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 = {} },
{ "j-hui/fidget.nvim", opts = {} },
-- Additional lua configuration, makes nvim stuff amazing!
'folke/neodev.nvim',
"folke/neodev.nvim",
-- Add document color
'mrshmllow/document-color.nvim',
"mrshmllow/document-color.nvim",
'b0o/schemastore.nvim',
"b0o/schemastore.nvim",
-- Rename with immediate visual feedback
{
'smjonas/inc-rename.nvim',
"smjonas/inc-rename.nvim",
config = function()
require('inc_rename').setup {
require("inc_rename").setup({
preview_empty_name = true,
}
end
})
end,
},
},
},
{
'ray-x/lsp_signature.nvim',
"ray-x/lsp_signature.nvim",
dependencies = {
'neovim/nvim-lspconfig',
"neovim/nvim-lspconfig",
},
opts = {
hint_enable = false,
handler_opts = {
border = border
}
border = border,
},
},
},
{
-- Autocompletion
'hrsh7th/nvim-cmp',
dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip', 'hrsh7th/cmp-path',
'onsails/lspkind-nvim', },
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-path",
"onsails/lspkind-nvim",
},
},
-- Useful plugin to show you pending keybinds.
{ 'folke/which-key.nvim', opts = {} },
{
-- Adds git releated signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',
"folke/which-key.nvim",
opts = {},
init = function()
vim.keymap.set('n', '<leader>gs', require('gitsigns.actions').stage_hunk, { desc = "[G]it [S]tage hunk" })
vim.keymap.set('n', '<leader>gS', require('gitsigns.actions').undo_stage_hunk, { desc = "[G]it undo [S]tage hunk" })
vim.keymap.set('n', '<leader>gd', require('gitsigns.actions').preview_hunk_inline, { desc = "[G]it [D]iff hunk " })
vim.keymap.set('n', ']g', require('gitsigns.actions').next_hunk, { desc = "Go to next hunk" })
vim.keymap.set('n', '[g', require('gitsigns.actions').prev_hunk, { desc = "Go to previous hunk" })
require("which-key").register({
["<leader>g"] = { name = "[G]it", _ = "which_key_ignore" },
["<leader>b"] = { name = "[B]buffer", _ = "which_key_ignore" },
["<leader>s"] = { name = "[S]earch", _ = "which_key_ignore" },
})
end,
},
{
-- Adds git related signs to the gutter, as well as utilities for managing changes
"lewis6991/gitsigns.nvim",
init = function()
vim.keymap.set("n", "<leader>gs", require("gitsigns.actions").stage_hunk, { desc = "[G]it [S]tage hunk" })
vim.keymap.set(
"n",
"<leader>gS",
require("gitsigns.actions").undo_stage_hunk,
{ desc = "[G]it undo [S]tage hunk" }
)
vim.keymap.set(
"n",
"<leader>gd",
require("gitsigns.actions").preview_hunk_inline,
{ desc = "[G]it [D]iff hunk" }
)
vim.keymap.set("n", "<leader>gr", require("gitsigns.actions").reset_hunk, { desc = "[G]it [R]eset hunk" })
vim.keymap.set("v", "<leader>gs", gitsigns_visual_op("stage_hunk"), { desc = "[G]it [S]tage selection" })
vim.keymap.set("v", "<leader>gr", gitsigns_visual_op("reset_hunk"), { desc = "[G]it [R]eset selection" })
vim.keymap.set("n", "]g", function()
require("gitsigns.actions").nav_hunk("next")
end, { desc = "Go to next hunk" })
vim.keymap.set("n", "[g", function()
require("gitsigns.actions").nav_hunk("prev")
end, { desc = "Go to previous hunk" })
end,
opts = {
-- See `:help gitsigns.txt`
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
add = { text = "+" },
change = { text = "~" },
delete = { text = "_" },
topdelete = { text = "" },
changedelete = { text = "~" },
},
},
},
{
-- Set lualine as statusline
'nvim-lualine/lualine.nvim',
"nvim-lualine/lualine.nvim",
-- See `:help lualine.txt`
opts = {
options = {
icons_enabled = true,
theme = 'gruvbox',
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
theme = "gruvbox",
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
},
sections = {
lualine_b = {
'branch',
'diff',
{ 'diagnostics', symbols = { error = '', warn = '', info = '', hint = '' } },
"branch",
"diff",
{ "diagnostics", symbols = { error = "", warn = "", info = "", hint = "" } },
},
lualine_c = {
{
'filename',
"filename",
path = 1,
symbols = {
modified = symbols.file.modified,
readonly = symbols.file.readonly,
}
},
},
},
lualine_x = {
'encoding', { 'fileformat', icons_enabled = false }, 'filetype',
"encoding",
{ "fileformat", icons_enabled = false },
"filetype",
},
},
inactive_sections = {
lualine_c = {
{ 'filename', path = 1 },
{ "filename", path = 1 },
},
},
},
@ -186,68 +227,66 @@ require('lazy').setup({
{
-- Add indentation guides even on blank lines
'lukas-reineke/indent-blankline.nvim',
"lukas-reineke/indent-blankline.nvim",
-- Enable `lukas-reineke/indent-blankline.nvim`
-- See `:help indent_blankline.txt`
main = "ibl",
opts = {
indent = {
char = '¦',
char = "¦",
},
},
},
-- Fuzzy Finder (files, lsp, etc)
{
'nvim-telescope/telescope.nvim',
version = '*',
dependencies = { 'nvim-lua/plenary.nvim',
'nvim-telescope/telescope-ui-select.nvim' }
"nvim-telescope/telescope.nvim",
version = "*",
dependencies = { "nvim-lua/plenary.nvim", "nvim-telescope/telescope-ui-select.nvim" },
},
-- Fuzzy Finder Algorithm which requires local dependencies to be built.
-- Only load if `make` is available. Make sure you have the system
-- requirements installed.
{
'nvim-telescope/telescope-fzf-native.nvim',
"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 = 'make',
build = "make",
cond = function()
return vim.fn.executable 'make' == 1
return vim.fn.executable("make") == 1
end,
},
{
-- Highlight, edit, and navigate code
'nvim-treesitter/nvim-treesitter',
"nvim-treesitter/nvim-treesitter",
dependencies = {
'nvim-treesitter/nvim-treesitter-textobjects',
'nvim-treesitter/nvim-treesitter-context',
"nvim-treesitter/nvim-treesitter-textobjects",
"nvim-treesitter/nvim-treesitter-context",
},
config = function()
pcall(require('nvim-treesitter.install').update { with_sync = true })
pcall(require("nvim-treesitter.install").update({ with_sync = true }))
end,
},
require 'themes.gruvbox',
{ import = 'plugins' },
require("themes.gruvbox"),
{ import = "plugins" },
}, {
install = {
colorscheme = {
'gruvbox',
}
}
"gruvbox",
},
},
})
require('options')
require('keymaps')
require('autocmds')
require("options")
require("keymaps")
require("autocmds")
-- [[ Configure Telescope ]]
-- See `:help telescope` and `:help telescope.setup()`
require('telescope').setup {
require("telescope").setup({
pickers = {
find_files = {
hidden = true,
@ -259,70 +298,94 @@ require('telescope').setup {
},
mappings = {
n = {
['<c-d>'] = "delete_buffer",
['<Tab>'] = "move_selection_next",
['<S-Tab>'] = "move_selection_previous",
["<c-d>"] = "delete_buffer",
["<Tab>"] = "move_selection_next",
["<S-Tab>"] = "move_selection_previous",
},
i = {
['<c-d>'] = "delete_buffer",
['<Tab>'] = "move_selection_next",
['<S-Tab>'] = "move_selection_previous",
["<c-d>"] = "delete_buffer",
["<Tab>"] = "move_selection_next",
["<S-Tab>"] = "move_selection_previous",
},
},
},
extensions = {
["ui-select"] = {
require('telescope.themes').get_dropdown {}
}
}
}
require("telescope.themes").get_dropdown({}),
},
},
})
-- Enable telescope fzf native, if installed
pcall(require('telescope').load_extension, 'fzf')
pcall(require('telescope').load_extension, 'ui-select')
pcall(require("telescope").load_extension, "fzf")
pcall(require("telescope").load_extension, "ui-select")
-- 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>/', function()
require('telescope.builtin').current_buffer_fuzzy_find({
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>/", function()
require("telescope.builtin").current_buffer_fuzzy_find({
-- Show matches in the order they appear in the document
sorting_strategy = "ascending",
})
end, { desc = '[/] Fuzzily search in current buffer' })
end, { desc = "[/] Fuzzily search in current buffer" })
vim.keymap.set("n", "<leader>s/", function()
require("telescope.builtin").live_grep({
grep_open_files = true,
prompt_title = "Live Grep in Open Files",
})
end, { desc = "[S]earch [/] in Open Files" })
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', function()
require('telescope.builtin').grep_string({
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", function()
require("telescope.builtin").grep_string({
-- Show matches in the order they appear in the document
sorting_strategy = "ascending",
})
end, { 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>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' })
end, { 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>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>sk", require("telescope.builtin").keymaps, { desc = "[S]earch [K]eymaps" })
vim.keymap.set("n", "<leader>sn", function()
require("telescope.builtin").find_files({ cwd = vim.fn.stdpath("config") })
end, { desc = "[S]earch [N]eovim files" })
-- [[ Configure Treesitter ]]
-- See `:help nvim-treesitter`
require('nvim-treesitter.configs').setup {
require("nvim-treesitter.configs").setup({
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim', 'markdown',
'markdown_inline', 'bash', 'zig' },
ensure_installed = {
"c",
"cpp",
"go",
"lua",
"python",
"rust",
"tsx",
"typescript",
"vimdoc",
"vim",
"markdown",
"markdown_inline",
"bash",
"zig",
},
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = true,
highlight = { enable = true },
-- Disabled because it caueses issues with nvim-autopair
indent = { enable = false, disable = { 'python' } },
indent = { enable = false, disable = { "python" } },
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<c-space>',
node_incremental = '<c-space>',
scope_incremental = '<c-s>',
node_decremental = '<M-space>',
init_selection = "<c-space>",
node_incremental = "<c-space>",
scope_incremental = "<c-s>",
node_decremental = "<M-space>",
},
},
textobjects = {
@ -331,70 +394,64 @@ require('nvim-treesitter.configs').setup {
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = {
-- You can use the capture groups defined in textobjects.scm
['aa'] = '@parameter.outer',
['ia'] = '@parameter.inner',
['af'] = '@function.outer',
['if'] = '@function.inner',
['ac'] = '@class.outer',
['ic'] = '@class.inner',
["aa"] = "@parameter.outer",
["ia"] = "@parameter.inner",
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
[']m'] = '@function.outer',
[']]'] = '@class.outer',
["]m"] = "@function.outer",
["]]"] = "@class.outer",
},
goto_next_end = {
[']M'] = '@function.outer',
[']['] = '@class.outer',
["]M"] = "@function.outer",
["]["] = "@class.outer",
},
goto_previous_start = {
['[m'] = '@function.outer',
['[['] = '@class.outer',
["[m"] = "@function.outer",
["[["] = "@class.outer",
},
goto_previous_end = {
['[M'] = '@function.outer',
['[]'] = '@class.outer',
["[M"] = "@function.outer",
["[]"] = "@class.outer",
},
},
swap = {
enable = true,
swap_next = {
['<leader>a'] = '@parameter.inner',
["<leader>a"] = "@parameter.inner",
},
swap_previous = {
['<leader>A'] = '@parameter.inner',
["<leader>A"] = "@parameter.inner",
},
},
},
}
})
-- LSP settings.
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(
vim.lsp.handlers.hover,
{ border = border }
)
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border })
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(
vim.lsp.handlers.hover,
{ border = border }
)
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border })
vim.diagnostic.config {
vim.diagnostic.config({
float = {
border = border
}
}
border = border,
},
})
-- Set the diagnostic symbols (Also used by Neo-tree)
local signs = {
Error = symbols.diagnostic.error,
Warn = symbols.diagnostic.warning,
Hint = symbols.diagnostic.hint,
Info = symbols.diagnostic.info
Info = symbols.diagnostic.info,
}
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
@ -411,63 +468,67 @@ local on_attach = function(client, bufnr)
-- for LSP related items. It sets the mode, buffer and description for us each time.
local nmap = function(keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
desc = "LSP: " .. desc
end
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc })
end
vim.keymap.set('n', '<leader>rn', function()
return ':IncRename ' .. vim.fn.expand('<cword>')
end, { expr = true, desc = '[R]e[n]ame' })
vim.keymap.set("n", "<leader>rn", function()
return ":IncRename " .. vim.fn.expand("<cword>")
end, { expr = true, desc = "[R]e[n]ame" })
-- nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
-- Should allow code actions in visual mode
vim.keymap.set({ 'v', 'n' }, '<leader>ca', vim.lsp.buf.code_action,
{ buffer = bufnr, desc = 'LSP: [C]ode [A]ction', remap = true })
vim.keymap.set(
{ "v", "n" },
"<leader>ca",
vim.lsp.buf.code_action,
{ buffer = bufnr, desc = "LSP: [C]ode [A]ction", remap = true }
)
-- nmap('<leader>ca', require('telescope.builtin')., '[C]ode [A]ction')
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
nmap('<leader>D', vim.lsp.buf.type_definition, '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", vim.lsp.buf.definition, "[G]oto [D]efinition")
nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
nmap("gI", vim.lsp.buf.implementation, "[G]oto [I]mplementation")
nmap("<leader>D", vim.lsp.buf.type_definition, "Type [D]efinition")
nmap("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]symbols")
nmap("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]symbols")
-- See `:help K` for why this keymap
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
nmap("K", vim.lsp.buf.hover, "Hover Documentation")
nmap("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation")
-- Lesser used LSP functionality
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
nmap('<leader>wl', function()
nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
nmap("<leader>wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder")
nmap("<leader>wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder")
nmap("<leader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist Folders')
end, "[W]orkspace [L]ist Folders")
-- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format()
end, { desc = 'Format current buffer with LSP' })
-- Format on save
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format()
end,
})
end
-- Attach document colour support
if client.server_capabilities.colorProvider then
require("document-color").buf_attach(bufnr)
end
-- -- Create a command `:Format` local to the LSP buffer
-- vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
-- vim.lsp.buf.format()
-- end, { desc = 'Format current buffer with LSP' })
--
-- -- Format on save
-- local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
-- if client.supports_method("textDocument/formatting") then
-- vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
-- vim.api.nvim_create_autocmd("BufWritePre", {
-- group = augroup,
-- buffer = bufnr,
-- callback = function()
-- vim.lsp.buf.format()
-- end,
-- })
-- end
--
-- -- Attach document colour support
-- if client.server_capabilities.colorProvider then
-- require("document-color").buf_attach(bufnr)
-- end
end
-- Enable the following language servers
@ -479,7 +540,6 @@ local servers = {
clangd = {},
gopls = {},
pyright = {},
zls = {},
rust_analyzer = {
-- enable clippy on save
["rust-analyzer"] = {
@ -503,56 +563,56 @@ local servers = {
},
jsonls = {
json = {
schemas = require('schemastore').json.schemas(),
schemas = require("schemastore").json.schemas(),
},
},
yamlls = {
yaml = {
schemas = require('schemastore').yaml.schemas(),
schemas = require("schemastore").yaml.schemas(),
},
},
taplo = {},
cmake = {}
cmake = {},
}
-- Setup neovim lua configuration
require('neodev').setup()
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 = require("cmp_nvim_lsp").default_capabilities(capabilities)
capabilities.textDocument.colorProvider = {
dynamicRegistration = true
dynamicRegistration = true,
}
-- Setup mason so it can manage external tooling
require('mason').setup()
require("mason").setup()
-- Ensure the servers above are installed
local mason_lspconfig = require 'mason-lspconfig'
local mason_lspconfig = require("mason-lspconfig")
mason_lspconfig.setup {
mason_lspconfig.setup({
ensure_installed = vim.tbl_keys(servers),
}
})
mason_lspconfig.setup_handlers {
mason_lspconfig.setup_handlers({
function(server_name)
require('lspconfig')[server_name].setup {
require("lspconfig")[server_name].setup({
capabilities = capabilities,
on_attach = on_attach,
settings = servers[server_name],
}
})
end,
}
})
-- nvim-cmp setup
local cmp = require 'cmp'
local luasnip = require 'luasnip'
local lspkind = require 'lspkind'
local cmp = require("cmp")
local luasnip = require("luasnip")
local lspkind = require("lspkind")
luasnip.config.setup {}
luasnip.config.setup({})
cmp.setup {
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
@ -569,15 +629,15 @@ cmp.setup {
},
}),
},
mapping = cmp.mapping.preset.insert {
['<C-u>'] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete {},
['<CR>'] = cmp.mapping.confirm {
mapping = cmp.mapping.preset.insert({
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete({}),
["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = cmp.mapping(function(fallback)
}),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
@ -585,8 +645,8 @@ cmp.setup {
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
@ -594,14 +654,14 @@ cmp.setup {
else
fallback()
end
end, { 'i', 's' }),
},
end, { "i", "s" }),
}),
sources = {
{ name = 'luasnip' },
{ name = 'nvim_lsp' },
{ name = 'path' },
{ name = "luasnip" },
{ name = "nvim_lsp" },
{ name = "path" },
},
}
})
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et

View File

@ -5,6 +5,7 @@
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "9d5ba06d6ee7418c674f498634617416d15b6239" },
"document-color.nvim": { "branch": "main", "commit": "74c487f0e5accfaae033755451b9e367220693fd" },
"fidget.nvim": { "branch": "main", "commit": "1ba38e4cbb24683973e00c2e36f53ae64da38ef5" },
"gitsigns.nvim": { "branch": "main", "commit": "c097cb255096f333e14d341082a84f572b394fa2" },
@ -40,7 +41,6 @@
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
"telescope.nvim": { "branch": "master", "commit": "6312868392331c9c0f22725041f1ec2bef57c751" },
"todo-comments.nvim": { "branch": "main", "commit": "a736bbe08c8eff370dfa60701f1e669816d4e3c8" },
"treesj": { "branch": "main", "commit": "60e27280030f9cd8dfb6ceb335922c6ff76682cc" },
"trouble.nvim": { "branch": "main", "commit": "b9cf677f20bb2faa2dacfa870b084e568dca9572" },
"undotree": { "branch": "master", "commit": "aa93a7e5890dbbebbc064cd22260721a6db1a196" },
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" },

View File

@ -1,6 +1,6 @@
-- See `:help vim.o`
-- Set highlight on search
vim.o.hlsearch = false
-- Set highlight on search, clear by pressing esc
vim.o.hlsearch = true
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- Make line numbers default
vim.wo.number = true
@ -52,3 +52,9 @@ vim.o.confirm = true
-- Turn on cursorline
vim.o.cursorline = true
-- Don't show mode, powerline already shows it
vim.o.showmode = false
-- Minimum number of screen lines above and below the cursor
vim.o.scrolloff = 10

View File

@ -0,0 +1,63 @@
-- https://github.com/stevearc/conform.nvim
return {
"stevearc/conform.nvim",
event = { "BufWritePre" },
cmd = { "ConformInfo" },
keys = {
{
-- Customize or remove this keymap to your liking
"<leader>f",
function()
require("conform").format({ async = true, lsp_fallback = true })
end,
mode = "",
desc = "[F]ormat buffer",
},
},
opts = {
-- TODO: Automate installing these using e.g. mason
formatters_by_ft = {
c = { "clang-format" },
cpp = { "clang-format" },
go = { "goimports", "gofmt" },
python = { "ruff_format" },
rust = { "rustfmt" },
javascript = { { "prettierd", "prettier" } },
typescript = { { "prettierd", "prettier" } },
typescriptreact = { { "prettierd", "prettier" } },
css = { { "prettierd", "prettier" } },
markdown = { { "prettierd", "prettier" } },
lua = { "stylua" },
json = { "jq" },
yaml = { { "prettierd", "prettier" } },
toml = { "taplo" },
cmake = { "cmake_format" },
-- ["*"] = { "codespell" },
["_"] = { "trim_whitespace", "trim_newlines" },
},
format_after_save = {
lsp_fallback = true,
},
notify_on_error = true,
},
init = function()
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()
vim.b.disable_autoformat = false
vim.g.disable_autoformat = false
end, {
desc = "Re-enable autoformat-on-save",
})
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
end,
}

View File

@ -1,5 +1,6 @@
-- https://github.com/Wansmer/treesj
return {
enabled = false,
'Wansmer/treesj',
keys = {
{