Hack and slash nvim - slowly refactoring and upgrading.

This commit is contained in:
Shawn Anderson 2023-05-27 13:57:34 -07:00
parent de5c96a214
commit 9fa13b5c93
6 changed files with 376 additions and 46 deletions

View File

@ -1,3 +1,9 @@
" This makes the location of the current open file always the current working
" directory of vim. This pairs very nicely with tmux. Added - Sept 15th 2020
autocmd BufEnter * lcd %:p:h
augroup vyper_ft
au!
autocmd BufNewFile,BufRead *.vy set syntax=vyper

View File

@ -6,13 +6,13 @@ runtime coc.vim
runtime keys.vim
" Check code as python3 by default
let g:neomake_python_python_maker = neomake#makers#ft#python#python()
let g:neomake_python_flake8_maker = neomake#makers#ft#python#flake8()
let g:neomake_python_python_maker.exe = 'python3 -m py_compile'
let g:neomake_python_flake8_maker.exe = 'python3 -m flake8'
" let g:neomake_python_python_maker = neomake#makers#ft#python#python()
" let g:neomake_python_flake8_maker = neomake#makers#ft#python#flake8()
" let g:neomake_python_python_maker.exe = 'python3 -m py_compile'
" let g:neomake_python_flake8_maker.exe = 'python3 -m flake8'
" Disable error messages inside the buffer, next to the problematic line
let g:neomake_virtualtext_current_error = 1
" let g:neomake_virtualtext_current_error = 1
"------------------------------------------------------------------------------
" Shawn Anderson as of September 30th 2020
@ -43,9 +43,4 @@ inoremap <M-a> <home>
nnoremap <C-e> <end>
nnoremap <M-a> <home>
:set cursorline
:set number
:set relativenumber!
:set autoread
let g:coc_global_extensions = ['coc-json', 'coc-git', 'coc-tsserver', 'coc-pyright', 'coc-solidity']

View File

@ -1,18 +1,52 @@
"------------------------------------------------------------------------------
" Use comma for leader
let mapleader = ","
"------------------------------------------------------------------------------
" Inherited from MattCoding4Days
" remap default leader key to comma
let mapleader = ","
nnoremap <leader>r :source $MYVIMRC<CR>
" Shawn Anderson as of September 30th 2020
noremap <leader>f 0
noremap <leader>j $
" Highlight search
map <leader>/ :nohl<CR>
" Faster scrolling with control
noremap <C-j> jj
noremap <C-k> kk
" Spookie bug. I think I was hacked and that someone i fucking with me.
" Whenever I would pres shift K it would open a new tab in nvim.
" inoremap <S-k> <S-k>
" inoremap <S-j> <S-j>
" Here, I borrow some mappings from readline! These are great, google
" `readline cheatsheet` I map alt-a to home because I use ctr-a for tmux
" leader.
inoremap <C-b> <left>
inoremap <C-f> <right>
inoremap <C-e> <end>
inoremap <M-a> <home>
nnoremap <C-e> <end>
nnoremap <M-a> <home>
" Edit Vim Config File
nnoremap <leader>e :e $MYVIMRC<CR>
nnoremap <leader>w :w<CR>
nnoremap <leader>i :w<CR>:source $MYVIMRC<CR>:PlugInstall<CR>
" Source Vim Config File
nnoremap <leader>r :source $MYVIMRC<CR>
" Save file
"nnoremap <leader>w :w<CR>
" Install Plugins
"nnoremap <leader>i :w<CR>:source $MYVIMRC<CR>:PlugInstall<CR>
" Nerd Tree!!! (I think)
" Change Ctrl N mapping to Ctrl Space "
inoremap <C-space> <C-n>
" Clip Board!!!
" " Copy to clipboard
vnoremap <leader>y "+y
nnoremap <leader>Y "+yg_
@ -26,27 +60,27 @@ vnoremap <leader>p "+p
vnoremap <leader>P "+P
" tab navigation mappings
" Tab navigation mappings
" New tab
map <C-t> :tabnew<CR>
imap <C-t> <ESC>:tabnew<CR>
" map <C-t> :tabnew<CR>
" imap <C-t> <ESC>:tabnew<CR>
" Close tab
map <C-q> :tabclose<CR>
imap <C-q> :tabclose<CR>
" map <C-q> :tabclose<CR>
" imap <C-q> :tabclose<CR>
" Move Right
map <C-l> :tabn<CR>
imap <C-l> <ESC>:tabn<CR>
map <C-j> :tabn<CR>
imap <C-j> <ESC>:tabn<CR>
" map <C-l> :tabn<CR>
" imap <C-l> <ESC>:tabn<CR>
" map <C-j> :tabn<CR>
" imap <C-j> <ESC>:tabn<CR>
" Move Left
map <C-h> :tabp<CR>
imap <C-h> <ESC>:tabp<CR>
map <C-k> :tabp<CR>
imap <C-k> <ESC>:tabp<CR>
" map <C-h> :tabp<CR>
" imap <C-h> <ESC>:tabp<CR>
" map <C-k> :tabp<CR>
" imap <C-k> <ESC>:tabp<CR>
" clear search results
nnoremap <silent> // :noh<CR>

View File

@ -0,0 +1,266 @@
-- since this is just an example spec, don't actually load anything here and return an empty spec
-- stylua: ignore
-- if true then return {} end
-- every spec file under config.plugins will be loaded automatically by lazy.nvim
--
-- In your plugin files, you can:
-- * add extra plugins
-- * disable/enabled LazyVim plugins
-- * override the configuration of LazyVim plugins
return {
-- add gruvbox
{ "ellisonleao/gruvbox.nvim" },
-- Configure LazyVim to load gruvbox
{
"LazyVim/LazyVim",
opts = {
colorscheme = "gruvbox",
},
},
-- change trouble config
{
"folke/trouble.nvim",
-- opts will be merged with the parent spec
opts = { use_diagnostic_signs = true },
},
-- disable trouble
{ "folke/trouble.nvim", enabled = false },
-- add symbols-outline
{
"simrat39/symbols-outline.nvim",
cmd = "SymbolsOutline",
keys = { { "<leader>cs", "<cmd>SymbolsOutline<cr>", desc = "Symbols Outline" } },
config = true,
},
-- override nvim-cmp and add cmp-emoji
{
"hrsh7th/nvim-cmp",
dependencies = { "hrsh7th/cmp-emoji" },
---@param opts cmp.ConfigSchema
opts = function(_, opts)
local cmp = require("cmp")
opts.sources = cmp.config.sources(vim.list_extend(opts.sources, { { name = "emoji" } }))
end,
},
-- change some telescope options and a keymap to browse plugin files
{
"nvim-telescope/telescope.nvim",
keys = {
-- add a keymap to browse plugin files
-- stylua: ignore
{
"<leader>fp",
function() require("telescope.builtin").find_files({ cwd = require("lazy.core.config").options.root }) end,
desc = "Find Plugin File",
},
},
-- change some options
opts = {
defaults = {
layout_strategy = "horizontal",
layout_config = { prompt_position = "top" },
sorting_strategy = "ascending",
winblend = 0,
},
},
},
-- add telescope-fzf-native
{
"telescope.nvim",
dependencies = {
"nvim-telescope/telescope-fzf-native.nvim",
build = "make",
config = function()
require("telescope").load_extension("fzf")
end,
},
},
-- add pyright to lspconfig
{
"neovim/nvim-lspconfig",
---@class PluginLspOpts
opts = {
---@type lspconfig.options
servers = {
-- pyright will be automatically installed with mason and loaded with lspconfig
pyright = {},
},
},
},
-- add tsserver and setup with typescript.nvim instead of lspconfig
{
"neovim/nvim-lspconfig",
dependencies = {
"jose-elias-alvarez/typescript.nvim",
init = function()
require("lazyvim.util").on_attach(function(_, buffer)
-- stylua: ignore
vim.keymap.set( "n", "<leader>co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" })
vim.keymap.set("n", "<leader>cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer })
end)
end,
},
---@class PluginLspOpts
opts = {
---@type lspconfig.options
servers = {
-- tsserver will be automatically installed with mason and loaded with lspconfig
tsserver = {},
},
-- you can do any additional lsp server setup here
-- return true if you don't want this server to be setup with lspconfig
---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
setup = {
-- example to setup with typescript.nvim
tsserver = function(_, opts)
require("typescript").setup({ server = opts })
return true
end,
-- Specify * to use this function as a fallback for any server
-- ["*"] = function(server, opts) end,
},
},
},
-- for typescript, LazyVim also includes extra specs to properly setup lspconfig,
-- treesitter, mason and typescript.nvim. So instead of the above, you can use:
{ import = "lazyvim.plugins.extras.lang.typescript" },
-- add more treesitter parsers
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = {
"bash",
"html",
"javascript",
"json",
"lua",
"markdown",
"markdown_inline",
"python",
"query",
"regex",
"tsx",
"typescript",
"vim",
"yaml",
},
},
},
-- since `vim.tbl_deep_extend`, can only merge tables and not lists, the code above
-- would overwrite `ensure_installed` with the new value.
-- If you'd rather extend the default config, use the code below instead:
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
-- add tsx and treesitter
vim.list_extend(opts.ensure_installed, {
"tsx",
"typescript",
})
end,
},
-- the opts function can also be used to change the default opts:
{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
opts = function(_, opts)
table.insert(opts.sections.lualine_x, "😄")
end,
},
-- or you can return new options to override all the defaults
{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
opts = function()
return {
--[[add your custom lualine config here]]
}
end,
},
-- use mini.starter instead of alpha
{ import = "lazyvim.plugins.extras.ui.mini-starter" },
-- add jsonls and schemastore ans setup treesitter for json, json5 and jsonc
{ import = "lazyvim.plugins.extras.lang.json" },
-- add any tools you want to have installed below
{
"williamboman/mason.nvim",
opts = {
ensure_installed = {
"stylua",
"shellcheck",
"shfmt",
"flake8",
},
},
},
-- Use <tab> for completion and snippets (supertab)
-- first: disable default <tab> and <s-tab> behavior in LuaSnip
{
"L3MON4D3/LuaSnip",
keys = function()
return {}
end,
},
-- then: setup supertab in cmp
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-emoji",
},
---@param opts cmp.ConfigSchema
opts = function(_, opts)
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local luasnip = require("luasnip")
local cmp = require("cmp")
opts.mapping = vim.tbl_extend("force", opts.mapping, {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
-- they way you will only jump inside the snippet region
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
})
end,
},
}

View File

@ -1,39 +1,69 @@
" ------------------------------------------------------------------------------
" Neoconfig by Shawn Anderson starting September 30 2020
set cursorline
set autoread
" ignores case of letters on searches
set ignorecase
" Override the 'ignorecase' option if the search pattern contains upper case characters
set smartcase
" Follow the open file
set autochdir
" Don't produce swap files
set noswapfile
set tags=tags
"
" ------------------------------------------------------------------------------
" These are inherited from MattCoding4Days
"" Make vim scroll faster
" Something about tags... going to get away from tags.
"set tags=tags
" Make vim scroll faster
set ttyfast " Removed in Nvim "
set mouse=a
" Finish updates before redrawing screen
set lazyredraw
set nu
" Mouse support All
set mouse=a
" Line Numbers
set number
" Relative line numbers
set relativenumber!
" No line wrap
set nowrap
set relativenumber
" Encoding
set encoding=UTF-8
" set tabline to (not) display full path
set guitablabel=%F
" set guitablabel=%F " Set to remove
" Always display tabline
set showtabline=2
" tabs and spaces handling
set expandtab
set tabstop=4
" Tabs and spaces handling
set expandtab " Uses spaces instead of tabs
set tabstop=4 " Number of spaces per tab "
set softtabstop=4
set shiftwidth=4
" remove ugly vertical lines on window division
" Windowing Splitting
" Remove ugly vertical lines on window division
set fillchars+=vert:\
" autocompletion of files and commands behaves like shell
" Autocompletion of files and commands behaves like shell
" (complete only the common part, list the options that match)
set wildmode=list:longest
" when scrolling, keep cursor 3 lines away from screen border
set scrolloff=3
" fix problems with uncommon shells (fish, xonsh) and plugins running commands
" (neomake, ...)
set shell=$SHELL

View File

@ -1,4 +1,3 @@
"" Color Scheme set up for Material ===============================
if (has("nvim"))
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >