Created
January 26, 2023 16:03
-
-
Save ltratt/5a85730ca6c2a48deb01174dc789afb9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- On the first run, this file will cause various errors as the plugins will | |
-- not yet be installed. Execute :PackerInstall, quit neovim, rerun and... all | |
-- should be good! Note that this config will download rust source if | |
-- $RUST_SRC_DIR isn't set and download and build rust-analyzer (if it's not | |
-- found in $PATH) in the background -- these two tasks can take a little | |
-- while, so you might find that your first few minutes of editing Rust source | |
-- don't work quite as expected. | |
local config_dir = os.getenv("HOME") .. '/.config/nvim' | |
-- From https://github.com/sharksforarms/neovim-rust/blob/master/neovim-init-lsp-cmp-rust-tools.lua | |
local ensure_packer = function() | |
local fn = vim.fn | |
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" | |
if fn.empty(fn.glob(install_path)) > 0 then | |
fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }) | |
vim.cmd([[packadd packer.nvim]]) | |
return true | |
end | |
return false | |
end | |
local packer_bootstrap = ensure_packer() | |
require("packer").init({ | |
autoremove = true, | |
}) | |
require("packer").startup(function(use) | |
use 'wbthomason/packer.nvim' -- Package manager | |
use 'tpope/vim-fugitive' -- Git commands in nvim | |
use 'ludovicchabant/vim-gutentags' -- Automatic tags management | |
use 'sainnhe/gruvbox-material' -- Colourscheme | |
use 'simnalamburt/vim-mundo' -- Searchable tree of undos (F5) | |
use 'SammysHP/vim-heurindent' -- Automatically adjust 'shiftwidth' and 'expandtab' | |
use 'dietsche/vim-lastplace' -- Open cursor at last place in the file | |
use 'ntpeters/vim-better-whitespace' -- Highlight whitespace at end of lines | |
use 'tpope/vim-speeddating' -- Increment dates and other things correctly with <C-A>/<C-X> | |
use 'neomutt/neomutt.vim' -- Syntax highlighting for neomutt | |
use 'thaerkh/vim-workspace' -- Automatically save session | |
use 'lfv89/vim-interestingwords' -- Highlight word under cursor with \1,\2,etc (\0 clears all) | |
use 'numToStr/Comment.nvim' -- Add/remove comments with gc | |
use 'ggandor/leap.nvim' -- Forward (s)/backwards (S) search in visible text | |
use 'cyansprite/Extract' -- Rotate amongst recent yanks after pasting (with a-p and a-P) | |
use 'lukas-reineke/indent-blankline.nvim' -- Show indentation characters '┊' | |
use 'haya14busa/is.vim' -- Slightly tweak incremental searching | |
use 'folke/which-key.nvim' -- Show the available key-presses | |
use 'lewis6991/spellsitter.nvim' -- Spell checking integrated with TreeSitter | |
use 'rust-lang/rust.vim' -- Rust convenience | |
use 'Saecki/crates.nvim' -- Support for Rust crates.io | |
use 'simrat39/rust-tools.nvim' | |
use 'cespare/vim-toml' -- Syntax highlighting for TOML files | |
use 'editorconfig/editorconfig-vim' -- Cross-editor config file support (indent settings etc) | |
use 'dstein64/nvim-scrollview' -- Scrollbar | |
use 'mfussenegger/nvim-dap' -- Debug Adapter Protocol | |
use 'nvim-lua/popup.nvim' -- Hopefully temporary popin hack | |
-- UI to select things (files, grep results, open buffers...) | |
use { 'nvim-telescope/telescope.nvim', requires={ 'nvim-lua/plenary.nvim' } } | |
use { 'nvim-telescope/telescope-fzf-native.nvim', requires={ 'nvim-telescope/telescope.nvim' }, run='gmake' } | |
use 'itchyny/lightline.vim' -- Status bar (bottom of screen) | |
use 'mengelbrecht/lightline-bufferline' -- Buffer bar (top of screen) | |
-- Add git related info in the signs columns and popups | |
use { 'lewis6991/gitsigns.nvim', requires = { 'nvim-lua/plenary.nvim' } } | |
use { 'nvim-treesitter/nvim-treesitter', | |
run = function() require('nvim-treesitter.install').update({ with_sync = true })() end | |
} | |
use 'nvim-treesitter/nvim-treesitter-textobjects' -- Extra stuff for treesitter | |
use 'romgrk/nvim-treesitter-context' -- Auto-collapse code as you scroll | |
use 'neovim/nvim-lspconfig' -- Collection of configurations for built-in LSP client | |
-- LSP progress bar | |
use { "j-hui/fidget.nvim", config = function() require("fidget").setup() end } | |
use { "jose-elias-alvarez/null-ls.nvim", requires = { "nvim-lua/plenary.nvim" } } | |
-- Completion | |
use("hrsh7th/nvim-cmp") | |
use({ | |
"hrsh7th/cmp-nvim-lsp", | |
-- cmp Snippet completion | |
"hrsh7th/cmp-vsnip", | |
-- cmp Path completion | |
"hrsh7th/cmp-path", | |
"hrsh7th/cmp-buffer", | |
after = { "hrsh7th/nvim-cmp" }, | |
requires = { "hrsh7th/nvim-cmp" }, | |
}) | |
use 'L3MON4D3/LuaSnip' -- Snippets plugin | |
end) | |
-- the first run will install packer and our plugins | |
if packer_bootstrap then | |
require("packer").sync() | |
return | |
end | |
vim.o.inccommand = 'nosplit' | |
-- Show line numbers | |
vim.wo.number = true | |
vim.o.mouse = 'a' -- Enable mouse mode | |
vim.o.breakindent = true | |
-- Undo history | |
vim.opt.undofile = true | |
vim.opt.undodir = vim.fn.stdpath 'data' .. '/undo' | |
vim.opt.undolevels = 1000 | |
vim.opt.undoreload = 10000 | |
-- Smart-case searching | |
vim.o.ignorecase = true | |
vim.o.smartcase = true | |
-- More responsive UI | |
vim.o.updatetime = 250 | |
vim.o.timeoutlen = 500 | |
vim.wo.signcolumn = 'yes' | |
-- Disable vim's builtin netrw directory traverser | |
vim.g.loaded_netrw = 0 | |
-- Allow interacting with X's clipboard | |
vim.o.clipboard = 'unnamedplus' | |
-- Reload file on change | |
vim.api.nvim_exec([[ autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif ]], false) | |
-- Basic editing sanity | |
vim.api.nvim_set_keymap('', '<BS>', 'X', {noremap=true}) | |
vim.api.nvim_set_keymap('i', '<S-BS>', '<C-o>db', {noremap=true}) | |
vim.api.nvim_set_keymap('', '<S-BS>', 'db', {noremap=true}) | |
vim.api.nvim_set_keymap('i', '<S-Del>', '<C-o>dw', {noremap=true}) | |
vim.api.nvim_set_keymap('', '<S-Del>', 'dw', {noremap=true}) | |
vim.api.nvim_set_keymap('', '<S-Right>', 'w', {noremap=true}) | |
-- Highlight on yank | |
vim.api.nvim_exec( | |
[[ | |
augroup YankHighlight | |
autocmd! | |
autocmd TextYankPost * silent! lua vim.highlight.on_yank() | |
augroup end | |
]], | |
false | |
) | |
-- email formatting | |
vim.cmd [[ command -range=% -nargs=* EmailFormat <line1>,<line2>!email_format ]] | |
function _G.email_format_buf() | |
local pos = vim.api.nvim_eval('line2byte(line("."))') | |
vim.fn.execute(':EmailFormat') | |
vim.fn.execute('goto ' .. pos) | |
end | |
function _G.email_insert_file(l) | |
vim.fn.execute('read ' .. config_dir .. '/' .. l) | |
end | |
vim.api.nvim_set_keymap('n', '<F2>', ':call v:lua.email_format_buf()<CR>', { noremap = true }) | |
vim.api.nvim_set_keymap('v', '<F2>', ':EmailFormat<CR>', { noremap = true }) | |
vim.api.nvim_set_keymap('', '<F3>', ':call v:lua.email_insert_file("sig_normal")<CR>', { noremap = true }) | |
vim.api.nvim_set_keymap('', '<S-F3>', ':call v:lua.email_insert_file("sig_kings")<CR>', { noremap = true }) | |
vim.api.nvim_set_keymap('', '<F4>', 'O<Esc>|:call v:lua.email_insert_file("reminder")<CR>|<Up>|dd|lllllll|i|', { noremap = true }) | |
-- Spell checker | |
vim.o.spell = true | |
if os.execute('find ' .. config_dir .. '/spell/en.utf-8.add -cnewer ' .. config_dir .. '/spell/en.utf-8.add.spl') ~= 0 then | |
vim.cmd('mkspell! ' .. config_dir .. '/spell/en.utf-8.add') | |
end | |
-- Text widths for different file types | |
vim.api.nvim_exec([[ autocmd FileType mail set textwidth=76 ]], false) | |
-- rust and rust_analyzer | |
local rust_analyzer_installed = true | |
if os.execute("which rust-analyzer > /dev/null 2>&1") ~= 0 then | |
-- If rust-analyzer isn't found in $PATH, install a local copy | |
rust_analyzer_installed = false | |
local ra_src = vim.fn.stdpath 'data' .. '/rust-analyzer' | |
if vim.fn.empty(vim.fn.glob(ra_src)) > 0 then | |
os.execute("/bin/sh -c 'cd " .. vim.fn.stdpath 'data' .. " && git clone https://github.com/rust-analyzer/rust-analyzer.git && cd rust-analyzer && cargo build --release' &") | |
end | |
end | |
if os.getenv("RUST_SRC_PATH") == nil then | |
-- If $RUST_SRC_PATH isn't specified, install a local copy of the Rust source | |
-- and point RUST_SRC_PATH at that copy. | |
local rust_src = vim.fn.stdpath 'data' .. '/rust' | |
if vim.fn.empty(vim.fn.glob(rust_src)) > 0 then | |
os.execute("/bin/sh -c 'cd " .. rust_src .. "/.. && git clone https://github.com/rust-lang/rust && cd rust && cp config.toml.example config.toml && ./x.py fetch > /dev/null' &") | |
end | |
local has_unistd, _ = pcall(require, 'posix.stdlib') | |
if has_unistd then | |
require 'posix.stdlib'.setenv("RUST_SRC_PATH", rust_src .. "/library") | |
else | |
vim.fn.execute('echoerr("luaposix not installed")') | |
end | |
end | |
-- LSP settings | |
local nvim_lsp = require 'lspconfig' | |
function _G.all_diagnostics() | |
if #vim.diagnostic.get(0, {severity = 'Error' }) > 0 then | |
vim.diagnostic.setloclist({severity = 'Error'}) | |
else | |
vim.diagnostic.setloclist() | |
end | |
end | |
function _G.next_diagnostic() | |
if #vim.diagnostic.get(0, {severity = 'Error'}) > 0 then | |
vim.diagnostic.goto_next({severity = 'Error'}) | |
else | |
vim.diagnostic.goto_next() | |
end | |
end | |
function _G.prev_diagnostic() | |
if #vim.diagnostic.get(0, {severity = 'Error'}) > 0 then | |
vim.lsp.diagnostic.goto_prev({severity = 'Error'}) | |
else | |
vim.lsp.diagnostic.goto_prev() | |
end | |
end | |
-- Right align diagnostics | |
local function diagnostic_align(d) | |
local line_len = vim.fn.strdisplaywidth(vim.api.nvim_buf_get_lines(0, d.lnum, d.lnum + 1, false)[1] or "") | |
local columns = vim.api.nvim_get_option("columns") | |
return string.rep(" ", columns - line_len - vim.fn.strdisplaywidth(d.message) - 10) .. d.message | |
end | |
vim.diagnostic.config({ | |
virtual_text = { source = false, prefix = "", format = diagnostic_align, spacing = 0 }, | |
}) | |
local on_attach = function(client, buffer) | |
vim.api.nvim_buf_set_option(buffer, 'omnifunc', 'v:lua.vim.lsp.omnifunc') | |
local opts = {} | |
vim.api.nvim_buf_set_keymap(buffer, 'n', 'ga', '<cmd>lua all_diagnostics()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(buffer, 'n', 'gc', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(buffer, 'n', 'gd', [[<cmd>lua require('telescope.builtin').lsp_definitions()<CR>]], opts) | |
vim.api.nvim_buf_set_keymap(buffer, 'n', 'ge', '<cmd>lua next_diagnostic()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(buffer, 'n', 'gE', '<cmd>lua prev_diagnostic()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(buffer, 'n', 'gf', '<cmd>lua vim.lsp.buf.format({async=true})<CR>', opts) | |
vim.api.nvim_buf_set_keymap(buffer, 'n', 'gh', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(buffer, 'n', 'gH', '<cmd>lua vim.lsp.buf.hover()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(buffer, 'n', 'gl', '<cmd>lua vim.diagnostic.open_float(0, {scope="line"})<CR>', opts) | |
vim.api.nvim_buf_set_keymap(buffer, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(buffer, 'n', 'gR', '<cmd>lua vim.lsp.buf.rename()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(buffer, 'n', 'gs', [[:split<CR><cmd>lua require('telescope.builtin').lsp_definitions()<CR>]], opts) | |
vim.api.nvim_buf_set_keymap(buffer, 'n', 'gy', [[<cmd>lua require('telescope.builtin').lsp_document_symbols()<CR>]], opts) | |
vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]] | |
require('which-key').register({ | |
g = { | |
name = 'LSP and related', | |
a = 'Show all errors or, if none, all warnings', | |
c = 'Code action (e.g. expand enum variants)', | |
d = 'Goto definition', | |
E = 'Goto last error or, if none, next warning', | |
e = 'Goto next error or, if none, next warning', | |
f = 'Format file', | |
h = 'Show short definition', | |
H = 'Show long definition', | |
l = [[Show this line's diagnostic]], | |
r = 'Find references', | |
R = 'Rename symbol', | |
s = 'Goto definition in horizontal split', | |
v = 'which_key_ignore', | |
y = 'Show all symbols', | |
} | |
}) | |
-- " Show diagnostic popup on cursor hover | |
local diag_float_grp = vim.api.nvim_create_augroup("DiagnosticFloat", { clear = true }) | |
vim.api.nvim_create_autocmd("CursorHold", { | |
callback = function() | |
vim.diagnostic.open_float(nil, { focusable = false }) | |
end, | |
group = diag_float_grp, | |
}) | |
end | |
-- rust-tools | |
local opts = { | |
server = { | |
on_attach = on_attach, | |
}, | |
tools = { | |
runnables = { | |
use_telescope = true, | |
}, | |
inlay_hints = { | |
only_current_line = true, | |
right_align = true, | |
right_align_padding = 2 | |
}, | |
}, | |
} | |
if rust_analyzer_installed == false then | |
-- We installed a local copy of rust-analyzer, so point the LSP at the | |
-- relevant binary. | |
opts['server']['cmd'] = { vim.fn.stdpath 'data' .. '/rust-analyzer/target/release/rust-analyzer' } | |
end | |
require('rust-tools').setup(opts) | |
-- Enable language servers | |
-- local servers = { 'clangd' } | |
-- for _, lsp in ipairs(servers) do | |
-- nvim_lsp[lsp].setup { | |
-- on_attach = on_attach, | |
-- capabilities = capabilities, | |
-- } | |
-- end | |
-- nvim-cmp setup | |
local cmp = require 'cmp' | |
local luasnip = require 'luasnip' | |
require("luasnip.loaders.from_vscode").load() | |
local only_whitespace_before = function() | |
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then | |
return false | |
end | |
local col = vim.api.nvim_win_get_cursor(0)[2] | |
local uptocol = string.sub(vim.api.nvim_get_current_line(), 1, col) | |
local s, e = uptocol:find("^[%s]*$") | |
return s ~= nil | |
end | |
vim.opt.shortmess = vim.opt.shortmess + "c" | |
cmp.setup { | |
completion = { | |
autocomplete = true, | |
completeopt = 'menu' | |
}, | |
snippet = { | |
expand = function(args) | |
require('luasnip').lsp_expand(args.body) | |
end, | |
}, | |
mapping = cmp.mapping.preset.insert({ | |
["<CR>"] = cmp.mapping.confirm({ | |
behavior = cmp.ConfirmBehavior.Insert, | |
select = true, | |
}), | |
['<Tab>'] = function(fallback) | |
if cmp.visible() then | |
cmp.select_next_item() | |
elseif luasnip.expand_or_jumpable() then | |
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), '') | |
elseif only_whitespace_before() == false then | |
cmp.complete() | |
else | |
fallback() | |
end | |
end, | |
['<S-Tab>'] = function(fallback) | |
if cmp.visible() then | |
cmp.select_prev_item() | |
elseif luasnip.jumpable(-1) then | |
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-jump-prev', true, true, true), '') | |
else | |
fallback() | |
end | |
end, | |
}), | |
sources = { | |
{ name = 'nvim_lsp' }, | |
{ name = 'luasnip' }, | |
{ name = 'path' }, | |
{ name = 'buffer' } | |
}, | |
} | |
-- Comment.nvim | |
require('Comment').setup() | |
-- Extract | |
vim.g.extract_useDefaultMappings = false | |
vim.api.nvim_set_keymap('n', 'p', '<Plug>(extract-put)', {silent=true}) | |
vim.api.nvim_set_keymap('n', 'P', '<Plug>(extract-Put)', {silent=true}) | |
vim.api.nvim_set_keymap('n', '<a-p>', '<Plug>(extract-Sycle)', {silent=true}) | |
vim.api.nvim_set_keymap('n', '<a-P>', '<Plug>(extract-sycle)', {silent=true}) | |
-- gruvbox-material | |
vim.o.termguicolors = true | |
vim.g.gruvbox_material_palette = 'mix' | |
vim.cmd [[colorscheme gruvbox-material]] | |
function _G.toggle_bg() | |
if vim.o.background == "dark" then | |
vim.g.gruvbox_material_palette = 'original' | |
vim.o.background = 'light' | |
else | |
vim.g.gruvbox_material_palette = 'mix' | |
vim.o.background = 'dark' | |
end | |
end | |
vim.api.nvim_set_keymap('', '<F6>', ':call v:lua.toggle_bg()<CR>', {}) | |
-- gutentags | |
if os.execute("which ectags > /dev/null 2>&1") == 0 then | |
vim.g.gutentags_ctags_executable = 'ectags' | |
end | |
vim.api.nvim_exec([[ | |
augroup MyGutentagsStatusLineRefresher | |
autocmd! | |
autocmd User GutentagsUpdating call lightline#update() | |
autocmd User GutentagsUpdated call lightline#update() | |
augroup END | |
]], false) | |
vim.g.gutentags_cache_dir = vim.fn.stdpath 'data' .. '/tags' | |
vim.g.gutentags_exclude_project_root = { os.getenv("HOME") } | |
-- indent-blankline | |
require("indent_blankline").setup { | |
char = '┊', | |
filetype_exclude = { 'help', 'packer' }, | |
buftype_exclude = { 'terminal', 'nofile' }, | |
char_highlight = 'LineNr', | |
show_first_indent_level = false, | |
show_trailing_blankline_indent = false | |
} | |
-- interestingwords | |
vim.g.interestingWordsDefaultMappings = 0 | |
vim.api.nvim_set_keymap('n', '<leader>0', ':call UncolorAllWords()<CR>', {silent=true, noremap=true}) | |
vim.api.nvim_set_keymap('n', '<leader>1', ':call InterestingWords("a")<CR>', {silent=true, noremap=true}) | |
vim.api.nvim_set_keymap('n', '<leader>2', ':call InterestingWords("b")<CR>', {silent=true, noremap=true}) | |
vim.api.nvim_set_keymap('n', '<leader>3', ':call InterestingWords("c")<CR>', {silent=true, noremap=true}) | |
vim.api.nvim_set_keymap('n', '<leader>4', ':call InterestingWords("d")<CR>', {silent=true, noremap=true}) | |
vim.api.nvim_set_keymap('n', '<leader>5', ':call InterestingWords("e")<CR>', {silent=true, noremap=true}) | |
vim.api.nvim_set_keymap('n', 'n', ':call WordNavigation(1)<CR>', {silent=true, noremap=true}) | |
vim.api.nvim_set_keymap('n', 'N', ':call WordNavigation(0)<CR>', {silent=true, noremap=true}) | |
-- lightline and lightline-bufferline settings | |
vim.o.showtabline = 2 | |
vim.g.lightline = { | |
-- lightline | |
active = { | |
left = {{'mode'}, {'absolutepath'}, {'modified'}}, | |
right = {{'lineinfo'}, {'percent'}, {'fileformat', 'fileencoding', 'filetype'}} | |
}, | |
colorscheme = 'gruvbox_material', | |
component_function = { gitbranch = 'fugitive#head' }, | |
-- lightline-bufferline | |
tabline = {left = {{'buffers'}}, right = {}}, | |
component_expand = {buffers = 'lightline#bufferline#buffers'}, | |
component_raw = {buffers = 1}, | |
component_type = {buffers = 'tabsel'} | |
} | |
vim.g['lightline#bufferline#filename_modifier'] = ':~' | |
vim.g['lightline#bufferline#enable_devicons'] = 1 | |
vim.g['lightline#bufferline#show_number'] = 2 | |
vim.g['lightline#bufferline#clickable'] = 1 | |
vim.g['lightline#bufferline#number_separator'] = ':' | |
vim.g['lightline#bufferline#shorten_path'] = true | |
vim.g['lightline#bufferline#unnamed'] = '[No Name]' | |
vim.api.nvim_set_keymap('', '<C-PageUp>', ':bp!<CR>', { silent=true }) | |
vim.api.nvim_set_keymap('', '<C-PageDown>', ':bn!<CR>', { silent=true }) | |
-- gitsigns | |
require('gitsigns').setup { | |
signs = { | |
add = { hl = 'GitGutterAdd', text = '+' }, | |
change = { hl = 'GitGutterChange', text = '~' }, | |
delete = { hl = 'GitGutterDelete', text = '_' }, | |
topdelete = { hl = 'GitGutterDelete', text = '‾' }, | |
changedelete = { hl = 'GitGutterChange', text = '~' }, | |
}, | |
} | |
-- leap | |
require('leap').add_default_mappings() | |
-- mundo | |
vim.api.nvim_set_keymap('', '<F5>', ':MundoToggle<Cr>', {}) | |
-- null-ls | |
local null_ls = require("null-ls") | |
null_ls.setup({ | |
sources = { | |
null_ls.builtins.formatting.stylua, | |
null_ls.builtins.diagnostics.eslint, | |
null_ls.builtins.completion.spell, | |
}, | |
}) | |
-- spellsitter | |
require('spellsitter').setup() | |
-- telescope | |
local actions = require('telescope.actions') | |
require('telescope').setup{ | |
defaults = { | |
layout_strategy = "flex", | |
sorting_strategy = "descending", | |
mappings = { | |
i = { | |
["<C-d>"] = false, | |
["<C-u>"] = false, | |
["<PageDown>"] = actions.move_to_bottom, | |
["<PageUp>"] = actions.move_to_top, | |
["<C-up>"] = actions.preview_scrolling_up, | |
["<C-down>"] = actions.preview_scrolling_down, | |
}, | |
n = { | |
["<C-d>"] = false, | |
["<C-u>"] = false, | |
["<PageDown>"] = actions.move_to_bottom, | |
["<PageUp>"] = actions.move_to_top, | |
["<C-up>"] = actions.preview_scrolling_up, | |
["<C-down>"] = actions.preview_scrolling_down, | |
}, | |
}, | |
}, | |
extensions = { | |
fzf = { | |
fuzzy = true, -- false will only do exact matching | |
override_generic_sorter = true, -- override the generic sorter | |
override_file_sorter = true, -- override the file sorter | |
case_mode = "smart_case", -- or "ignore_case" or "respect_case" | |
-- the default case_mode is "smart_case" | |
} | |
} | |
} | |
require('telescope').load_extension('fzf') | |
vim.api.nvim_set_keymap('', '<C-b>', [[<cmd>lua require('telescope.builtin').buffers({sort_lastused=true, ignore_current_buffer=false, sort_mru=true})<CR>]], { noremap=true, silent=true}) | |
vim.api.nvim_set_keymap('', '<C-m>', [[<cmd>lua require('telescope.builtin').marks({sort_lastused=true, sort_mru=true})<CR>]], { noremap=true, silent=true}) | |
vim.api.nvim_set_keymap('', '<C-p>', [[<cmd>lua require('telescope.builtin').find_files({hidden=true, previewer=false})<CR>]], { noremap=true, silent=true}) | |
vim.api.nvim_set_keymap('n', '<leader>sb', [[<cmd>lua require('telescope.builtin').current_buffer_fuzzy_find()<CR>]], { noremap = true, silent = true }) | |
vim.api.nvim_set_keymap('n', '<leader>sf', [[<cmd>lua require('telescope.builtin').treesitter()<CR>]], { noremap = true, silent = true }) | |
vim.api.nvim_set_keymap('n', '<leader>sg', [[<cmd>lua require('telescope.builtin').live_grep()<CR>]], { noremap = true, silent = true }) | |
vim.api.nvim_set_keymap('n', '<leader>sh', [[<cmd>lua require('telescope.builtin').help_tags()<CR>]], { noremap = true, silent = true }) | |
vim.api.nvim_set_keymap('n', '<leader>so', [[<cmd>lua require('telescope.builtin').tags{ only_current_buffer = true }<CR>]], { noremap = true, silent = true }) | |
vim.api.nvim_set_keymap('n', '<leader>st', [[<cmd>lua require('telescope.builtin').tags()<CR>]], { noremap = true, silent = true }) | |
vim.api.nvim_set_keymap('n', '<leader>sw', [[<cmd>lua require('telescope.builtin').grep_string()<CR>]], { noremap = true, silent = true }) | |
vim.api.nvim_set_keymap('n', '<leader>?', [[<cmd>lua require('telescope.builtin').oldfiles()<CR>]], { noremap = true, silent = true }) | |
-- treesitter | |
require('nvim-treesitter.configs').setup { | |
ensure_installed = { 'c', 'cpp', 'css', 'toml', 'python', 'rust' }, | |
highlight = { | |
enable = true, | |
disable = {'latex'}, | |
-- Currently we have to add Vim's syntax highlighting to avoid every | |
-- keyword being highlighted as a spelling error... | |
additional_vim_regex_highlighting = true, | |
}, | |
incremental_selection = { enable = true }, | |
-- Enabling treesitter's indentation currently causes autoindenting to become very wonky. | |
-- indent = { enable = true }, | |
textobjects = { enable = true }, | |
} | |
-- treesitter-context | |
require('treesitter-context').setup { | |
enable = true, | |
} | |
-- which-key | |
require('which-key').setup {} | |
-- workspace | |
vim.g.workspace_session_name = '.workspace.vim' | |
vim.g.workspace_autosave_untrailspaces = false | |
vim.g.workspace_session_disable_on_args = true | |
vim.g.workspace_autosave_ignore = {'gitcommit', 'diff'} | |
vim.api.nvim_set_keymap('', '<leader>w', ':ToggleWorkspace<Cr>', {noremap=true}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if exists('g:GuiLoaded') | |
GuiLinespace 0 | |
GuiTabline 0 | |
set title | |
endif | |
let output=system("xrandr | grep \\* | cut -d ' ' -f4 -") | |
let s:font_family = 'JuliaMono Medium' | |
if output =~ ".*3840x2560.*" | |
let s:font_size = 14 | |
" set lines=51 columns=140 | |
elseif output =~ ".*2256x1504.*" | |
let s:font_size = 10 | |
" set lines=40 columns=105 | |
elseif output =~ ".*2560x1440.*" | |
let s:font_size = 15 | |
set lines=40 columns=130 | |
elseif output =~ ".*1920x1080.*" | |
let s:font_size = 8 | |
set lines=40 columns=130 | |
else | |
let s:font_size = 13 | |
set lines=50 columns=130 | |
endif | |
function! s:update_font() | |
call rpcnotify(0, 'Gui', 'Font', s:font_family.':h'.string(s:font_size)) | |
endfunction | |
function! s:set_font_family(family) | |
let s:font_family = a:family | |
call s:update_font() | |
endfunction | |
command! -nargs=1 GuiFontFamily call <SID>set_font_family(<args>) | |
" fast font inc/dec | |
call s:update_font() | |
function! s:font_size_dec(count) | |
let l:count = a:count | if l:count < 1 | let l:count = 1 | endif | |
let s:font_size = s:font_size - l:count | |
if s:font_size < 1 | let s:font_size = 1 | endif | |
call s:update_font() | |
endfunction | |
function! s:font_size_inc(count) | |
let l:count = a:count | if l:count < 1 | let l:count = 1 | endif | |
let s:font_size = s:font_size + l:count | |
if s:font_size < 1 | let s:font_size = 1 | endif | |
call s:update_font() | |
endfunction | |
command! GuiFontSizeDec call <SID>font_size_dec(1) | |
command! GuiFontSizeInc call <SID>font_size_inc(1) | |
command! -nargs=1 GuiFontSizeDecN call <SID>font_size_dec(<args>) | |
command! -nargs=1 GuiFontSizeIncN call <SID>font_size_inc(<args>) | |
nnoremap <C-Down> :<C-u>call <SID>font_size_dec(v:count)<CR> | |
nnoremap <C-Up> :<C-u>call <SID>font_size_inc(v:count)<CR> | |
nnoremap <C-ScrollWheelUp> :call <SID>font_size_inc(1)<CR> | |
nnoremap <C-ScrollWheelDown> :call <SID>font_size_dec(1)<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment