2022-08-16 01:59:31 +00:00
|
|
|
-- What: Mono-file nvim configuration file
|
|
|
|
-- Why: Easy to see through everything without needing to navigate thru files
|
|
|
|
-- Features:
|
|
|
|
-- - LSP
|
|
|
|
-- - Auto-complete (in insert mode: ctrl-space, navigate w/ Tab+S-Tab, confirm: Enter)
|
2022-09-24 23:49:40 +00:00
|
|
|
-- - <leader>df to format document
|
2022-08-22 09:17:11 +00:00
|
|
|
-- - Harpoon marks: Navigate through main files within each project
|
2022-09-07 06:06:13 +00:00
|
|
|
--
|
|
|
|
-- REQUIREMENTS:
|
2022-11-19 15:24:41 +00:00
|
|
|
-- - zk @ https://github.com/mickael-menu/zk
|
2022-09-24 23:49:40 +00:00
|
|
|
-- - prettierd @ npm install -g @fsouza/prettierd
|
2022-08-16 01:59:31 +00:00
|
|
|
|
2022-08-14 08:57:04 +00:00
|
|
|
vim.cmd([[
|
2022-11-22 03:09:44 +00:00
|
|
|
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
|
2022-11-22 08:12:15 +00:00
|
|
|
let plug_path = data_dir . '/autoload/plug.vim'
|
|
|
|
if empty(glob(plug_path))
|
|
|
|
execute '!curl -fLo '.plug_path.' --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
|
|
|
|
execute 'so '.plug_path
|
2022-08-14 08:57:04 +00:00
|
|
|
endif
|
2022-08-14 07:48:17 +00:00
|
|
|
]])
|
2022-11-22 08:12:15 +00:00
|
|
|
|
2023-01-10 15:30:52 +00:00
|
|
|
local function truthy(v) return v ~= nil end
|
|
|
|
|
|
|
|
local function cfg(cfg_var, do_fn) if truthy(cfg_var) then do_fn() end end
|
|
|
|
|
2022-11-22 06:21:46 +00:00
|
|
|
-- vim-plug
|
2022-08-14 08:57:04 +00:00
|
|
|
local Plug = vim.fn['plug#']
|
2022-11-22 05:36:18 +00:00
|
|
|
|
2022-11-22 08:12:15 +00:00
|
|
|
vim.call('plug#begin')
|
2022-09-24 23:49:40 +00:00
|
|
|
|
2022-08-15 06:45:08 +00:00
|
|
|
-- libs and dependencies
|
2023-01-10 15:30:52 +00:00
|
|
|
Plug('nvim-lua/plenary.nvim') -- The base of all plugins
|
2022-08-15 06:45:08 +00:00
|
|
|
|
2022-08-15 09:05:14 +00:00
|
|
|
-- plugins
|
2022-11-07 18:15:34 +00:00
|
|
|
Plug('tjdevries/nlua.nvim') -- adds symbols of vim stuffs in init.lua
|
2022-08-16 01:59:31 +00:00
|
|
|
Plug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighting
|
2022-08-15 06:45:08 +00:00
|
|
|
Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects
|
2022-11-22 05:36:18 +00:00
|
|
|
Plug('nvim-telescope/telescope.nvim', { branch = '0.1.x' }) -- file browser
|
2023-01-10 15:30:52 +00:00
|
|
|
-- TODO: this might need to be taken extra care in our Nix config
|
|
|
|
-- What this Plug declaration means is this repo needs to be built on our running environment
|
|
|
|
-- -----
|
|
|
|
-- What to do:
|
|
|
|
-- - Run `make` at anytime before Nix is done on this repository
|
|
|
|
-- - Might mean that we fetch this repository, run make, and copy to destination folder
|
|
|
|
-- - Make sure that if we run `make` at first Plug run, that `make` is idempotent
|
|
|
|
-- OR
|
|
|
|
-- Make sure that Plug does not run `make` and use the output it needs
|
2022-08-22 09:17:11 +00:00
|
|
|
Plug('nvim-telescope/telescope-fzf-native.nvim',
|
2022-11-22 05:36:18 +00:00
|
|
|
{ ['do'] = 'make >> /tmp/log 2>&1' })
|
2022-08-22 09:17:11 +00:00
|
|
|
Plug('nvim-telescope/telescope-file-browser.nvim')
|
2022-09-24 23:49:40 +00:00
|
|
|
|
2022-08-15 06:45:08 +00:00
|
|
|
-- cmp: auto-complete/suggestions
|
|
|
|
Plug('neovim/nvim-lspconfig') -- built-in LSP configurations
|
|
|
|
Plug('hrsh7th/cmp-nvim-lsp')
|
2022-11-22 01:53:03 +00:00
|
|
|
Plug('hrsh7th/cmp-path')
|
2022-08-15 06:45:08 +00:00
|
|
|
Plug('hrsh7th/cmp-buffer')
|
2022-11-22 01:09:48 +00:00
|
|
|
Plug('hrsh7th/cmp-cmdline')
|
2022-08-15 06:45:08 +00:00
|
|
|
Plug('hrsh7th/nvim-cmp')
|
|
|
|
Plug('onsails/lspkind-nvim')
|
2022-11-24 00:18:38 +00:00
|
|
|
Plug('yioneko/nvim-yati', { tag = '*' }) -- copium: fix Python indent auto-correct from smart-indent
|
2022-10-12 00:06:09 +00:00
|
|
|
-- Plug('tzachar/cmp-tabnine', { ['do'] = './install.sh' })
|
2022-09-24 23:49:40 +00:00
|
|
|
|
2022-08-15 06:45:08 +00:00
|
|
|
-- DevExp
|
2022-08-31 14:39:47 +00:00
|
|
|
Plug('windwp/nvim-autopairs') -- matches pairs like [] (),...
|
|
|
|
Plug('windwp/nvim-ts-autotag') -- matches tags <body>hello</body>
|
2022-09-02 14:00:54 +00:00
|
|
|
Plug('NMAC427/guess-indent.nvim') -- guesses the indentation of an opened buffer
|
2022-08-15 09:05:14 +00:00
|
|
|
Plug('numToStr/Comment.nvim') -- "gc" to comment visual regions/lines
|
2022-08-15 06:45:08 +00:00
|
|
|
Plug('lewis6991/gitsigns.nvim') -- add git info to sign columns
|
|
|
|
Plug('tpope/vim-fugitive') -- git commands in nvim
|
2022-08-15 09:05:14 +00:00
|
|
|
Plug('williamboman/mason.nvim') -- LSP, debuggers,... package manager
|
|
|
|
Plug('williamboman/mason-lspconfig.nvim') -- lsp config for mason
|
2022-08-16 04:59:49 +00:00
|
|
|
Plug('ThePrimeagen/harpoon') -- 1-click through marked files per project
|
2022-09-24 06:03:47 +00:00
|
|
|
Plug('TimUntersberger/neogit') -- Easy-to-see git status
|
2022-09-24 23:49:40 +00:00
|
|
|
Plug('folke/trouble.nvim') -- File-grouped workspace diagnostics
|
2022-10-12 00:06:09 +00:00
|
|
|
Plug('tpope/vim-dispatch') -- Allows quick build/compile/test vim commands
|
|
|
|
Plug('clojure-vim/vim-jack-in') -- Clojure: ":Boot", ":Clj", ":Lein"
|
|
|
|
Plug('radenling/vim-dispatch-neovim') -- Add support for neovim's terminal emulator
|
|
|
|
Plug('Olical/conjure') -- REPL on the source for Clojure (and other LISPs)
|
2022-10-13 00:47:16 +00:00
|
|
|
Plug('gennaro-tedesco/nvim-jqx') -- JSON formatter (use :Jqx*)
|
|
|
|
Plug('kylechui/nvim-surround') -- surrounds with tags/parenthesis
|
2022-10-26 12:09:47 +00:00
|
|
|
Plug('simrat39/rust-tools.nvim') -- config rust-analyzer and nvim integration
|
2022-08-15 06:45:08 +00:00
|
|
|
|
|
|
|
-- UI & colorscheme
|
2023-01-15 12:48:11 +00:00
|
|
|
Plug('simrat39/inlay-hints.nvim') -- type-hints with pseudo-virtual texts
|
|
|
|
Plug('gruvbox-community/gruvbox') -- theme provider
|
|
|
|
Plug('nvim-lualine/lualine.nvim') -- fancy status line
|
|
|
|
Plug('lukas-reineke/indent-blankline.nvim') -- identation lines on blank lines
|
|
|
|
Plug('kyazdani42/nvim-web-devicons') -- icons for folder and filetypes
|
|
|
|
Plug('m-demare/hlargs.nvim') -- highlights arguments; great for func prog
|
|
|
|
Plug('folke/todo-comments.nvim') -- Highlights TODO
|
2022-08-15 06:45:08 +00:00
|
|
|
|
2022-09-24 23:49:40 +00:00
|
|
|
-- other utilities
|
2022-08-15 09:05:14 +00:00
|
|
|
Plug('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' })
|
2022-11-24 00:18:38 +00:00
|
|
|
Plug('nvim-treesitter/nvim-treesitter-context') -- Top one-liner context of func/class scope
|
|
|
|
Plug('nvim-treesitter/playground') -- Sees Treesitter AST - less hair pulling, more PRs
|
2022-08-15 09:05:14 +00:00
|
|
|
Plug('saadparwaiz1/cmp_luasnip') -- snippet engine
|
|
|
|
Plug('L3MON4D3/LuaSnip') -- snippet engine
|
2022-08-27 12:34:55 +00:00
|
|
|
Plug('mickael-menu/zk-nvim') -- Zettelkasten
|
2023-01-10 15:30:52 +00:00
|
|
|
-- Switch cases:
|
|
|
|
-- `gsp` -> PascalCase (classes), `gsc` -> camelCase (Java), `gs_` -> snake_case (C/C++/Rust)
|
|
|
|
-- `gsu` -> UPPER_CASE (CONSTs), `gsk` -> kebab-case (Clojure), `gsK` -> Title-Kebab-Case
|
|
|
|
-- `gs.` -> dot.case (R)
|
|
|
|
Plug('arthurxavierx/vim-caser') -- switch cases
|
2022-08-15 06:45:08 +00:00
|
|
|
|
|
|
|
---------
|
2022-08-14 08:57:04 +00:00
|
|
|
vim.call('plug#end')
|
|
|
|
|
2022-11-22 08:12:15 +00:00
|
|
|
vim.cmd([[
|
2022-11-24 00:18:38 +00:00
|
|
|
if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
|
|
|
|
PlugInstall --sync | autocmd VimEnter * so $MYVIMRC
|
|
|
|
endif
|
2022-11-22 08:12:15 +00:00
|
|
|
]])
|
2022-11-22 05:36:18 +00:00
|
|
|
|
2022-12-30 03:19:02 +00:00
|
|
|
-- special terminals, place them at 4..=7 for ergonomics
|
2023-01-10 15:30:52 +00:00
|
|
|
vim.api.nvim_create_autocmd({ "VimEnter" }, {
|
2022-12-30 03:19:02 +00:00
|
|
|
callback = function()
|
2022-12-30 04:34:19 +00:00
|
|
|
local function named_term(term_idx, term_name)
|
|
|
|
require('harpoon.term').gotoTerminal(term_idx)
|
2023-01-10 15:30:52 +00:00
|
|
|
vim.cmd([[:exe ":file ]] .. term_name .. [[" | :bfirst]])
|
2022-12-30 04:34:19 +00:00
|
|
|
end
|
2023-01-10 15:30:52 +00:00
|
|
|
|
2022-12-30 04:34:19 +00:00
|
|
|
-- term:ctl at 4
|
|
|
|
named_term(4, "term:ctl")
|
|
|
|
-- term:dev at 5
|
|
|
|
named_term(5, "term:dev")
|
|
|
|
-- term:repl at 7
|
|
|
|
named_term(7, "term:repl")
|
|
|
|
-- term:repl at 6
|
|
|
|
named_term(6, "term:repl2")
|
2022-12-30 03:19:02 +00:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2023-01-15 12:48:11 +00:00
|
|
|
vim.g.gruvbox_contrast_dark="soft";
|
|
|
|
vim.g.gruvbox_contrast_light="soft";
|
|
|
|
vim.opt.ignorecase = true;
|
|
|
|
vim.opt.smartcase = true;
|
|
|
|
vim.opt.incsearch = true;
|
|
|
|
vim.opt.number = true;
|
|
|
|
vim.opt.relativenumber = true;
|
|
|
|
vim.opt.autoindent = true;
|
|
|
|
vim.opt.smartindent = true;
|
|
|
|
vim.opt.expandtab = true;
|
|
|
|
vim.opt.exrc = true;
|
|
|
|
|
|
|
|
vim.opt.tabstop = 4;
|
|
|
|
vim.opt.softtabstop = 4;
|
|
|
|
vim.opt.shiftwidth = 4;
|
|
|
|
vim.opt.scrolloff = 30;
|
|
|
|
vim.opt.signcolumn = "yes";
|
|
|
|
vim.opt.colorcolumn = "80";
|
|
|
|
|
|
|
|
vim.opt.background = "light";
|
|
|
|
|
|
|
|
vim.api.nvim_create_user_command('Dark', function(opts)
|
|
|
|
-- opts: {name, args: str, fargs: Splited<str>, range, ...}
|
|
|
|
---@type string
|
|
|
|
local contrast = (opts.args and string.len(opts.args) > 0) and opts.args or vim.g.gruvbox_contrast_dark;
|
|
|
|
vim.g.gruvbox_contrast_dark = contrast;
|
|
|
|
vim.opt.background = "dark";
|
|
|
|
end,
|
|
|
|
{nargs = "?";})
|
|
|
|
|
|
|
|
vim.api.nvim_create_user_command('Light', function(opts)
|
|
|
|
-- opts: {name, args: str, fargs: Splited<str>, range, ...}
|
|
|
|
---@type string
|
|
|
|
local contrast = (opts.args and string.len(opts.args) > 0) and opts.args or vim.g.gruvbox_contrast_dark;
|
|
|
|
vim.g.gruvbox_contrast_light = contrast;
|
|
|
|
vim.opt.background = "light";
|
|
|
|
end,
|
|
|
|
{nargs = "?";})
|
|
|
|
|
2022-11-22 05:36:18 +00:00
|
|
|
vim.opt.lazyredraw = true
|
|
|
|
vim.opt.termguicolors = true
|
|
|
|
vim.opt.cursorline = true
|
|
|
|
-- some plugins misbehave when we do swap files
|
|
|
|
vim.opt.swapfile = false
|
|
|
|
vim.opt.backup = false
|
2023-01-15 12:48:11 +00:00
|
|
|
vim.opt.undodir = vim.fn.stdpath('state')..'/.vim/undodir'
|
2022-11-22 05:36:18 +00:00
|
|
|
vim.opt.undofile = true
|
|
|
|
vim.opt.completeopt = 'menuone,noselect'
|
|
|
|
-- vim.opt.clipboard = "unnamedplus"
|
2022-11-24 00:18:38 +00:00
|
|
|
-- more aggressive swap file writing. ThePrimeagen believes higher number
|
|
|
|
-- leads to low DX
|
|
|
|
vim.opt.updatetime = 50
|
2022-11-22 05:36:18 +00:00
|
|
|
|
|
|
|
vim.g.mapleader = ' '
|
|
|
|
vim.g.maplocalleader = ','
|
|
|
|
|
|
|
|
-- basic keymaps
|
2022-12-30 10:08:04 +00:00
|
|
|
-- Since we use space for leader, we're asserting that this does nothing by itself
|
|
|
|
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
|
2022-12-30 14:10:55 +00:00
|
|
|
-- make :terminal escape out. For zsh-vi-mode, just use Alt-Z or any keybind
|
2022-12-30 10:08:04 +00:00
|
|
|
-- that does not collide with vi-motion keybind. This is because
|
|
|
|
-- <Alt-x> -> ^[x; while <Esc> on the terminal is ^[
|
|
|
|
vim.keymap.set('t', '<Esc>', '<C-\\><C-n>)')
|
2023-01-10 15:30:52 +00:00
|
|
|
vim.keymap.set({ 'n', 'i', 'v' }, '<c-l>', '<Cmd>mode<Cr>', { desc = "" }) -- redraw on every mode
|
2022-11-22 05:36:18 +00:00
|
|
|
|
|
|
|
-- diagnostics (errors/warnings to be shown)
|
|
|
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
|
|
|
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
|
|
|
|
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float) -- opens diag in box (floating)
|
|
|
|
-- vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist) -- opens list of diags
|
|
|
|
-- vim.keymap.set('n', '<leader>wq', vim.diagnostic.setqflist) -- workspace diags
|
|
|
|
vim.keymap.set('n', '<leader>q', '<cmd>TroubleToggle loclist<cr>')
|
|
|
|
vim.keymap.set('n', '<leader>wq', '<cmd>TroubleToggle workspace_diagnostics<cr>')
|
|
|
|
|
2022-08-15 06:45:08 +00:00
|
|
|
-- color, highlighting, UI stuffs
|
2022-11-22 05:36:18 +00:00
|
|
|
vim.cmd([[
|
|
|
|
colorscheme gruvbox
|
|
|
|
]])
|
2022-09-12 23:20:01 +00:00
|
|
|
require('hlargs').setup()
|
2022-09-24 23:49:40 +00:00
|
|
|
require('nvim-web-devicons').setup()
|
|
|
|
require('trouble').setup()
|
2022-11-29 23:08:44 +00:00
|
|
|
|
|
|
|
-- TODO: Any way to collect all the TODOs and its variants?
|
2022-09-24 23:49:40 +00:00
|
|
|
require('todo-comments').setup()
|
2022-08-14 08:57:04 +00:00
|
|
|
|
2022-08-15 06:45:08 +00:00
|
|
|
-- plugin keymaps
|
2022-09-12 23:20:01 +00:00
|
|
|
|
2022-08-15 09:05:14 +00:00
|
|
|
local function remap(mode, key_cmd, binded_fn, opts)
|
2022-10-26 12:09:47 +00:00
|
|
|
opts = opts or { remap = true }
|
|
|
|
return vim.keymap.set(mode, key_cmd, binded_fn, opts)
|
2022-08-15 06:45:08 +00:00
|
|
|
end
|
2022-08-15 09:05:14 +00:00
|
|
|
|
2022-08-15 06:45:08 +00:00
|
|
|
-- Comment.nvim
|
|
|
|
require('Comment').setup()
|
|
|
|
-- lukas-reineke/indent-blankline.nvim
|
2022-08-16 01:59:31 +00:00
|
|
|
vim.opt.list = true
|
|
|
|
vim.opt.listchars:append "space:⋅"
|
|
|
|
vim.opt.listchars:append "eol:↴"
|
|
|
|
|
|
|
|
require("indent_blankline").setup {
|
2022-10-26 12:09:47 +00:00
|
|
|
show_end_of_line = true,
|
|
|
|
space_char_blankline = " ",
|
2022-08-15 06:45:08 +00:00
|
|
|
}
|
2022-09-24 23:49:40 +00:00
|
|
|
-- User command that transform into 2-spaces by translating to tabstop
|
|
|
|
vim.api.nvim_create_user_command(
|
2022-10-26 12:09:47 +00:00
|
|
|
'HalfSpaces',
|
|
|
|
function(opts)
|
|
|
|
vim.api.nvim_command("set ts=2 sts=2 noet")
|
|
|
|
vim.api.nvim_command("retab!")
|
|
|
|
vim.api.nvim_command("set ts=1 sts=1 et")
|
|
|
|
vim.api.nvim_command("retab")
|
|
|
|
vim.api.nvim_command("GuessIndent")
|
|
|
|
end,
|
|
|
|
{ nargs = 0 }
|
2022-09-24 23:49:40 +00:00
|
|
|
)
|
|
|
|
vim.api.nvim_create_user_command(
|
2022-10-26 12:09:47 +00:00
|
|
|
'DoubleSpaces',
|
|
|
|
function(opts)
|
2022-11-19 15:24:41 +00:00
|
|
|
-- cannot really do 1-space tab. The minimum is 2-space to begin
|
|
|
|
-- doubling
|
|
|
|
vim.api.nvim_command("set ts=2 sts=2 noet")
|
2022-10-26 12:09:47 +00:00
|
|
|
vim.api.nvim_command("retab!")
|
2022-11-19 15:24:41 +00:00
|
|
|
vim.api.nvim_command("set ts=4 sts=4 et")
|
2022-10-26 12:09:47 +00:00
|
|
|
vim.api.nvim_command("retab")
|
|
|
|
vim.api.nvim_command("GuessIndent")
|
|
|
|
end,
|
|
|
|
{ nargs = 0 }
|
2022-09-24 23:49:40 +00:00
|
|
|
)
|
|
|
|
|
2022-08-15 06:45:08 +00:00
|
|
|
-- telescope
|
2022-08-22 09:17:11 +00:00
|
|
|
local fb_actions = require "telescope".extensions.file_browser.actions
|
2022-08-15 06:45:08 +00:00
|
|
|
require('telescope').setup {
|
2022-10-26 12:09:47 +00:00
|
|
|
defaults = {
|
|
|
|
mappings = {
|
|
|
|
i = {
|
|
|
|
['<C-u>'] = false,
|
|
|
|
['<C-d>'] = false,
|
|
|
|
},
|
|
|
|
},
|
2022-10-12 00:06:09 +00:00
|
|
|
},
|
2022-10-26 12:09:47 +00:00
|
|
|
extensions = {
|
|
|
|
fzf = {
|
|
|
|
fuzzy = true, -- allow fuzzy matches
|
|
|
|
override_generic_sorter = true,
|
|
|
|
override_file_sorter = true,
|
|
|
|
case_mode = 'smart_case'
|
|
|
|
},
|
|
|
|
file_browser = {
|
2022-12-26 11:34:17 +00:00
|
|
|
theme = require('telescope.themes').get_ivy().theme,
|
2022-10-26 12:09:47 +00:00
|
|
|
hiject_netrw = true, -- disables netrw and use file-browser instead
|
|
|
|
mappings = {
|
|
|
|
["i"] = {}, -- disable any shortcut in insert mode for now
|
|
|
|
["n"] = {
|
|
|
|
["c"] = fb_actions.create,
|
|
|
|
["r"] = fb_actions.rename,
|
|
|
|
["m"] = fb_actions.move,
|
|
|
|
["y"] = fb_actions.copy,
|
|
|
|
["d"] = fb_actions.remove,
|
|
|
|
["o"] = fb_actions.open,
|
|
|
|
["g"] = fb_actions.goto_parent_dir,
|
|
|
|
["e"] = fb_actions.goto_home_dir,
|
|
|
|
["w"] = fb_actions.goto_cwd,
|
|
|
|
["t"] = fb_actions.change_cwd,
|
|
|
|
["f"] = fb_actions.toggle_browser,
|
|
|
|
["h"] = fb_actions.toggle_hidden,
|
|
|
|
["s"] = fb_actions.toggle_all,
|
|
|
|
}
|
|
|
|
}
|
2022-08-22 09:17:11 +00:00
|
|
|
}
|
2022-08-15 06:45:08 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-27 12:34:55 +00:00
|
|
|
|
2022-09-07 06:06:13 +00:00
|
|
|
-- Telescope key remap stuffs
|
2022-08-15 06:45:08 +00:00
|
|
|
pcall(require('telescope').load_extension, 'fzf')
|
2022-08-22 09:17:11 +00:00
|
|
|
pcall(require('telescope').load_extension, 'file_browser')
|
2022-08-15 09:05:14 +00:00
|
|
|
remap('n', '<C-p>', '<cmd>Telescope<cr>', { desc = 'Open Telescope general search' })
|
2022-08-22 09:17:11 +00:00
|
|
|
|
|
|
|
remap('n', '<leader>fm', function()
|
2022-12-26 11:34:17 +00:00
|
|
|
require("telescope").extensions.file_browser.file_browser({})
|
2022-08-22 09:17:11 +00:00
|
|
|
end, { desc = '[F]ile [M]utation' })
|
|
|
|
|
2022-08-15 09:05:14 +00:00
|
|
|
remap('n', '<leader>ff', function()
|
2022-10-26 12:09:47 +00:00
|
|
|
require('telescope.builtin').find_files({
|
|
|
|
hidden = false,
|
|
|
|
no_ignore = false,
|
|
|
|
follow = false,
|
|
|
|
})
|
2022-08-22 09:17:11 +00:00
|
|
|
end, { desc = '[F]ind [F]ile' })
|
|
|
|
|
|
|
|
remap('n', '<leader>fa', function()
|
2022-12-26 12:32:35 +00:00
|
|
|
require('telescope.builtin').find_files({
|
2022-10-26 12:09:47 +00:00
|
|
|
hidden = true,
|
|
|
|
no_ignore = true,
|
|
|
|
follow = true,
|
2022-12-26 12:32:35 +00:00
|
|
|
})
|
2022-08-31 14:39:47 +00:00
|
|
|
end, { desc = '[F]ind [A]ll files' })
|
2022-08-22 09:17:11 +00:00
|
|
|
|
2022-08-15 09:05:14 +00:00
|
|
|
remap('n', '<leader>fg', function()
|
2022-10-26 12:09:47 +00:00
|
|
|
require('telescope.builtin').live_grep()
|
2022-08-15 09:05:14 +00:00
|
|
|
end, { desc = '[F]ind by [G]rep' })
|
2022-08-22 09:17:11 +00:00
|
|
|
|
2022-08-15 09:05:14 +00:00
|
|
|
remap('n', '<leader>fb', function()
|
2022-10-26 12:09:47 +00:00
|
|
|
require('telescope.builtin').buffers()
|
2022-08-15 09:05:14 +00:00
|
|
|
end, { desc = '[F]ind existing [B]uffers' })
|
2022-08-22 09:17:11 +00:00
|
|
|
|
2022-08-15 09:05:14 +00:00
|
|
|
remap('n', '<leader>fh', function()
|
2022-10-26 12:09:47 +00:00
|
|
|
require('telescope.builtin').help_tags()
|
2022-08-15 09:05:14 +00:00
|
|
|
end, { desc = '[F]ind [H]elp' })
|
2022-08-22 09:17:11 +00:00
|
|
|
|
2022-08-15 09:05:14 +00:00
|
|
|
remap('n', '<leader>fd', function()
|
2022-10-26 12:09:47 +00:00
|
|
|
require('telescope.builtin').diagnostics()
|
2022-08-15 09:05:14 +00:00
|
|
|
end, { desc = '[F]ind [D]iagnostics' })
|
2022-08-22 09:17:11 +00:00
|
|
|
|
2022-09-07 06:06:13 +00:00
|
|
|
-- ZK remap stuffs
|
|
|
|
remap('n', '<leader>zf', function()
|
2022-12-13 05:26:42 +00:00
|
|
|
-- vim.cmd([[:ZkNotes]])
|
2022-12-26 11:34:17 +00:00
|
|
|
require('zk').edit({}, { multi_select = false })
|
2022-09-07 06:06:13 +00:00
|
|
|
end, { desc = '[Z]ettelkasten [F]iles' })
|
|
|
|
|
|
|
|
remap('n', '<leader>zg', function()
|
2022-10-26 12:09:47 +00:00
|
|
|
vim.cmd([[:ZkGrep]])
|
2022-09-07 06:06:13 +00:00
|
|
|
end, { desc = '[Z]ettelkasten [G]rep' })
|
|
|
|
|
2022-08-15 06:45:08 +00:00
|
|
|
-- treesitter
|
2022-11-24 00:18:38 +00:00
|
|
|
require 'treesitter-context'
|
2022-08-15 06:45:08 +00:00
|
|
|
require('nvim-treesitter.configs').setup {
|
2022-11-24 00:18:38 +00:00
|
|
|
yati = {
|
|
|
|
enable = true, default_lazy = true, default_fallback = "auto",
|
|
|
|
disable = { "nix" }
|
|
|
|
},
|
2022-11-23 23:40:33 +00:00
|
|
|
indent = { enable = false },
|
2022-10-26 12:09:47 +00:00
|
|
|
ensure_installed = {
|
|
|
|
'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css',
|
|
|
|
'python', 'prisma', 'html', "dockerfile", "c", "cpp", "hcl", "svelte", "astro",
|
2022-11-24 00:18:38 +00:00
|
|
|
"clojure", "fennel", "bash", "nix", "query",
|
2022-10-26 12:09:47 +00:00
|
|
|
},
|
|
|
|
sync_install = false,
|
2022-11-24 00:26:22 +00:00
|
|
|
highlight = {
|
|
|
|
enable = true,
|
|
|
|
enable_vim_regex_highlighting = true,
|
|
|
|
},
|
2022-10-26 12:09:47 +00:00
|
|
|
incremental_selection = {
|
|
|
|
enable = true,
|
|
|
|
keymaps = {
|
2022-11-19 15:24:41 +00:00
|
|
|
init_selection = '<C-space>',
|
|
|
|
node_incremental = '<C-space>',
|
|
|
|
node_decremental = '<C-backspace>',
|
|
|
|
pscope_incremental = '<C-S>'
|
|
|
|
},
|
2022-10-26 12:09:47 +00:00
|
|
|
},
|
|
|
|
textobjects = {
|
|
|
|
select = {
|
|
|
|
enable = true,
|
|
|
|
lookahead = true,
|
|
|
|
keymaps = {
|
|
|
|
['af'] = '@function.outer',
|
|
|
|
['if'] = '@function.inner',
|
|
|
|
['ac'] = '@class.outer',
|
|
|
|
['ic'] = '@class.inner',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-11-24 00:26:22 +00:00
|
|
|
playground = {
|
|
|
|
enable = true,
|
|
|
|
disable = {}
|
|
|
|
},
|
2022-10-26 12:09:47 +00:00
|
|
|
-- automatically close and modify HTML and TSX tags
|
|
|
|
autotag = {
|
|
|
|
enable = true,
|
2022-08-15 06:45:08 +00:00
|
|
|
},
|
|
|
|
}
|
2022-08-31 14:39:47 +00:00
|
|
|
|
|
|
|
require('nvim-autopairs').setup {
|
2022-10-26 12:09:47 +00:00
|
|
|
check_ts = true,
|
2022-09-02 14:00:54 +00:00
|
|
|
}
|
|
|
|
|
2022-09-07 06:06:13 +00:00
|
|
|
local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
|
2022-09-12 23:20:01 +00:00
|
|
|
parser_config.tsx.filetype_to_parsername = { "javascript", "typescript.tsx" }
|
2022-10-12 00:06:09 +00:00
|
|
|
parser_config.astro.filetype_to_parsername = { "javascript", "typescript.tsx", "astro" }
|
2022-09-07 06:06:13 +00:00
|
|
|
|
|
|
|
|
2022-09-02 14:00:54 +00:00
|
|
|
require('guess-indent').setup {
|
2022-10-26 12:09:47 +00:00
|
|
|
auto_cmd = true, -- Set to false to disable automatic execution
|
|
|
|
filetype_exclude = { -- A list of filetypes for which the auto command gets disabled
|
|
|
|
"netrw",
|
|
|
|
"tutor",
|
|
|
|
},
|
2022-11-19 15:24:41 +00:00
|
|
|
|
2022-10-26 12:09:47 +00:00
|
|
|
buftype_exclude = { -- A list of buffer types for which the auto command gets disabled
|
|
|
|
"help",
|
|
|
|
"nofile",
|
|
|
|
"terminal",
|
|
|
|
-- "prompt",
|
|
|
|
},
|
2022-08-31 14:39:47 +00:00
|
|
|
}
|
|
|
|
|
2022-12-30 04:34:19 +00:00
|
|
|
-- harpoon: O(1) buffer/terminal switching
|
2022-12-29 23:22:16 +00:00
|
|
|
remap('n', '<leader>m', function() require('harpoon.mark').add_file() end, { desc = "[H]arpoon [M]ark" })
|
2022-08-27 12:34:55 +00:00
|
|
|
local function harpoon_nav(key, nav_file_index, lead_keybind)
|
2022-10-26 12:09:47 +00:00
|
|
|
lead_keybind = lead_keybind or '<leader>h'
|
|
|
|
assert(type(key) == "string", "expect key to be string(keybind)")
|
|
|
|
assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index")
|
2022-12-29 23:22:16 +00:00
|
|
|
return remap('n', lead_keybind .. key,
|
|
|
|
function() require('harpoon.ui').nav_file(nav_file_index) end,
|
|
|
|
{ desc = "[H]arpoon navigate " .. tostring(nav_file_index) })
|
2022-08-27 12:34:55 +00:00
|
|
|
end
|
2022-08-31 14:39:47 +00:00
|
|
|
|
2022-08-27 12:34:55 +00:00
|
|
|
-- remap letters to index. Inspired by alternating number of Dvorak programmer
|
|
|
|
-- best practices: try to keep marked files to be around 4
|
|
|
|
harpoon_nav('f', 1)
|
|
|
|
harpoon_nav('j', 2)
|
|
|
|
harpoon_nav('d', 3)
|
|
|
|
harpoon_nav('k', 4)
|
2022-08-22 09:17:11 +00:00
|
|
|
remap('n', '<leader>hh', function() require('harpoon.ui').toggle_quick_menu() end)
|
2022-12-29 23:22:16 +00:00
|
|
|
for i = 1, 10 do
|
|
|
|
-- harpoon: navigate files by numbers
|
|
|
|
harpoon_nav(tostring(i % 10), i)
|
|
|
|
-- harpoon: navigate terms by numbers
|
|
|
|
remap('n', '<leader>t' .. tostring(i % 10), function()
|
|
|
|
require('harpoon.term').gotoTerminal(i)
|
|
|
|
end)
|
|
|
|
end
|
2022-08-15 06:45:08 +00:00
|
|
|
|
2022-12-13 05:26:42 +00:00
|
|
|
-- neogit: easy-to-see git status. Provides only productivity on staging/unstage
|
2022-09-24 06:03:47 +00:00
|
|
|
require('neogit').setup {}
|
2022-12-29 23:22:16 +00:00
|
|
|
remap('n', '<leader>gs', function() require('neogit').open({}) end, { desc = "[G]it [S]tatus" });
|
2022-09-24 06:03:47 +00:00
|
|
|
|
2022-08-15 09:05:14 +00:00
|
|
|
-- LSP settings
|
2022-09-24 23:49:40 +00:00
|
|
|
-- This function gets run when an LSP connects to a particular buffer.
|
2022-11-23 17:02:56 +00:00
|
|
|
require("inlay-hints").setup {
|
2022-12-08 07:12:55 +00:00
|
|
|
only_current_line = false,
|
2022-11-23 17:02:56 +00:00
|
|
|
eol = {
|
2022-12-08 20:25:58 +00:00
|
|
|
right_align = false,
|
2022-11-23 17:02:56 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-22 03:48:24 +00:00
|
|
|
local on_attach = function(client, bufnr)
|
2022-10-26 12:09:47 +00:00
|
|
|
-- 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
|
|
|
|
-- many times.
|
|
|
|
--
|
|
|
|
-- In this case, we create a function that lets us more easily define mappings specific
|
|
|
|
-- 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
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.keymap.set('n', keys, func, { noremap = true, buffer = bufnr, desc = desc })
|
2022-08-15 09:05:14 +00:00
|
|
|
end
|
|
|
|
|
2022-10-26 12:09:47 +00:00
|
|
|
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
|
|
|
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
|
|
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
|
|
nmap('<leader>df', function() vim.lsp.buf.format({ async = true }) end, '[D]ocument [F]ormat')
|
|
|
|
|
|
|
|
-- symbols and gotos
|
|
|
|
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
|
|
|
|
nmap('gi', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
|
|
|
|
nmap('gr', require('telescope.builtin').lsp_references)
|
|
|
|
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')
|
|
|
|
|
|
|
|
-- documentations. 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')
|
2022-11-03 15:28:49 +00:00
|
|
|
nmap('gtd', vim.lsp.buf.type_definition, '[G]oto [T]ype [D]efinition')
|
2022-10-26 12:09:47 +00:00
|
|
|
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
|
|
|
|
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()))
|
2022-11-22 03:48:24 +00:00
|
|
|
|
2022-10-26 12:09:47 +00:00
|
|
|
end, '[W]orkspace [L]ist Folders')
|
2022-09-12 23:20:01 +00:00
|
|
|
|
2022-12-08 07:12:55 +00:00
|
|
|
-- enable inlay hints if available
|
|
|
|
require('inlay-hints').on_attach(client, bufnr)
|
|
|
|
|
2022-08-15 09:05:14 +00:00
|
|
|
end
|
2022-11-21 22:16:34 +00:00
|
|
|
-- nvim-cmp
|
|
|
|
local cmp = require 'cmp'
|
|
|
|
local luasnip = require 'luasnip'
|
|
|
|
local lspkind = require('lspkind')
|
|
|
|
local source_mapping = {
|
|
|
|
buffer = '[Buffer]',
|
|
|
|
nvim_lsp = '[LSP]',
|
|
|
|
nvim_lua = '[Lua]',
|
|
|
|
-- cmp_tabnine = '[T9]',
|
|
|
|
path = '[Path]',
|
|
|
|
}
|
|
|
|
|
2022-11-28 02:04:38 +00:00
|
|
|
cmp.event:on(
|
|
|
|
"confirm_done",
|
|
|
|
require('nvim-autopairs.completion.cmp').on_confirm_done()
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-11-21 22:16:34 +00:00
|
|
|
cmp.setup {
|
|
|
|
snippet = {
|
|
|
|
expand = function(args)
|
|
|
|
luasnip.lsp_expand(args.body)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
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)
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_next_item()
|
|
|
|
elseif luasnip.expand_or_jumpable() then
|
|
|
|
luasnip.expand_or_jump()
|
|
|
|
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' }),
|
|
|
|
},
|
|
|
|
formatting = {
|
|
|
|
format = function(entry, vim_item)
|
|
|
|
vim_item.kind = lspkind.symbolic(vim_item.kind, { mode = 'symbol' })
|
|
|
|
vim_item.menu = source_mapping[entry.source_name]
|
|
|
|
-- if entry.source.name == "cmp_tabnine" then
|
|
|
|
-- local detail = (entry.completion_item.data or {}).detail
|
|
|
|
-- vim_item.kind = ""
|
|
|
|
-- if detail and detail:find('.*%%.*') then
|
|
|
|
-- vim_item.kind = vim_item.kind .. ' ' .. detail
|
|
|
|
-- end
|
|
|
|
--
|
|
|
|
-- if (entry.completion_item.data or {}).multiline then
|
|
|
|
-- vim_item.kind = vim_item.kind .. ' ' .. '[ML]'
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
local maxwidth = 80
|
|
|
|
vim_item.abbr = string.sub(vim_item.abbr, 1, maxwidth)
|
|
|
|
return vim_item
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
sources = cmp.config.sources {
|
|
|
|
{ name = 'nvim_lsp' },
|
|
|
|
{ name = 'luasnip' },
|
2022-11-22 01:09:48 +00:00
|
|
|
{ name = 'buffer' },
|
2022-11-23 23:43:01 +00:00
|
|
|
{ name = 'path' },
|
2022-12-05 07:48:37 +00:00
|
|
|
{ name = "conjure" },
|
2022-11-21 22:16:34 +00:00
|
|
|
-- { name = 'cmp_tabnine' },
|
|
|
|
},
|
|
|
|
}
|
2022-08-15 09:05:14 +00:00
|
|
|
-- nvim-cmp supports additional completion capabilities
|
2022-11-22 01:09:48 +00:00
|
|
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
2022-10-12 00:06:09 +00:00
|
|
|
-- local tabnine = require('cmp_tabnine.config')
|
|
|
|
-- tabnine.setup({
|
2022-11-21 22:16:34 +00:00
|
|
|
-- max_lines = 1000,
|
|
|
|
-- max_num_results = 20,
|
|
|
|
-- sort = true,
|
|
|
|
-- run_on_every_keystroke = true,
|
|
|
|
-- snippet_placeholder = '..',
|
|
|
|
-- ignored_file_types = {},
|
|
|
|
-- show_prediction_strength = true,
|
2022-10-12 00:06:09 +00:00
|
|
|
-- })
|
2022-08-15 09:05:14 +00:00
|
|
|
-- default language servers
|
2022-11-24 00:18:38 +00:00
|
|
|
local servers = {
|
2022-11-23 23:43:44 +00:00
|
|
|
'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals',
|
2023-01-19 23:06:25 +00:00
|
|
|
'rnix', 'eslint', 'terraformls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls", 'yamlls', "ansiblels",
|
2022-12-03 06:43:44 +00:00
|
|
|
"jsonls", "denols"
|
2022-11-23 23:43:44 +00:00
|
|
|
}
|
2022-08-15 09:05:14 +00:00
|
|
|
require("mason").setup({
|
2022-10-26 12:09:47 +00:00
|
|
|
ui = {
|
|
|
|
icons = {
|
|
|
|
package_installed = "✓",
|
|
|
|
package_pending = "➜",
|
|
|
|
package_uninstalled = "✗"
|
|
|
|
},
|
|
|
|
check_outdated_packages_on_open = true,
|
2022-12-03 07:03:20 +00:00
|
|
|
},
|
|
|
|
-- The default settings is "prepend" https://github.com/williamboman/mason.nvim#default-configuration
|
|
|
|
-- Which means Mason's installed path is prioritized against our local install
|
|
|
|
-- see: https://git.pegasust.com/pegasust/aoc/commit/b45dc32c74d84c9f787ebce7a174c9aa1d411fc2
|
|
|
|
-- This introduces some pitfalls, so we'll take the approach of trusting user's local installation
|
|
|
|
PATH = "append";
|
2022-08-15 09:05:14 +00:00
|
|
|
})
|
|
|
|
require('mason-lspconfig').setup({
|
2022-10-26 12:09:47 +00:00
|
|
|
ensure_installed = servers,
|
|
|
|
automatic_installation = true
|
2022-08-15 09:05:14 +00:00
|
|
|
})
|
2022-11-30 11:46:32 +00:00
|
|
|
|
2022-11-22 03:48:24 +00:00
|
|
|
local inlay_hint_tsjs = {
|
|
|
|
includeInlayEnumMemberValueHints = true,
|
|
|
|
includeInlayFunctionLikeReturnTypeHints = true,
|
|
|
|
includeInlayFunctionParameterTypeHints = true,
|
|
|
|
includeInlayParameterNameHints = 'all', -- "none" | "literals" | "all"
|
|
|
|
inlcudeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
|
|
|
includeInlayPropertyDeclarationTypeHints = true,
|
|
|
|
includeInlayVariableTypeHints = true,
|
|
|
|
};
|
|
|
|
|
2022-08-16 01:59:31 +00:00
|
|
|
require('mason-lspconfig').setup_handlers({
|
2022-10-26 12:09:47 +00:00
|
|
|
-- default handler
|
|
|
|
function(server_name)
|
|
|
|
require('lspconfig')[server_name].setup {
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
}
|
|
|
|
end,
|
|
|
|
["sumneko_lua"] = function()
|
|
|
|
require('lspconfig').sumneko_lua.setup {
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
settings = {
|
|
|
|
Lua = {
|
|
|
|
runtime = {
|
|
|
|
version = "LuaJIT",
|
|
|
|
path = vim.split(package.path, ";"),
|
|
|
|
},
|
|
|
|
diagnostics = {
|
|
|
|
globals = { "vim" }
|
|
|
|
},
|
|
|
|
workspace = {
|
|
|
|
library = vim.api.nvim_get_runtime_file('', true)
|
|
|
|
},
|
|
|
|
telemetry = { enable = false },
|
2022-11-24 00:18:38 +00:00
|
|
|
hint = { enable = true, },
|
2022-10-26 12:09:47 +00:00
|
|
|
format = {
|
|
|
|
enable = true,
|
|
|
|
defaultConfig = {
|
|
|
|
indent_style = "space",
|
2022-11-21 22:16:34 +00:00
|
|
|
indent_size = 4,
|
2022-10-26 12:09:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-09-12 23:20:01 +00:00
|
|
|
}
|
|
|
|
}
|
2022-10-26 12:09:47 +00:00
|
|
|
end,
|
2022-11-21 22:16:34 +00:00
|
|
|
["tsserver"] = function()
|
|
|
|
require('lspconfig').tsserver.setup {
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
2022-12-03 06:43:44 +00:00
|
|
|
-- TODO: Have to figure out an alternative config for monorepo to prevent
|
|
|
|
-- Deno from injecting TS projects.
|
2022-11-21 22:16:34 +00:00
|
|
|
-- Monorepo support: spawn one instance of lsp within the git
|
|
|
|
-- repos.
|
2022-12-03 06:43:44 +00:00
|
|
|
-- root_dir = require('lspconfig.util').root_pattern('.git'),
|
|
|
|
root_dir = require('lspconfig.util').root_pattern('package.json'),
|
2022-11-22 03:48:24 +00:00
|
|
|
settings = {
|
|
|
|
javascript = inlay_hint_tsjs,
|
|
|
|
typescript = inlay_hint_tsjs,
|
|
|
|
}
|
2022-11-21 22:16:34 +00:00
|
|
|
}
|
|
|
|
end,
|
2022-12-03 06:43:44 +00:00
|
|
|
["denols"] = function()
|
|
|
|
require('lspconfig').denols.setup {
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
root_dir = require('lspconfig.util').root_pattern("deno.json", "deno.jsonc"),
|
|
|
|
}
|
|
|
|
end,
|
2022-10-26 12:09:47 +00:00
|
|
|
-- ["rust_analyzer"] = function()
|
2022-11-21 22:16:34 +00:00
|
|
|
-- require('lspconfig').rust_analyzer.setup {
|
|
|
|
-- on_attach = on_attach,
|
|
|
|
-- capabilities = capabilities,
|
|
|
|
-- settings = {
|
|
|
|
-- checkOnSave = {
|
|
|
|
-- command = "clippy",
|
|
|
|
-- }
|
|
|
|
-- }
|
|
|
|
-- }
|
2022-10-26 12:09:47 +00:00
|
|
|
-- end,
|
|
|
|
-- ["astro"] = function()
|
2022-11-21 22:16:34 +00:00
|
|
|
-- print('configuring astro')
|
|
|
|
-- require('lspconfig').astro.setup {
|
|
|
|
-- on_attach = on_attach,
|
|
|
|
-- capabilities = capabilities,
|
|
|
|
-- init_options = {
|
|
|
|
-- configuration = {},
|
|
|
|
-- typescript = {
|
|
|
|
-- serverPath = data_dir
|
|
|
|
-- }
|
2022-10-26 12:09:47 +00:00
|
|
|
-- }
|
2022-11-21 22:16:34 +00:00
|
|
|
-- }
|
2022-10-26 12:09:47 +00:00
|
|
|
-- end
|
2022-08-16 01:59:31 +00:00
|
|
|
})
|
2022-10-26 12:09:47 +00:00
|
|
|
require("rust-tools").setup {
|
|
|
|
tools = { -- rust-tools options
|
|
|
|
|
|
|
|
-- how to execute terminal commands
|
|
|
|
-- options right now: termopen / quickfix
|
|
|
|
executor = require("rust-tools/executors").termopen,
|
|
|
|
|
|
|
|
-- 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"
|
2022-11-22 03:48:24 +00:00
|
|
|
on_initialized = function()
|
2022-11-24 00:18:38 +00:00
|
|
|
require('inlay-hints').set_all()
|
2022-11-22 03:48:24 +00:00
|
|
|
end,
|
2022-10-26 12:09:47 +00:00
|
|
|
|
|
|
|
-- automatically call RustReloadWorkspace when writing to a Cargo.toml file.
|
|
|
|
reload_workspace_from_cargo_toml = true,
|
|
|
|
|
|
|
|
-- These apply to the default RustSetInlayHints command
|
|
|
|
inlay_hints = {
|
|
|
|
-- automatically set inlay hints (type hints)
|
|
|
|
-- default: true
|
2022-12-08 07:12:55 +00:00
|
|
|
auto = false,
|
2022-10-26 12:09:47 +00:00
|
|
|
|
|
|
|
-- Only show inlay hints for the current line
|
|
|
|
only_current_line = false,
|
|
|
|
|
|
|
|
-- whether to show parameter hints with the inlay hints or not
|
|
|
|
-- default: true
|
|
|
|
show_parameter_hints = true,
|
|
|
|
|
|
|
|
-- prefix for parameter hints
|
|
|
|
-- default: "<-"
|
|
|
|
parameter_hints_prefix = "<- ",
|
|
|
|
|
|
|
|
-- prefix for all the other hints (type, chaining)
|
|
|
|
-- default: "=>"
|
|
|
|
other_hints_prefix = "=> ",
|
|
|
|
|
|
|
|
-- whether to align to the length of the longest line in the file
|
|
|
|
max_len_align = false,
|
|
|
|
|
|
|
|
-- padding from the left if max_len_align is true
|
|
|
|
max_len_align_padding = 1,
|
|
|
|
|
|
|
|
-- whether to align to the extreme right or not
|
|
|
|
right_align = false,
|
|
|
|
|
|
|
|
-- padding from the right if right_align is true
|
|
|
|
right_align_padding = 7,
|
|
|
|
|
|
|
|
-- The color of the hints
|
|
|
|
highlight = "Comment",
|
|
|
|
},
|
|
|
|
|
|
|
|
-- options same as lsp hover / vim.lsp.util.open_floating_preview()
|
|
|
|
hover_actions = {
|
|
|
|
|
|
|
|
-- the border that is used for the hover window
|
|
|
|
-- see vim.api.nvim_open_win()
|
|
|
|
border = {
|
|
|
|
{ "╭", "FloatBorder" },
|
|
|
|
{ "─", "FloatBorder" },
|
|
|
|
{ "╮", "FloatBorder" },
|
|
|
|
{ "│", "FloatBorder" },
|
|
|
|
{ "╯", "FloatBorder" },
|
|
|
|
{ "─", "FloatBorder" },
|
|
|
|
{ "╰", "FloatBorder" },
|
|
|
|
{ "│", "FloatBorder" },
|
|
|
|
},
|
|
|
|
|
|
|
|
-- whether the hover action window gets automatically focused
|
|
|
|
-- default: false
|
|
|
|
auto_focus = false,
|
|
|
|
},
|
|
|
|
|
|
|
|
-- settings for showing the crate graph based on graphviz and the dot
|
|
|
|
-- command
|
|
|
|
crate_graph = {
|
|
|
|
-- Backend used for displaying the graph
|
|
|
|
-- see: https://graphviz.org/docs/outputs/
|
|
|
|
-- default: x11
|
|
|
|
backend = "x11",
|
|
|
|
-- where to store the output, nil for no output stored (relative
|
|
|
|
-- path from pwd)
|
|
|
|
-- default: nil
|
|
|
|
output = nil,
|
|
|
|
-- true for all crates.io and external crates, false only the local
|
|
|
|
-- crates
|
|
|
|
-- default: true
|
|
|
|
full = true,
|
|
|
|
|
|
|
|
-- List of backends found on: https://graphviz.org/docs/outputs/
|
|
|
|
-- Is used for input validation and autocompletion
|
|
|
|
-- Last updated: 2021-08-26
|
|
|
|
enabled_graphviz_backends = {
|
|
|
|
"bmp",
|
|
|
|
"cgimage",
|
|
|
|
"canon",
|
|
|
|
"dot",
|
|
|
|
"gv",
|
|
|
|
"xdot",
|
|
|
|
"xdot1.2",
|
|
|
|
"xdot1.4",
|
|
|
|
"eps",
|
|
|
|
"exr",
|
|
|
|
"fig",
|
|
|
|
"gd",
|
|
|
|
"gd2",
|
|
|
|
"gif",
|
|
|
|
"gtk",
|
|
|
|
"ico",
|
|
|
|
"cmap",
|
|
|
|
"ismap",
|
|
|
|
"imap",
|
|
|
|
"cmapx",
|
|
|
|
"imap_np",
|
|
|
|
"cmapx_np",
|
|
|
|
"jpg",
|
|
|
|
"jpeg",
|
|
|
|
"jpe",
|
|
|
|
"jp2",
|
|
|
|
"json",
|
|
|
|
"json0",
|
|
|
|
"dot_json",
|
|
|
|
"xdot_json",
|
|
|
|
"pdf",
|
|
|
|
"pic",
|
|
|
|
"pct",
|
|
|
|
"pict",
|
|
|
|
"plain",
|
|
|
|
"plain-ext",
|
|
|
|
"png",
|
|
|
|
"pov",
|
|
|
|
"ps",
|
|
|
|
"ps2",
|
|
|
|
"psd",
|
|
|
|
"sgi",
|
|
|
|
"svg",
|
|
|
|
"svgz",
|
|
|
|
"tga",
|
|
|
|
"tiff",
|
|
|
|
"tif",
|
|
|
|
"tk",
|
|
|
|
"vml",
|
|
|
|
"vmlz",
|
|
|
|
"wbmp",
|
|
|
|
"webp",
|
|
|
|
"xlib",
|
|
|
|
"x11",
|
|
|
|
},
|
|
|
|
},
|
2022-10-12 00:06:09 +00:00
|
|
|
},
|
2022-10-26 12:09:47 +00:00
|
|
|
|
|
|
|
-- all the opts to send to nvim-lspconfig
|
|
|
|
-- these override the defaults set by rust-tools.nvim
|
|
|
|
-- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer
|
|
|
|
server = {
|
|
|
|
-- standalone file support
|
|
|
|
-- setting it to false may improve startup time
|
|
|
|
standalone = true,
|
|
|
|
on_attach = function(client, bufnr)
|
|
|
|
local nmap = function(keys, func, desc)
|
|
|
|
if desc then
|
|
|
|
desc = 'LSP: ' .. desc
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.keymap.set('n', keys, func, { noremap = true, buffer = bufnr, desc = desc })
|
|
|
|
end
|
2022-11-22 03:48:24 +00:00
|
|
|
on_attach(client, bufnr)
|
|
|
|
require('inlay-hints').on_attach(client, bufnr)
|
2022-11-02 18:30:40 +00:00
|
|
|
nmap('K', require 'rust-tools'.hover_actions.hover_actions, 'Hover Documentation')
|
2022-10-26 12:09:47 +00:00
|
|
|
|
|
|
|
end,
|
|
|
|
capabilities = capabilities,
|
|
|
|
settings = {
|
|
|
|
checkOnSave = {
|
|
|
|
command = "clippy",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}, -- rust-analyzer options
|
|
|
|
|
|
|
|
-- debugging stuff
|
|
|
|
dap = {
|
|
|
|
adapter = {
|
|
|
|
type = "executable",
|
|
|
|
command = "lldb-vscode",
|
|
|
|
name = "rt_lldb",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
require('zk').setup({
|
|
|
|
picker = "telescope",
|
|
|
|
lsp = {
|
|
|
|
config = {
|
|
|
|
cmd = { "zk", "lsp" },
|
|
|
|
name = "zk",
|
|
|
|
on_attach = on_attach,
|
|
|
|
},
|
|
|
|
auto_attach = {
|
|
|
|
enable = true,
|
|
|
|
filetypes = { "markdown" }
|
|
|
|
},
|
2022-08-31 05:41:56 +00:00
|
|
|
},
|
|
|
|
})
|
2022-08-16 01:59:31 +00:00
|
|
|
|
2022-08-31 14:39:47 +00:00
|
|
|
-- Custom ZkOrphans that determines unlinked notes
|
|
|
|
-- `:ZkOrphans {tags = {"work"}}`
|
|
|
|
require('zk.commands').add("ZkOrphans", function(options)
|
2022-10-26 12:09:47 +00:00
|
|
|
options = vim.tbl_extend("force", { orphan = true }, options or {})
|
|
|
|
-- zk.edit opens notes picker
|
|
|
|
require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" })
|
2022-08-31 14:39:47 +00:00
|
|
|
end)
|
2022-11-30 11:46:32 +00:00
|
|
|
--
|
2022-08-31 14:39:47 +00:00
|
|
|
-- ZkGrep: opens file picker
|
|
|
|
-- In the case where `match_ctor` is falsy, create a prompt.
|
|
|
|
-- This is so that we distinguish between ZkGrep and ZkNotes
|
|
|
|
-- Params:
|
2022-09-24 23:49:40 +00:00
|
|
|
-- match_ctor: string | {match= :string,...} | "" | nil
|
2022-08-31 14:39:47 +00:00
|
|
|
require('zk.commands').add("ZkGrep", function(match_ctor)
|
2022-10-26 12:09:47 +00:00
|
|
|
-- handle polymorphic `match_ctor`
|
|
|
|
local grep_str = match_ctor
|
|
|
|
local match
|
|
|
|
if match_ctor == nil or match_ctor == '' then
|
|
|
|
vim.fn.inputsave()
|
|
|
|
grep_str = vim.fn.input('Grep string: >')
|
|
|
|
vim.fn.inputrestore()
|
|
|
|
match = { match = grep_str }
|
|
|
|
elseif type(match_ctor) == 'string' then
|
|
|
|
match = { match = grep_str }
|
|
|
|
end
|
2022-12-26 11:34:17 +00:00
|
|
|
require('zk').edit(match, { title = "Grep: '" .. grep_str .. "'", mutli_select = false })
|
2022-08-31 14:39:47 +00:00
|
|
|
end)
|
|
|
|
|
2022-08-15 09:05:14 +00:00
|
|
|
|
|
|
|
-- Gitsigns
|
|
|
|
require('gitsigns').setup {
|
2022-10-26 12:09:47 +00:00
|
|
|
signs = {
|
|
|
|
add = { text = '+' },
|
|
|
|
change = { text = '~' },
|
|
|
|
delete = { text = '_' },
|
|
|
|
topdelete = { text = '‾' },
|
|
|
|
changedelete = { text = '~' },
|
|
|
|
}
|
2022-08-15 09:05:14 +00:00
|
|
|
}
|
|
|
|
require('lualine').setup {
|
2022-10-26 12:09:47 +00:00
|
|
|
options = {
|
|
|
|
icons_enabled = true,
|
|
|
|
},
|
|
|
|
sections = {
|
|
|
|
lualine_a = { 'mode' },
|
|
|
|
lualine_b = { 'branch', 'diff', 'diagnostics' },
|
|
|
|
lualine_c = {
|
|
|
|
{ 'filename',
|
|
|
|
file_status = true,
|
|
|
|
newfile_status = false,
|
|
|
|
path = 1,
|
|
|
|
symbols = {
|
|
|
|
modified = '[+]',
|
|
|
|
readonly = '[-]',
|
|
|
|
unnamed = '[Unnamed]',
|
|
|
|
newfile = '[New]',
|
|
|
|
},
|
|
|
|
},
|
2022-09-24 06:03:47 +00:00
|
|
|
},
|
2022-10-26 12:09:47 +00:00
|
|
|
lualine_x = { 'encoding', 'fileformat', 'filetype', },
|
|
|
|
lualine_y = { 'progress' },
|
|
|
|
lualine_z = { 'location' },
|
2022-09-24 06:03:47 +00:00
|
|
|
},
|
2022-10-26 12:09:47 +00:00
|
|
|
inactive_sections = {
|
|
|
|
lualine_a = {},
|
|
|
|
lualine_b = {},
|
|
|
|
lualine_c = { { 'filename', path = 1, file_status = true, }, },
|
|
|
|
lualine_x = { 'location' },
|
|
|
|
lualine_y = {},
|
|
|
|
lualine_z = {},
|
|
|
|
}
|
2022-08-15 09:05:14 +00:00
|
|
|
}
|
2022-10-13 00:47:16 +00:00
|
|
|
|
|
|
|
require('nvim-surround').setup {}
|