1
0
Fork 0

nvim: switch from double quotes to single quotes and some other ADHD+OCD related changes

This commit is contained in:
Pratham Patel 2023-03-12 18:53:45 +05:30
parent ed6efb1fd8
commit 3ae395550b
4 changed files with 146 additions and 144 deletions

View File

@ -14,10 +14,10 @@ vim.g.maplocalleader = ' '
-- initialize the package manager -- initialize the package manager
require("plug-init") require('plug-init')
-- setup the plugins -- setup the plugins
require("plug-setup") require('plug-setup')
-- load the options, autocmds, key bindings and statusline -- load the options, autocmds, key bindings and statusline
require("vim-options") require('vim-options')
require("autocmds") require('autocmds')
require("key-bindings") require('key-bindings')

View File

@ -19,7 +19,7 @@ vim.keymap.set({'n', 'i'}, '<C-S-V>', '\'+P')
-- idk what this is -- idk what this is
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
-- Remap for dealing with word wrap -- remap for dealing with word wrap
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })

View File

@ -35,7 +35,7 @@ require('lazy').setup({
-- end, -- end,
}, },
{ -- Rust { -- Rust lang
'rust-lang/rust.vim', 'rust-lang/rust.vim',
'simrat39/rust-tools.nvim', 'simrat39/rust-tools.nvim',
}, },
@ -71,7 +71,7 @@ require('lazy').setup({
{ -- adds git releated signs to the gutter, as well as utilities for managing changes { -- adds git releated signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim', 'lewis6991/gitsigns.nvim',
opts = { opts = {
-- See `:help gitsigns.txt` -- see `:help gitsigns.txt`
signs = { signs = {
add = { text = '+' }, add = { text = '+' },
change = { text = '~' }, change = { text = '~' },
@ -84,7 +84,7 @@ require('lazy').setup({
{ -- set lualine as statusline { -- set lualine as statusline
'nvim-lualine/lualine.nvim', 'nvim-lualine/lualine.nvim',
-- See `:help lualine.txt` -- see `:help lualine.txt`
opts = { opts = {
options = { options = {
icons_enabled = true, icons_enabled = true,
@ -131,17 +131,17 @@ require('lazy').setup({
{ -- add indentation guides even on blank lines { -- add indentation guides even on blank lines
'lukas-reineke/indent-blankline.nvim', 'lukas-reineke/indent-blankline.nvim',
-- enable `lukas-reineke/indent-blankline.nvim` -- enable `lukas-reineke/indent-blankline.nvim`
-- See `:help indent_blankline.txt` -- see `:help indent_blankline.txt`
opts = { opts = {
char = '', char = '',
show_trailing_blankline_indent = false, show_trailing_blankline_indent = false,
}, },
}, },
-- "gc" to comment visual regions/lines -- 'gc' to comment visual regions/lines
{ 'numToStr/Comment.nvim', opts = {} }, { 'numToStr/Comment.nvim', opts = {} },
-- fuzzy Finder (files, lsp, etc) -- fuzzy finder (files, lsp, etc)
{ 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim' } }, { 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim' } },
{ -- highlight, edit, and navigate code { -- highlight, edit, and navigate code

View File

@ -2,18 +2,18 @@
-- nvim-tree -- nvim-tree
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
require("nvim-tree").setup({ require('nvim-tree').setup({
auto_reload_on_write = true, auto_reload_on_write = true,
disable_netrw = false, disable_netrw = false,
hijack_netrw = true, hijack_netrw = true,
sort_by = "case_sensitive", sort_by = 'case_sensitive',
view = { view = {
width = 30, width = 30,
number = true, number = true,
relativenumber = true, relativenumber = true,
mappings = { mappings = {
list = { list = {
{ key = "u", action = "dir_up" }, { key = 'u', action = 'dir_up' },
}, },
}, },
}, },
@ -21,21 +21,21 @@ require("nvim-tree").setup({
group_empty = false, group_empty = false,
highlight_git = true, highlight_git = true,
icons = { icons = {
symlink_arrow = "", symlink_arrow = '',
glyphs = { glyphs = {
modified = "", modified = '',
git = { git = {
unstaged = "", unstaged = '',
staged = "", staged = '',
unmerged = "", unmerged = '',
renamed = "", renamed = '',
untracked = "[ ]", untracked = '[ ]',
deleted = "", deleted = '',
ignored = "", ignored = '',
}, },
}, },
}, },
special_files = { "Cargo.toml", "README.md", "Readme.md", "readme.md" }, special_files = { 'Cargo.toml', 'README.md', 'Readme.md', 'readme.md' },
symlink_destination = true, symlink_destination = true,
}, },
filters = { filters = {
@ -55,7 +55,7 @@ cmp.setup({
snippet = { snippet = {
-- REQUIRED - you must specify a snippet engine -- REQUIRED - you must specify a snippet engine
expand = function(args) expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. vim.fn['vsnip#anonymous'](args.body) -- for `vsnip` users
end, end,
}, },
window = { window = {
@ -63,7 +63,9 @@ cmp.setup({
documentation = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(),
}, },
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
['<Tab>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. -- accept currently selected item
-- set `select` to `false` to only confirm explicitly selected items
['<Tab>'] = cmp.mapping.confirm({ select = true }),
}), }),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'nvim_lsp' }, { name = 'nvim_lsp' },
@ -73,10 +75,10 @@ cmp.setup({
}) })
}) })
local capabilities = require("cmp_nvim_lsp").default_capabilities() local capabilities = require('cmp_nvim_lsp').default_capabilities()
require("lspconfig")["rust_analyzer"].setup { require('lspconfig')['rust_analyzer'].setup {
cmd = {"rust-analyzer"}, cmd = {'rust-analyzer'},
filetypes = {"rust"}, filetypes = {'rust'},
capabilities = capabilities, capabilities = capabilities,
} }
--]] --]]
@ -91,22 +93,22 @@ local opts = {
-- how to execute terminal commands -- how to execute terminal commands
-- options right now: termopen / quickfix -- options right now: termopen / quickfix
executor = require("rust-tools/executors").termopen, executor = require('rust-tools/executors').termopen,
-- callback to execute once rust-analyzer is done initializing the workspace -- callback to execute once rust-analyzer is done initializing the workspace
-- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error" -- the callback receives one parameter indicating the `health` of the server: 'ok' | 'warning' | 'error'
on_initialized = nil, on_initialized = nil,
-- automatically call RustReloadWorkspace when writing to a Cargo.toml file. -- automatically call RustReloadWorkspace when writing to a Cargo.toml file
reload_workspace_from_cargo_toml = true, reload_workspace_from_cargo_toml = true,
-- These apply to the default RustSetInlayHints command -- these apply to the default RustSetInlayHints command
inlay_hints = { inlay_hints = {
-- automatically set inlay hints (type hints) -- automatically set inlay hints (type hints)
-- default: true -- default: true
auto = true, auto = true,
-- Only show inlay hints for the current line -- only show inlay hints for the current line
only_current_line = false, only_current_line = false,
-- whether to show parameter hints with the inlay hints or not -- whether to show parameter hints with the inlay hints or not
@ -114,12 +116,12 @@ local opts = {
show_parameter_hints = true, show_parameter_hints = true,
-- prefix for parameter hints -- prefix for parameter hints
-- default: "<-" -- default: '<-'
parameter_hints_prefix = "<- ", parameter_hints_prefix = '<- ',
-- prefix for all the other hints (type, chaining) -- prefix for all the other hints (type, chaining)
-- default: "=>" -- default: '=>'
other_hints_prefix = "=> ", other_hints_prefix = '=> ',
-- whether to align to the length of the longest line in the file -- whether to align to the length of the longest line in the file
max_len_align = false, max_len_align = false,
@ -133,8 +135,8 @@ local opts = {
-- padding from the right if right_align is true -- padding from the right if right_align is true
right_align_padding = 7, right_align_padding = 7,
-- The color of the hints -- the color of the hints
highlight = "Comment", highlight = 'Comment',
}, },
-- options same as lsp hover / vim.lsp.util.open_floating_preview() -- options same as lsp hover / vim.lsp.util.open_floating_preview()
@ -143,14 +145,14 @@ local opts = {
-- the border that is used for the hover window -- the border that is used for the hover window
-- see vim.api.nvim_open_win() -- see vim.api.nvim_open_win()
border = { border = {
{ "", "FloatBorder" }, { '', 'FloatBorder' },
{ "", "FloatBorder" }, { '', 'FloatBorder' },
{ "", "FloatBorder" }, { '', 'FloatBorder' },
{ "", "FloatBorder" }, { '', 'FloatBorder' },
{ "", "FloatBorder" }, { '', 'FloatBorder' },
{ "", "FloatBorder" }, { '', 'FloatBorder' },
{ "", "FloatBorder" }, { '', 'FloatBorder' },
{ "", "FloatBorder" }, { '', 'FloatBorder' },
}, },
-- whether the hover action window gets automatically focused -- whether the hover action window gets automatically focused
@ -161,10 +163,10 @@ local opts = {
-- settings for showing the crate graph based on graphviz and the dot -- settings for showing the crate graph based on graphviz and the dot
-- command -- command
crate_graph = { crate_graph = {
-- Backend used for displaying the graph -- backend used for displaying the graph
-- see: https://graphviz.org/docs/outputs/ -- see: https://graphviz.org/docs/outputs/
-- default: x11 -- default: x11
backend = "x11", backend = 'x11',
-- where to store the output, nil for no output stored (relative -- where to store the output, nil for no output stored (relative
-- path from pwd) -- path from pwd)
-- default: nil -- default: nil
@ -174,64 +176,64 @@ local opts = {
-- default: true -- default: true
full = true, full = true,
-- List of backends found on: https://graphviz.org/docs/outputs/ -- list of backends found on: https://graphviz.org/docs/outputs/
-- Is used for input validation and autocompletion -- is used for input validation and autocompletion
-- Last updated: 2021-08-26 -- last updated: 2021-08-26
enabled_graphviz_backends = { enabled_graphviz_backends = {
"bmp", 'bmp',
"cgimage", 'cgimage',
"canon", 'canon',
"dot", 'dot',
"gv", 'gv',
"xdot", 'xdot',
"xdot1.2", 'xdot1.2',
"xdot1.4", 'xdot1.4',
"eps", 'eps',
"exr", 'exr',
"fig", 'fig',
"gd", 'gd',
"gd2", 'gd2',
"gif", 'gif',
"gtk", 'gtk',
"ico", 'ico',
"cmap", 'cmap',
"ismap", 'ismap',
"imap", 'imap',
"cmapx", 'cmapx',
"imap_np", 'imap_np',
"cmapx_np", 'cmapx_np',
"jpg", 'jpg',
"jpeg", 'jpeg',
"jpe", 'jpe',
"jp2", 'jp2',
"json", 'json',
"json0", 'json0',
"dot_json", 'dot_json',
"xdot_json", 'xdot_json',
"pdf", 'pdf',
"pic", 'pic',
"pct", 'pct',
"pict", 'pict',
"plain", 'plain',
"plain-ext", 'plain-ext',
"png", 'png',
"pov", 'pov',
"ps", 'ps',
"ps2", 'ps2',
"psd", 'psd',
"sgi", 'sgi',
"svg", 'svg',
"svgz", 'svgz',
"tga", 'tga',
"tiff", 'tiff',
"tif", 'tif',
"tk", 'tk',
"vml", 'vml',
"vmlz", 'vmlz',
"wbmp", 'wbmp',
"webp", 'webp',
"xlib", 'xlib',
"x11", 'x11',
}, },
}, },
}, },
@ -248,23 +250,20 @@ local opts = {
-- debugging stuff -- debugging stuff
dap = { dap = {
adapter = { adapter = {
type = "executable", type = 'executable',
command = "lldb-vscode", command = 'lldb-vscode',
name = "rt_lldb", name = 'rt_lldb',
}, },
}, },
} }
require('rust-tools').setup(opts) require('rust-tools').setup(opts)
-- Set inlay hints for the current buffer -- set inlay hints for the current buffer
require('rust-tools').inlay_hints.set() require('rust-tools').inlay_hints.set()
-- Unset inlay hints for the current buffer
--require('rust-tools').inlay_hints.unset() -- enable inlay hints auto update and set them for all the buffers
-- Enable inlay hints auto update and set them for all the buffers
require('rust-tools').inlay_hints.enable() require('rust-tools').inlay_hints.enable()
-- Disable inlay hints auto update and unset them for all buffers
--require('rust-tools').inlay_hints.disable()
-- RustRunnables -- RustRunnables
require('rust-tools').runnables.runnables() require('rust-tools').runnables.runnables()
@ -291,7 +290,7 @@ require('telescope').setup {
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) 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><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
vim.keymap.set('n', '<leader>/', function() vim.keymap.set('n', '<leader>/', function()
-- You can pass additional configuration to telescope to change theme, layout, etc. -- you can pass additional configuration to telescope to change theme, layout, etc
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10, winblend = 10,
previewer = false, previewer = false,
@ -310,12 +309,13 @@ vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { de
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
require('nvim-treesitter.configs').setup { require('nvim-treesitter.configs').setup {
-- Add languages to be installed here that you want installed for treesitter -- add languages to be installed here that you want installed for treesitter
-- https://github.com/nvim-treesitter/nvim-treesitter#supported-languages -- https://github.com/nvim-treesitter/nvim-treesitter#supported-languages
ensure_installed = { 'bash', 'c', 'cmake', 'comment', 'cpp', 'devicetree', 'diff', 'git_rebase', 'gitcommit', 'gitignore', 'go', 'help', 'html', 'lua', 'make', 'markdown', 'nix', 'python', 'regex', 'rust', 'toml', 'tsx', 'typescript', 'vim', 'yaml' }, ensure_installed = { 'bash', 'c', 'cmake', 'comment', 'cpp', 'devicetree', 'diff', 'git_rebase', 'gitcommit', 'gitignore', 'go', 'help', 'html', 'lua', 'make', 'markdown', 'nix', 'python', 'regex', 'rust', 'toml', 'tsx', 'typescript', 'vim', 'yaml' },
-- --
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) -- autoinstall languages that are not installed
-- defaults to false (but you can change for yourself!)
auto_install = false, auto_install = false,
highlight = { enable = true }, highlight = { enable = true },
@ -332,9 +332,9 @@ require('nvim-treesitter.configs').setup {
textobjects = { textobjects = {
select = { select = {
enable = true, enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim lookahead = true, -- automatically jump forward to textobj, similar to targets.vim
keymaps = { keymaps = {
-- You can use the capture groups defined in textobjects.scm -- you can use the capture groups defined in textobjects.scm
['aa'] = '@parameter.outer', ['aa'] = '@parameter.outer',
['ia'] = '@parameter.inner', ['ia'] = '@parameter.inner',
['af'] = '@function.outer', ['af'] = '@function.outer',
@ -375,21 +375,22 @@ require('nvim-treesitter.configs').setup {
}, },
} }
-- Diagnostic keymaps -- diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" }) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" }) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) 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" }) vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
-- LSP settings. -- LSP settings
-- This function gets run when an LSP connects to a particular buffer. -- this function gets run when an LSP connects to a particular buffer
local on_attach = function(_, bufnr) local on_attach = function(_, bufnr)
-- NOTE: Remember that lua is a real programming language, and as such it is possible -- 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 -- to define small helper and utility functions so you don't have to repeat yourself
-- many times. -- many times
-- --
-- In this case, we create a function that lets us more easily define mappings specific -- in this case, we create a function that lets us more easily define
-- for LSP related items. It sets the mode, buffer and description for us each time. -- mappings specific for LSP related items
-- it sets the mode, buffer and description for us each time
local nmap = function(keys, func, desc) local nmap = function(keys, func, desc)
if desc then if desc then
desc = 'LSP: ' .. desc desc = 'LSP: ' .. desc
@ -408,11 +409,11 @@ local on_attach = function(_, bufnr)
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') 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('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
-- See `:help K` for why this keymap -- see `:help K` for why this keymap
nmap(')', vim.lsp.buf.hover, 'Hover Documentation') nmap(')', vim.lsp.buf.hover, 'Hover Documentation')
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation') nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
-- Lesser used LSP functionality -- lesser used LSP functionality
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') 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>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>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
@ -420,17 +421,18 @@ local on_attach = function(_, bufnr)
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) 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 -- create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format() vim.lsp.buf.format()
end, { desc = 'Format current buffer with LSP' }) end, { desc = 'Format current buffer with LSP' })
end end
-- Enable the following language servers -- enable the following language servers
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed. -- feel free to add/remove any LSPs that you want here they will automatically be installed
-- --
-- Add any additional override configuration in the following tables. They will be passed to -- add any additional override configuration in the following tables
-- the `settings` field of the server config. You must look up that documentation yourself. -- they will be passed to the `settings` field of the server config
-- you must look up that documentation yourself
local servers = { local servers = {
-- clangd = {}, -- clangd = {},
-- gopls = {}, -- gopls = {},
@ -446,17 +448,17 @@ local servers = {
}, },
} }
-- Setup neovim lua configuration -- setup neovim lua configuration
require('neodev').setup() require('neodev').setup()
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers -- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
-- Setup mason so it can manage external tooling -- setup mason so it can manage external tooling
require('mason').setup() require('mason').setup()
-- Ensure the servers above are installed -- ensure the servers above are installed
local mason_lspconfig = require 'mason-lspconfig' local mason_lspconfig = require 'mason-lspconfig'
mason_lspconfig.setup { mason_lspconfig.setup {