Update neovim configs

main
Buddy Sandidge 8 months ago
parent 41245ff7e6
commit dbb3fa6d8e

@ -1,5 +1,3 @@
require 'core.config' require('core.config')
require 'core.commands'
require 'core.keymaps'
vim.opt.runtimepath:prepend(vim.fn.stdpath('data') .. '/lazy/lazy.nvim') vim.opt.runtimepath:prepend(vim.fn.stdpath('data') .. '/lazy/lazy.nvim')
require 'lazy' .setup('plugins', {}) require('lazy').setup('plugins', {})

@ -3,7 +3,20 @@ vim.g.maplocalleader = ','
vim.opt.fileformats = { 'unix', 'dos', 'mac' } vim.opt.fileformats = { 'unix', 'dos', 'mac' }
vim.opt.autochdir = true vim.opt.mouse = 'a'
vim.opt.clipboard = 'unnamedplus'
vim.opt.breakindent = true
vim.opt.undofile = true
vim.opt.signcolumn = 'yes'
vim.opt.updatetime = 250
vim.opt.timeoutlen = 300
vim.opt.splitright = true
vim.opt.splitbelow = true
vim.opt.scrolloff = 8
-- vim.opt.autochdir = true
-- Tabs -- Tabs
vim.opt.shiftwidth = 4 vim.opt.shiftwidth = 4
@ -18,6 +31,7 @@ vim.opt.relativenumber = true
vim.opt.showmatch = true vim.opt.showmatch = true
vim.opt.spelllang = 'en_us' vim.opt.spelllang = 'en_us'
vim.opt.wildmode = 'list:longest' vim.opt.wildmode = 'list:longest'
vim.opt.cursorline = true
-- Indent -- Indent
vim.opt.copyindent = true vim.opt.copyindent = true
@ -28,6 +42,8 @@ vim.opt.shiftround = true
-- Text Formatting/Layout -- Text Formatting/Layout
vim.opt.ignorecase = true vim.opt.ignorecase = true
vim.opt.list = true vim.opt.list = true
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '' }
vim.opt.inccommand = 'split'
vim.opt.smartcase = true vim.opt.smartcase = true
vim.opt.wrap = false vim.opt.wrap = false
vim.opt.whichwrap:append { vim.opt.whichwrap:append {
@ -36,3 +52,31 @@ vim.opt.whichwrap:append {
['['] = true, ['['] = true,
[']'] = true, [']'] = true,
} }
vim.api.nvim_create_user_command('W', 'write', {})
vim.api.nvim_create_user_command('Q', 'qall!', {})
vim.keymap.set('n', '<leader>l', ':nohlsearch<CR>', { desc = 'clear highlighted search' })
vim.keymap.set('n', '<leader>ts', [[:%s/\s\s*$//g<CR>]], { desc = '[T]rim trailing [S]pace' })
vim.keymap.set('n', '<leader>ss', ':setlocal spell!<CR>', { desc = '[S]et [S]pell' })
vim.keymap.set('n', '<leader>p', ':set paste!<CR>', { desc = '[P]aste' })
vim.keymap.set('n', '<leader>nn', ':set nonumber norelativenumber<CR>', { desc = '[N]o [N]umber removed number and relative number' })
vim.keymap.set('n', '<leader>rn', ':set number relativenumber<CR>', { desc = '[R]elative [N]umber - set relative number and absolute number' })
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnopstic [Q]uickfix list' })
-- Use <Ctrl-h/j/k/l> to move between windows, no need for <Ctrl-w> first
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus up window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus down window' })
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus left window' })
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus right window' })
-- highlight text on copy
vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text',
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
callback = vim.highlight.on_yank,
})

@ -59,5 +59,4 @@ return {
'saadparwaiz1/cmp_luasnip', 'saadparwaiz1/cmp_luasnip',
'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-nvim-lsp',
}, },
} }

@ -3,5 +3,6 @@ return {
tag = 'v2.2', tag = 'v2.2',
dependencies = { dependencies = {
{ 'tpope/vim-sleuth', tag = 'v2.0' }, { 'tpope/vim-sleuth', tag = 'v2.0' },
{ 'numToStr/Comment.nvim', opts = {}, lazy = false },
}, },
} }

@ -1,14 +1,13 @@
local function config() local function config()
require('go').setup() require("go").setup()
end end
return { return {
'ray-x/go.nvim', 'ray-x/go.nvim',
name = 'go', name = 'go',
import = 'plugins.go',
config = config, config = config,
event = {'CmdlineEnter'}, event = { 'CmdlineEnter' },
ft = {'go', 'gomod'}, ft = { 'go', 'gomod' },
dependencies = { dependencies = {
'ray-x/guihua.lua', 'ray-x/guihua.lua',
'lspconfig', 'lspconfig',

@ -1,42 +1,11 @@
# chezmoi:template:left-delimiter=--{{ # chezmoi:template:left-delimiter=--{{
--{{- /* vim: set filetype=lua: */ -}} --{{- /* vim: set filetype=lua: */ -}}
local function on_attach(_, buffer)
local function nmap(keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
end
vim.keymap.set('n', keys, func, { buffer = buffer, desc = desc })
end
local function inspect_workspace_folders()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end
local function on_attach(_, buffer)
local function format_buffer(_) local function format_buffer(_)
vim.lsp.buf.format() vim.lsp.buf.format()
end end
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
local builtin = require 'telescope.builtin'
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')
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', inspect_workspace_folders, '[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(buffer, 'Format', format_buffer, { vim.api.nvim_buf_create_user_command(buffer, 'Format', format_buffer, {
desc = 'Format current buffer with LSP', desc = 'Format current buffer with LSP',
@ -46,12 +15,60 @@ end
local function config() local function config()
local cmp_nvim_lsp = require 'cmp_nvim_lsp' local cmp_nvim_lsp = require 'cmp_nvim_lsp'
local lspconfig = require 'lspconfig' local lspconfig = require 'lspconfig'
local mason = require 'mason'
local mason_lspconfig = require 'mason-lspconfig' local mason_lspconfig = require 'mason-lspconfig'
local neodev = require 'neodev' local builtin = require 'telescope.builtin'
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
callback = function (event)
local function map(keys, func, desc)
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc})
end
mason.setup() map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
neodev.setup() map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
map('gd', builtin.lsp_definitions, '[G]oto [D]efinition')
map('gr', builtin.lsp_references, '[G]oto [R]eferences')
map('gI', builtin.lsp_implementations, '[G]oto [I]mplementation')
map('<leader>D', builtin.lsp_type_definitions, 'Type [D]efinition')
map('<leader>ds', builtin.lsp_document_symbols, '[D]ocument [S]ymbols')
map('<leader>ws', builtin.lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
-- See `:help K` for why this keymap
map('K', vim.lsp.buf.hover, 'Hover Documentation')
map('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
local function inspect_workspace_folders()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end
-- Lesser used LSP functionality
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
map('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
map('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
map('<leader>wl', inspect_workspace_folders, '[W]orkspace [L]ist Folders')
-- 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).
local client = vim.lsp.get_client_by_id(event.data.client_id)
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
})
local servers = { local servers = {
bashls = {}, bashls = {},
@ -66,7 +83,6 @@ local function config()
yamlls = {}, yamlls = {},
cmake = {}, cmake = {},
cssls = {}, cssls = {},
rome = {},
--{{ if lookPath "node" -}} --{{ if lookPath "node" -}}
eslint = {}, eslint = {},
tsserver = {}, tsserver = {},
@ -108,10 +124,10 @@ return {
name = 'lspconfig', name = 'lspconfig',
config = config, config = config,
dependencies = { dependencies = {
{ 'williamboman/mason.nvim', tag = 'v1.*' }, { 'williamboman/mason.nvim', tag = 'v1.*', opts = {} },
{ 'williamboman/mason-lspconfig.nvim', tag = 'v1.*' }, { 'williamboman/mason-lspconfig.nvim', tag = 'v1.*' },
{ 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} },
{ 'folke/neodev.nvim', tag = 'v2.*' }, { 'folke/neodev.nvim', tag = 'v2.*', opts = {} },
{ 'folke/trouble.nvim', tag = 'v2.*' }, { 'folke/trouble.nvim', tag = 'v2.*' },
}, },
} }

@ -2,6 +2,7 @@ local function config()
local luasnip = require 'luasnip' local luasnip = require 'luasnip'
luasnip.setup() luasnip.setup()
luasnip.config.setup({}) luasnip.config.setup({})
require("luasnip.loaders.from_snipmate").lazy_load()
end end
return { return {

@ -34,30 +34,38 @@ end
vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {})
local telescope_setup = { local function config()
-- See `:help telescope` and `:help telescope.setup()`
local telescope = require('telescope')
local builtin = require('telescope.builtin')
local themes = require('telescope.themes')
telescope.setup({
-- pickers = {}
extensions = {
['ui-select'] = {
themes.get_dropdown(),
},
},
defaults = { defaults = {
mappings = { mappings = {
i = { i = {
['<C-u>'] = false, ['<C-u>'] = false,
['<C-d>'] = false, ['<C-d>'] = false,
['<C-enter>'] = 'to_fuzzy_refine',
}, },
}, },
}, },
} })
local function config()
-- See `:help telescope` and `:help telescope.setup()`
local telescope = require('telescope')
local builtin = require('telescope.builtin')
local themes = require('telescope.themes')
telescope.setup(telescope_setup)
-- Enable telescope fzf native, if installed -- Enable telescope fzf native, if installed
pcall(telescope.load_extension, 'fzf') pcall(telescope.load_extension, 'fzf')
pcall(telescope.load_extension, 'ui-select')
local fuzzy_find = function() local function fuzzy_find ()
-- You can pass additional configuration to telescope to change theme, layout, etc. -- You can pass additional configuration to telescope to change theme,
-- layout, etc.
builtin.current_buffer_fuzzy_find(themes.get_dropdown({ builtin.current_buffer_fuzzy_find(themes.get_dropdown({
winblend = 10, winblend = 10,
previewer = false, previewer = false,
@ -65,20 +73,22 @@ local function config()
end end
-- See `:help telescope.builtin` -- See `:help telescope.builtin`
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>/', fuzzy_find, { desc = '[/] Fuzzily search in current buffer' })
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>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', '<leader>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>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sG', live_grep_git_root, { desc = '[S]earch by [G]rep on Git Root' })
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' }) vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
vim.keymap.set('n', '<leader>sG', live_grep_git_root, { desc = '[S]earch by [G]rep on Git Root' })
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
vim.keymap.set('n', '<leader>/', fuzzy_find, { desc = '[/] Fuzzily search in current buffer' })
vim.keymap.set('n', '<leader>gf', builtin.git_files, { desc = 'Search [G]it [F]iles' })
end end
local is_make_installed = function() local function is_make_installed()
return vim.fn.executable('make') == 1 return vim.fn.executable('make') == 1
end end
@ -86,6 +96,7 @@ return {
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim',
branch = '0.1.x', branch = '0.1.x',
config = config, config = config,
event = 'VimEnter',
dependencies = { dependencies = {
'nvim-lua/plenary.nvim', 'nvim-lua/plenary.nvim',
{ {
@ -93,5 +104,7 @@ return {
cond = is_make_installed, cond = is_make_installed,
build = 'make', build = 'make',
}, },
'nvim-telescope/telescope-ui-select.nvim',
'nvim-tree/nvim-web-devicons',
}, },
} }

@ -12,6 +12,14 @@ return {
options = { options = {
theme = 'gruvbox', theme = 'gruvbox',
}, },
sections = {
lualine_a = { 'mode' },
lualine_b = { 'diagnostics' },
lualine_c = { { 'filename', path = 3 } },
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'progress' },
lualine_z = { 'location' }
},
}, },
}, },
} }

@ -1,25 +0,0 @@
local function init()
vim.o.timeout = true
vim.o.timeoutlen = 300
end
local function config()
local wk = require 'which-key'
wk.setup()
wk.register {
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
['<leader>g'] = { name = '[G]it', _ = 'which_key_ignore' },
['<leader>h'] = { name = 'More git', _ = '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
return {
'folke/which-key.nvim',
init = init,
config = config,
event = "VeryLazy",
}

@ -0,0 +1,53 @@
snippet #! "Shebang" !b
#!/usr/bin/env ${1:bash}
snippet - "bullet"
snippet -> "right arrow"
snippet :) "smile"
snippet :( "frown"
snippet <3 "heart"
snippet *<3 "sparkle heart"
💖
snippet x "ballot x"
snippet v "check mark"
snippet !? "interrobang"
snippet ?! "interrobang"
snippet ... "ellipsis"
snippet * "star"
snippet -- "em dash"
snippet != "not equal"
snippet <- "left arrow ←"
snippet \/ "down arrow ↓"
snippet 1/2 "half ½"
½

@ -0,0 +1,47 @@
# chezmoi:template:left-delimiter=#{{
#{{- /* vim: set filetype=snippets: */ -}}
#{{- if lookPath "go" -}}
snippet ignore "ignore function" !
func(...any) {}(${1})
snippet ctx "context" !
ctx context.Context
snippet e "error wrapper" !
e := wrap(".${1}")
snippet test "setup test case" !
func Test${1}(t *testing.T) {
type testcase struct {
Name string
Setup func(tc *testcase)
}
tt := []testcase{}
for _, tc := range tt {
tc := tc
t.Run(tc.Name, func(t *testing.T) {
t.Parallel()
tc.Setup(&tc)
})
}
}
snippet htest "setup context test case" !
func Test${1}(t *testing.T) {
type testcase struct {
Name string
Setup func(tc *testcase)
}
tt := []testcase{}
for _, tc := range tt {
tc := tc
t.Run(tc.Name, func(t *testing.T) {
ctx, a, ctrl := utils.Test(t)
t.Parallel()
tc.Setup(&tc)
})
}
}
#{{- end }}

@ -0,0 +1,18 @@
snippet doctype "html5 doctype" !
<!doctype html>
snippet head "head tag based html5 boilerplate" !
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="path/to/css/file.css">
</head>
snippet script "script tag" !
<script>${1}</script>
snippet scriptsrc "script src" !
<script src="${1}"></script>

@ -0,0 +1,54 @@
snippet f "function" !
function ${1:func} (${2}) {
${VISUAL}$0
}
snippet if "if" !
if (${1:true}) {
${VISUAL}$0
}
snippet scf "self calling function" !
(function (${1:argument}) {
${VISUAL}$0
}(${2:$1}));
snippet log "console.log"
console.log(${1:'${2:value}'});
snippet strict "use strict"
'use strict';
snippet timeout "setTimeout" !
setTimeout(function () {
${1://code}
}, 0);
snippet it "it test case" !
it('→ $1', () => {
});
snippet desc "describe test case" !
describe('→ $1', () => {
});
snippet exp "expect" b
expect($1).toBe($2);
snippet umd "Universal Module Definition" b
(function (root, factory) {
if (typeof define === "function" && define.amd) {
define(["${1:dependency}"], factory);
} else if (typeof exports === "object") {
module.exports = factory(require("$1"));
} else {
root.${2:Export} = factory(root.$1);
}
}(this, function ($1) {
function $2($3) {
}
return $2;
}))
snippet debug "debugger" !
debugger$1;

@ -0,0 +1,32 @@
snippet php "Starting php tag" !b
<?php
snippet phpil "php inline tag" !b
<?php ${1} ?>
snippet ec "echo" !b
echo "${1}";
snippet f "Anonymous function"
function () {
${1}
}
snippet fuse "Anonymous function with use"
function () use (${1}) {
${2}
}
snippet this "this helper"
$${1:this}->${2:prop}
snippet [] "array literal"
array(${1})
snippet {} "Empty object"
new stdClass()
snippet scf "self calling function" !b
call_user_func(function () {
${1}
});

@ -0,0 +1,9 @@
snippet map "Map snippet"
map(${1:lambda x: x}, ${2:[]})
snippet #! "Python shebang" !
#!/usr/bin/env python3
snippet #! "Python2 shebang" !
#!/usr/bin/env python2
# encoding: utf-8

@ -0,0 +1,7 @@
snippet mixin "mixin definition"
@mixin ${1:name}(${2:$vars}) {
${3:@content}
}
snippet inc "call a mixin"
@include ${1:mixin-name}${2:($variables)}
Loading…
Cancel
Save