mirror of
https://github.com/stevenproctor/dotfiles.git
synced 2026-01-28 11:29:56 -06:00
move nvim config to here to use stow
This commit is contained in:
96
nvim/.config/nvim/fnl/my_nvim/core.fnl
Normal file
96
nvim/.config/nvim/fnl/my_nvim/core.fnl
Normal file
@@ -0,0 +1,96 @@
|
||||
(module my_vim.core
|
||||
{autoload
|
||||
{a aniseed.core}
|
||||
require
|
||||
{nvim aniseed.nvim}})
|
||||
|
||||
|
||||
(nvim.ex.set "shortmess+=c") ; don't give |ins-completion-menu| messages.
|
||||
(nvim.ex.set "path+=**")
|
||||
(nvim.ex.set "wildignore+=*.o,*.obj,.git,*.rbc,*.class,.svn,vendor/gems/*")
|
||||
|
||||
(defn- safe-source
|
||||
[filename]
|
||||
(let [glob (nvim.fn.glob filename)]
|
||||
(if (not (a.empty? glob))
|
||||
(nvim.ex.source filename))))
|
||||
|
||||
(a.map safe-source ["~/.vimrc" "~/.vimrc.local"])
|
||||
|
||||
|
||||
(def- backup-dir "$HOME/.vim/backup")
|
||||
(def- undo-dir "$HOME.vim/undo")
|
||||
|
||||
(def- on-opts [
|
||||
:autoindent
|
||||
:autoread
|
||||
:expandtab
|
||||
:exrc ; allow project level (neo)vim files
|
||||
:hlsearch
|
||||
:ignorecase
|
||||
:incsearch
|
||||
:number
|
||||
:ruler
|
||||
:secure
|
||||
:shiftround ; When at 3 spaces and I hit >>, go to 4, not 5.
|
||||
:showcmd ; shows (parital) command in the status line
|
||||
:showmatch
|
||||
:smartcase
|
||||
:splitbelow
|
||||
:splitright
|
||||
:termguicolors
|
||||
:title
|
||||
:undofile
|
||||
:wildmenu
|
||||
])
|
||||
|
||||
|
||||
(def- val-based-opts
|
||||
{
|
||||
:t_Co 256
|
||||
:laststatus 2
|
||||
:encoding "utf-8"
|
||||
:history 500
|
||||
:redrawtime 5000
|
||||
:scrolloff 3
|
||||
:guifont "Hasklig"
|
||||
:background "dark"
|
||||
:backupdir backup-dir
|
||||
:directory backup-dir ;Don't clutter my dirs up with swp and tmp files
|
||||
:grepprg "ag" ; Use Silver Searcher instead of grep
|
||||
:tags "tags"
|
||||
:updatetime 300 ; per coc.vim for diagnostic messages
|
||||
:signcolumn "auto:1-3"
|
||||
:cmdheight 2 ; Better display for messages
|
||||
:undodir undo-dir
|
||||
:undolevels 1000
|
||||
:undoreload 10000
|
||||
:foldmethod "expr"
|
||||
:foldexpr "nvim_treesitter#foldexpr()"
|
||||
:foldlevelstart 99
|
||||
:foldlevel 99
|
||||
:tabstop 2
|
||||
:shiftwidth 2
|
||||
:softtabstop 2
|
||||
:list "listchars=tab:➥\\ ,trail:·"
|
||||
:backspace "indent,eol,start" ;allow backspacing over everything in insert mode
|
||||
:wildmode "list:longest,list:full"
|
||||
:wrap "off"
|
||||
})
|
||||
|
||||
(defn- set-opt
|
||||
[[opt val]]
|
||||
(tset vim.opt (a.str opt) val))
|
||||
|
||||
(defn- set-opt-on
|
||||
[opt]
|
||||
(set-opt [opt true]))
|
||||
|
||||
(a.map set-opt-on on-opts)
|
||||
|
||||
(a.map set-opt val-based-opts)
|
||||
|
||||
(nvim.ex.syntax "on")
|
||||
(nvim.ex.colorscheme "solarized8")
|
||||
|
||||
(nvim.fn.glob "~/.vimrc.local")
|
||||
10
nvim/.config/nvim/fnl/my_nvim/init.fnl
Normal file
10
nvim/.config/nvim/fnl/my_nvim/init.fnl
Normal file
@@ -0,0 +1,10 @@
|
||||
(module my_vim.init
|
||||
{autoload
|
||||
{a aniseed.core}
|
||||
require
|
||||
{nvim aniseed.nvim}})
|
||||
|
||||
(nvim.ex.source "~/.vimrc")
|
||||
|
||||
(require :my_nvim.core)
|
||||
(require :my_nvim.mapping)
|
||||
59
nvim/.config/nvim/fnl/my_nvim/mapping.fnl
Normal file
59
nvim/.config/nvim/fnl/my_nvim/mapping.fnl
Normal file
@@ -0,0 +1,59 @@
|
||||
(module my_nvim.mapping
|
||||
{autoload {nvim aniseed.nvim
|
||||
nu aniseed.nvim.util
|
||||
core aniseed.core}})
|
||||
|
||||
(defn- noremap [mode from to]
|
||||
"Sets a mapping with {:noremap true}."
|
||||
(nvim.set_keymap mode from to {:noremap true}))
|
||||
|
||||
; (set nvim.g.mapleader "\\")
|
||||
|
||||
(noremap :n "<leader>`" ":source ~/.config/nvim/init.lua<CR>")
|
||||
|
||||
(noremap :n :<Enter> ":nohlsearch<Enter>/<BS>")
|
||||
|
||||
;; Correct to first spelling suggestion.
|
||||
(noremap :n :<leader>zz ":normal! 1z=<cr>")
|
||||
|
||||
|
||||
;; nice paste from clipboard in insert mode
|
||||
(noremap :i :<C-V><C-O> ":set paste<CR><C-R><C-R>+<C-O>:set nopaste<CR>")
|
||||
|
||||
|
||||
; Insert Date
|
||||
(noremap :n :<F5> "\"=strftime(\"%F\")<CR>p")
|
||||
(noremap :i :<F5> "<C-R>=strftime(\"%F\")<CR>")
|
||||
|
||||
; Make markdown link with empty url
|
||||
;map <Leader>ah S<a href="" target="_blank" rel="noopener noreferrer"><CR>
|
||||
(noremap :v :<leader>ah "S<a href=\"\" target=\"_blank\" rel=\"nopener noreferrer\"><CR>")
|
||||
(noremap :v :<leader>ml "xi[<c-r>\"]()<esc>")
|
||||
|
||||
|
||||
(noremap :n :<C-e> "3<C-e>")
|
||||
(noremap :n :<C-y> "3<C-y>")
|
||||
|
||||
; Unimpaired configuration
|
||||
; Bubble single lines
|
||||
(noremap :n :<C-k> "[e")
|
||||
(noremap :n :<C-j> "]e")
|
||||
; Bubble multiple lines
|
||||
(noremap :v :<C-k> "[egv")
|
||||
(noremap :v :<C-j> "]egv")
|
||||
|
||||
; Format JSON
|
||||
(noremap :n :<leader>jpp ":%!python -m json.tool --indent=2<CR>")
|
||||
|
||||
; Map w!! to write readonly files
|
||||
(noremap :c :w!! "w !sudo tee % >/dev/null")
|
||||
|
||||
(noremap :n :gnh ":GitGutterNextHunk<CR>")
|
||||
(noremap :n :gph ":GitGutterPrevHunk<CR>")
|
||||
(noremap :n :gsh ":GitGutterStageHunk<CR>")
|
||||
|
||||
(noremap :n :<leader>li "<Cmd>LspInfo<CR>")
|
||||
;vim.api.nvim_set_keymap('n', '<leader>li', '<Cmd>LspInfo<CR>', { noremap=true, silent=true })
|
||||
|
||||
; Open file in Marked 2 (markdown viewer)
|
||||
(noremap :n :<leader>mv ":AsyncRun -mode=bang open -a Marked\\ 2.app \'%:p\'<cr>")
|
||||
111
nvim/.config/nvim/init.lua
Normal file
111
nvim/.config/nvim/init.lua
Normal file
@@ -0,0 +1,111 @@
|
||||
-- Source init.vim for migration of vimrc to neovim
|
||||
vim.fn.sign_define("LspDiagnosticsSignError",
|
||||
{texthl = "LspDiagnosticsSignError", text = "☢️", numhl = "LspDiagnosticsSignError"})
|
||||
vim.fn.sign_define("LspDiagnosticsSignWarning",
|
||||
{texthl = "LspDiagnosticsSignWarning", text = "⚠️", numhl = "LspDiagnosticsSignWarning"})
|
||||
vim.fn.sign_define("LspDiagnosticsSignHint",
|
||||
{texthl = "LspDiagnosticsSignHint", text = "🔎", numhl = "LspDiagnosticsSignHint"})
|
||||
vim.fn.sign_define("LspDiagnosticsSignInformation",
|
||||
{texthl = "LspDiagnosticsSignInformation", text = "ℹ️", numhl = "LspDiagnosticsSignInformation"})
|
||||
|
||||
local nvim_lsp = require('lspconfig')
|
||||
|
||||
function LspExecuteCommand(cmd, ...)
|
||||
arguments = {vim.uri_from_bufnr(0), vim.api.nvim_win_get_cursor(0)[1] - 1, vim.api.nvim_win_get_cursor(0)[2] -1}
|
||||
for _,a in pairs({...}) do table.insert(arguments, a) end
|
||||
vim.lsp.buf.execute_command({command = cmd, arguments = arguments})
|
||||
end
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
local on_attach = function(client, bufnr)
|
||||
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
||||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
|
||||
--Enable completion triggered by <c-x><c-o>
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- Mappings.
|
||||
local opts = { noremap=true, silent=true }
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
buf_set_keymap('n', 'gs', '<Cmd>lua vim.lsp.buf.document_symbol()<CR>', opts)
|
||||
buf_set_keymap('n', 'gS', '<Cmd>lua vim.lsp.buf.workspace_symbol()<CR>', opts)
|
||||
buf_set_keymap('n', 'gt', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
buf_set_keymap('n', '[g', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
buf_set_keymap('n', ']g', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>cn', "<cmd>lua LspExecuteCommand('clean-ns')<CR>", opts)
|
||||
buf_set_keymap('n', '<leader>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>ref', "<cmd>lua LspExecuteCommand('extract-function', vim.api.nvim_eval(\"input('Function name: ')\"))<CR>", opts)
|
||||
buf_set_keymap('x', '<leader>ref', "<cmd>lua LspExecuteCommand('extract-function', vim.api.nvim_eval(\"input('Function name: ')\"))<CR>", opts)
|
||||
buf_set_keymap('n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>fa', "<cmd>lua vim.lsp.buf.formatting_sync()<CR>", opts)
|
||||
buf_set_keymap('x', '<leader>fa', "<cmd>lua vim.lsp.buf.formatting_sync()<CR>", opts)
|
||||
buf_set_keymap('n', '<leader>ic', "<cmd>lua vim.lsp.buf.incoming_calls()<CR>", opts)
|
||||
buf_set_keymap('x', '<leader>ic', "<cmd>lua vim.lsp.buf.incoming_calls()<CR>", opts)
|
||||
buf_set_keymap('n', '<leader>id', "<cmd>lua LspExecuteCommand('inline-symbol')<CR>", opts)
|
||||
buf_set_keymap('x', '<leader>id', "<cmd>lua LspExecuteCommand('inline-symbol')<CR>", opts)
|
||||
buf_set_keymap('n', '<leader>il', "<cmd>lua LspExecuteCommand('introduce-let', vim.api.nvim_eval(\"input('Binding name: ')\"))<CR>", opts)
|
||||
buf_set_keymap('x', '<leader>il', "<cmd>lua LspExecuteCommand('introduce-let', vim.api.nvim_eval(\"input('Binding name: ')\"))<CR>", opts)
|
||||
buf_set_keymap('n', '<leader>m2l', "<cmd>lua LspExecuteCommand('move-to-let', vim.api.nvim_eval(\"input('Binding name: ')\"))<CR>", opts)
|
||||
buf_set_keymap('x', '<leader>m2l', "<cmd>lua LspExecuteCommand('move-to-let', vim.api.nvim_eval(\"input('Binding name: ')\"))<CR>", opts)
|
||||
|
||||
vim.api.nvim_command[[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()]]
|
||||
-- vim.api.nvim_command[[autocmd BufWritePre <buffer> lua vim.lsp.buf_request_sync(vim.api.nvim_get_current_buf(), 'workspace/executeCommand', {command = 'clean-ns', arguments = {vim.uri_from_bufnr(0), vim.api.nvim_win_get_cursor(0)[1], vim.api.nvim_win_get_cursor(0)[2]}, title = 'Clean Namespace'})]]
|
||||
|
||||
vim.api.nvim_command[[lua print("Lsp Client Attached.")]]
|
||||
end
|
||||
|
||||
|
||||
-- vim.api.nvim_set_keymap('n', '<leader>li', '<Cmd>LspInfo<CR>', { noremap=true, silent=true })
|
||||
|
||||
|
||||
local function setup_servers()
|
||||
require'lspinstall'.setup()
|
||||
local servers = require'lspinstall'.installed_servers()
|
||||
for _, server in pairs(servers) do
|
||||
require'lspconfig'[server].setup{
|
||||
on_attach = on_attach,
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
setup_servers()
|
||||
|
||||
-- Automatically reload after `:LspInstall <server>` so we don't have to restart neovim
|
||||
require'lspinstall'.post_install_hook = function ()
|
||||
setup_servers() -- reload installed servers
|
||||
vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server
|
||||
end
|
||||
|
||||
|
||||
-- require'nvim-treesitter.configs'.setup {
|
||||
-- ensure_installed = "all", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
|
||||
-- -- ignore_install = { "javascript" }, -- List of parsers to ignore installing
|
||||
-- -- highlight = {
|
||||
-- -- enable = true, -- false will disable the whole extension
|
||||
-- -- disable = { "c", "rust" }, -- list of language that will be disabled
|
||||
-- -- -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- -- -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
-- -- -- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||
-- -- -- Instead of true it can also be a list of languages
|
||||
-- -- additional_vim_regex_highlighting = false,
|
||||
-- -- },
|
||||
-- }
|
||||
--
|
||||
--
|
||||
vim.g["aniseed#env"] = { module = "my_nvim.init" }
|
||||
12
nvim/.config/nvim/tools.lua
Normal file
12
nvim/.config/nvim/tools.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
local api = vim.api
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.makeScratch()
|
||||
api.nvim_command [[enew]] -- equivalent to :enew
|
||||
vim.bo[0].buftype=nofile -- set the current buffer's (buffer 0) buftype to nofile
|
||||
vim.bo[0].bufhidden=hide
|
||||
vim.bo[0].swapfile=false
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user