updates & nvim config autoformat

This commit is contained in:
Henrik Bakken
2021-11-06 11:51:11 +01:00
parent 3e1020637b
commit a7c21c43ac
+327 -247
View File
@@ -53,7 +53,10 @@ opt.ignorecase = true -- Ignore case
opt.smartcase = true -- Do not ignore case with capitals opt.smartcase = true -- Do not ignore case with capitals
opt.wildmode = {"full"} -- Command-line completion mode opt.wildmode = {"full"} -- Command-line completion mode
opt.wildignorecase = true opt.wildignorecase = true
opt.wildignore = opt.wildignore + {"*swp", "*.class", "*.pyc", "*.png", "*.jpg", "*.gif", "*.zip", "*/tmp/*", "*.o", ".obj", "*.so"} opt.wildignore = opt.wildignore + {
"*swp", "*.class", "*.pyc", "*.png", "*.jpg", "*.gif", "*.zip", "*/tmp/*",
"*.o", ".obj", "*.so"
}
-- cursor -- cursor
opt.scrolloff = 5 -- Lines of context opt.scrolloff = 5 -- Lines of context
@@ -89,7 +92,8 @@ vim.api.nvim_command [[autocmd!]]
vim.api.nvim_command [[autocmd BufWritePost * %s/\s\+$//e]] vim.api.nvim_command [[autocmd BufWritePost * %s/\s\+$//e]]
vim.api.nvim_command [[autocmd BufWritePost *.py silent! execute ':Black']] vim.api.nvim_command [[autocmd BufWritePost *.py silent! execute ':Black']]
vim.api.nvim_command [[autocmd BufReadPost quickfix nmap <buffer> <cr> <cr>]] vim.api.nvim_command [[autocmd BufReadPost quickfix nmap <buffer> <cr> <cr>]]
vim.api.nvim_command [[autocmd TextYankPost * "lua vim.highlight.on_yank {on_visual = false}"]] vim.api
.nvim_command [[autocmd TextYankPost * "lua vim.highlight.on_yank {on_visual = false}"]]
vim.api.nvim_command [[augroup END]] vim.api.nvim_command [[augroup END]]
-- ---------------------------------------- -- ----------------------------------------
@@ -103,67 +107,76 @@ local map = vim.api.nvim_set_keymap
map("n", "Q", "", {noremap = true}) map("n", "Q", "", {noremap = true})
map("n", "q:", "", {noremap = true}) map("n", "q:", "", {noremap = true})
map("n", "<leader>E", [[:so ~/.config/nvim/init.lua<cr>:PackerInstall<cr>:PackerCompile<cr>]], { noremap = true }) map("n", "<leader>E",
map("n", "<leader>e", [[:vnew ~/dotfiles/nvim/init.lua<cr>]], { noremap = true }) [[:so ~/.config/nvim/init.lua<cr>:PackerInstall<cr>:PackerCompile<cr>]],
map("n", "<leader>nt", [[:vnew ~/notes/todos.md<cr>]], { noremap = true }) {noremap = true})
map("n", "<leader>nc", [[:vnew ~/notes/cheatsheet.md<cr>]], { noremap = true }) map("n", "<leader>e", [[:vnew ~/dotfiles/nvim/init.lua<cr>]], {noremap = true})
map("n", "<leader>nl", [[:vnew ~/notes/libs.md<cr>]], { noremap = true }) map("n", "<leader>nt", [[:vnew ~/notes/todos.md<cr>]], {noremap = true})
map("n", "<leader>nu", [[:vnew ~/notes/urls.md<cr>]], { noremap = true }) map("n", "<leader>nc", [[:vnew ~/notes/cheatsheet.md<cr>]], {noremap = true})
map("n", "<leader>nn", [[:Explore ~/notes<cr>]], { noremap = true }) map("n", "<leader>nl", [[:vnew ~/notes/libs.md<cr>]], {noremap = true})
map("n", "<leader>ww", [[:cd %:p:h<cr>]], { noremap = true }) map("n", "<leader>nu", [[:vnew ~/notes/urls.md<cr>]], {noremap = true})
map("n", "<esc><esc>", ":noh<cr>", { silent = true, noremap = true } ) map("n", "<leader>nn", [[:Explore ~/notes<cr>]], {noremap = true})
map("n", "<leader>ww", [[:cd %:p:h<cr>]], {noremap = true})
map("n", "<esc><esc>", ":noh<cr>", {silent = true, noremap = true})
-- <Tab> to navigate the completion menu -- <Tab> to navigate the completion menu
map("i", "<S-Tab>", [[pumvisible() ? "\<C-p>" : "\<S-Tab>"]], { expr = true, noremap = true }) map("i", "<S-Tab>", [[pumvisible() ? "\<C-p>" : "\<S-Tab>"]],
map("i", "<Tab>", [[pumvisible() ? "\<C-n>" : "\<Tab>"]], { expr = true, noremap = true }) {expr = true, noremap = true})
map("i", "<Tab>", [[pumvisible() ? "\<C-n>" : "\<Tab>"]],
{expr = true, noremap = true})
-- CURSOR -- CURSOR
-- stay visual when indenting -- stay visual when indenting
map("n", "-", "_", { noremap = true }) map("n", "-", "_", {noremap = true})
map("v", "v", "<esc>", { noremap = true }) map("v", "v", "<esc>", {noremap = true})
map("v", "<Tab>", ">gv", { noremap = true }) map("v", "<Tab>", ">gv", {noremap = true})
map("v", "<S-Tab>", "<gv", { noremap = true }) map("v", "<S-Tab>", "<gv", {noremap = true})
map("n", "<leader>o", "m`o<Esc>``", { noremap = true }) -- Insert a newline in normal mode map("n", "<leader>o", "m`o<Esc>``", {noremap = true}) -- Insert a newline in normal mode
-- repeat and next -- repeat and next
map("n", "\\", "n.", { noremap = true }) map("n", "\\", "n.", {noremap = true})
-- WINDOWS / BUFFERS -- WINDOWS / BUFFERS
-- make splits and tabs -- make splits and tabs
map("n", "<M-V>", ":vnew<cr>", { noremap = true }) map("n", "<M-V>", ":vnew<cr>", {noremap = true})
map("n", "<M-S>", ":new<cr>", { noremap = true }) map("n", "<M-S>", ":new<cr>", {noremap = true})
map("n", "<M-v>", ":vsplit<cr>", { noremap = true }) map("n", "<M-v>", ":vsplit<cr>", {noremap = true})
map("n", "<M-s>", ":split<cr>", { noremap = true }) map("n", "<M-s>", ":split<cr>", {noremap = true})
map("n", "<M-t>", ":tabe %<cr>", { noremap = true }) map("n", "<M-t>", ":tabe %<cr>", {noremap = true})
map("n", "<M-T>", ":tabnew<cr>", { noremap = true }) map("n", "<M-T>", ":tabnew<cr>", {noremap = true})
-- buffers and tabs -- buffers and tabs
map("n", "<M-J>", ":bprev<cr>", { noremap = true }) map("n", "<M-J>", ":bprev<cr>", {noremap = true})
map("n", "<M-K>", ":bnext<cr>", { noremap = true }) map("n", "<M-K>", ":bnext<cr>", {noremap = true})
map("n", "<M-H>", ":tabprev<cr>", { noremap = true }) map("n", "<M-H>", ":tabprev<cr>", {noremap = true})
map("n", "<M-L>", ":tabnext<cr>", { noremap = true }) map("n", "<M-L>", ":tabnext<cr>", {noremap = true})
-- resize windows with hjkl -- resize windows with hjkl
map("n", "<C-h>", "5<C-w><", { noremap = true }) map("n", "<C-h>", "5<C-w><", {noremap = true})
map("n", "<C-j>", "5<C-w>-", { noremap = true }) map("n", "<C-j>", "5<C-w>-", {noremap = true})
map("n", "<C-k>", "5<C-w>+", { noremap = true }) map("n", "<C-k>", "5<C-w>+", {noremap = true})
map("n", "<C-l>", "5<C-w>>", { noremap = true }) map("n", "<C-l>", "5<C-w>>", {noremap = true})
-- quickfix window -- quickfix window
map("n", "<C-n>", ":cp<cr>", { noremap = true }) map("n", "<C-n>", ":cp<cr>", {noremap = true})
map("n", "<C-m>", ":cn<cr>", { noremap = true }) map("n", "<C-m>", ":cn<cr>", {noremap = true})
-- remove buffer -- remove buffer
map("n", "<M-d>", ":bprev<bar>:bd#<cr>", { noremap = true }) map("n", "<M-d>", ":bprev<bar>:bd#<cr>", {noremap = true})
map("n", "<M-D>", ":bprev<bar>:bd!#<cr>", { noremap = true }) map("n", "<M-D>", ":bprev<bar>:bd!#<cr>", {noremap = true})
map("n", "<F9>", ":checkt<cr>", { noremap = true }) map("n", "<F9>", ":checkt<cr>", {noremap = true})
-- ---------------------------------------- -- ----------------------------------------
-- PACKER -- PACKER
-- ---------------------------------------- -- ----------------------------------------
local install_path = vim.fn.stdpath("data").."/site/pack/packer/start/packer.nvim" local install_path = vim.fn.stdpath("data") ..
"/site/pack/packer/start/packer.nvim"
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.fn.system({"git", "clone", "https://github.com/wbthomason/packer.nvim", install_path}) vim.fn.system({
"git", "clone", "https://github.com/wbthomason/packer.nvim",
install_path
})
vim.api.nvim_command "packadd packer.nvim" vim.api.nvim_command "packadd packer.nvim"
end end
require("packer").startup {function(use) require("packer").startup {
function(use)
use {"wbthomason/packer.nvim"} use {"wbthomason/packer.nvim"}
-- tpope -- tpope
@@ -181,7 +194,8 @@ require("packer").startup {function(use)
use {"dhruvasagar/vim-table-mode"} use {"dhruvasagar/vim-table-mode"}
-- git -- git
use {"tpope/vim-fugitive", use {
"tpope/vim-fugitive",
config = function() config = function()
local map = vim.api.nvim_set_keymap local map = vim.api.nvim_set_keymap
map("", "<C-g>", ":vertical Git<cr>:vertical resize 60<cr>", {}) map("", "<C-g>", ":vertical Git<cr>:vertical resize 60<cr>", {})
@@ -194,7 +208,7 @@ require("packer").startup {function(use)
"lewis6991/gitsigns.nvim", "lewis6991/gitsigns.nvim",
requires = {"nvim-lua/plenary.nvim"}, requires = {"nvim-lua/plenary.nvim"},
config = function() config = function()
require("gitsigns").setup{ require("gitsigns").setup {
numhl = false, numhl = false,
linehl = false, linehl = false,
keymaps = { keymaps = {
@@ -202,8 +216,14 @@ require("packer").startup {function(use)
noremap = true, noremap = true,
buffer = true, buffer = true,
["n <M-.>"] = { expr = true, [[&diff ? "]c" : "<cmd>lua require('gitsigns.actions').next_hunk()<cr>"]]}, ["n <M-.>"] = {
["n <M-,>"] = { expr = true, [[&diff ? "[c" : "<cmd>lua require('gitsigns.actions').prev_hunk()<cr>"]]}, expr = true,
[[&diff ? "]c" : "<cmd>lua require('gitsigns.actions').next_hunk()<cr>"]]
},
["n <M-,>"] = {
expr = true,
[[&diff ? "[c" : "<cmd>lua require('gitsigns.actions').prev_hunk()<cr>"]]
},
["n <leader>gs"] = [[<cmd>lua require("gitsigns").stage_hunk()<cr>]], ["n <leader>gs"] = [[<cmd>lua require("gitsigns").stage_hunk()<cr>]],
["v <leader>gs"] = [[<cmd>lua require("gitsigns").stage_hunk({vim.fn.line("."), vim.fn.line("v")})<cr>]], ["v <leader>gs"] = [[<cmd>lua require("gitsigns").stage_hunk({vim.fn.line("."), vim.fn.line("v")})<cr>]],
@@ -217,18 +237,19 @@ require("packer").startup {function(use)
["o ih"] = [[:<C-U>lua require("gitsigns.actions").select_hunk()<cr>]], ["o ih"] = [[:<C-U>lua require("gitsigns.actions").select_hunk()<cr>]],
["x ih"] = [[:<C-U>lua require("gitsigns.actions").select_hunk()<cr>]] ["x ih"] = [[:<C-U>lua require("gitsigns.actions").select_hunk()<cr>]]
}, },
word_diff = false, word_diff = false
} }
end end
} }
-- folder tree -- folder tree
use {"kyazdani42/nvim-tree.lua", use {
"kyazdani42/nvim-tree.lua",
requires = {"kyazdani42/nvim-web-devicons"}, requires = {"kyazdani42/nvim-web-devicons"},
config = function() config = function()
require("nvim-tree").setup{ require("nvim-tree").setup {
disable_netrw = false, disable_netrw = false,
auto_close=true, auto_close = true
} }
local map = vim.api.nvim_set_keymap local map = vim.api.nvim_set_keymap
map("n", "<C-p>", ":NvimTreeToggle<cr>", {noremap = true}) map("n", "<C-p>", ":NvimTreeToggle<cr>", {noremap = true})
@@ -236,28 +257,27 @@ require("packer").startup {function(use)
} }
-- theme -- theme
use {"folke/tokyonight.nvim", use {
config = function() "folke/tokyonight.nvim",
vim.g.tokyonight_style = "night" config = function() vim.g.tokyonight_style = "night" end
end
} }
use {"sonph/onehalf", rtp = "vim", } use {"sonph/onehalf", rtp = "vim"}
use {"tomasr/molokai", } use {"tomasr/molokai"}
use {"morhetz/gruvbox", } use {"morhetz/gruvbox"}
use {"jnurmine/Zenburn", } use {"jnurmine/Zenburn"}
use {"nanotech/jellybeans.vim", } use {"nanotech/jellybeans.vim"}
use {"mhartington/oceanic-next", } use {"mhartington/oceanic-next"}
use {"NLKNguyen/papercolor-theme", } use {"NLKNguyen/papercolor-theme"}
use {"drewtempelmeyer/palenight.vim", } use {"drewtempelmeyer/palenight.vim"}
use {"altercation/vim-colors-solarized", } use {"altercation/vim-colors-solarized"}
use {"rakr/vim-one", use {
config = function() "rakr/vim-one",
vim.g.one_allow_italics = 1 config = function() vim.g.one_allow_italics = 1 end
end
} }
use {"ayu-theme/ayu-vim", use {
"ayu-theme/ayu-vim",
config = function() config = function()
-- vim.g.ayucolor = "light" -- vim.g.ayucolor = "light"
-- vim.g.ayucolor = "mirage" -- vim.g.ayucolor = "mirage"
@@ -265,26 +285,22 @@ require("packer").startup {function(use)
end end
} }
use {"skbolton/embark", use {
config = function() "skbolton/embark",
vim.g.embark_terminal_italics = 1 config = function() vim.g.embark_terminal_italics = 1 end
end
} }
use {"arcticicestudio/nord-vim", use {"arcticicestudio/nord-vim", config = function() end}
config = function()
end
}
use {"junegunn/seoul256.vim", use {
config = function() "junegunn/seoul256.vim",
vim.g.seoul256_background = 235 config = function() vim.g.seoul256_background = 235 end
end
} }
vim.cmd "colorscheme OceanicNext" vim.cmd "colorscheme OceanicNext"
-- coloring of colornames -- coloring of colornames
use {"rrethy/vim-hexokinase", use {
"rrethy/vim-hexokinase",
run = "cd /home/hjalmarlucius/.local/share/nvim/site/pack/packer/start/vim-hexokinase && make hexokinase", run = "cd /home/hjalmarlucius/.local/share/nvim/site/pack/packer/start/vim-hexokinase && make hexokinase",
config = function() config = function()
vim.g.Hexokinase_highlighters = {"backgroundfull"} vim.g.Hexokinase_highlighters = {"backgroundfull"}
@@ -292,9 +308,11 @@ require("packer").startup {function(use)
} }
-- flashing cursor on move -- flashing cursor on move
use {"danilamihailov/beacon.nvim", use {
"danilamihailov/beacon.nvim",
setup = function() setup = function()
vim.api.nvim_exec( [[highlight Beacon guibg=white ctermbg=15]], false) vim.api.nvim_exec([[highlight Beacon guibg=white ctermbg=15]],
false)
end, end,
config = function() config = function()
vim.g.beacon_size = 40 vim.g.beacon_size = 40
@@ -304,14 +322,16 @@ require("packer").startup {function(use)
} }
-- indentation guides -- indentation guides
use {"lukas-reineke/indent-blankline.nvim", use {
"lukas-reineke/indent-blankline.nvim",
config = function() config = function()
vim.g.indent_blankline_char = "|" vim.g.indent_blankline_char = "|"
vim.g.indent_blankline_use_treesitter = true vim.g.indent_blankline_use_treesitter = true
end end
} }
use {"haya14busa/vim-asterisk", use {
"haya14busa/vim-asterisk",
config = function() config = function()
vim.g["asterisk#keeppos"] = 1 vim.g["asterisk#keeppos"] = 1
local map = vim.api.nvim_set_keymap local map = vim.api.nvim_set_keymap
@@ -322,12 +342,13 @@ require("packer").startup {function(use)
end end
} }
use {"christoomey/vim-tmux-navigator", use {
"christoomey/vim-tmux-navigator",
config = function() config = function()
vim.g.tmux_navigator_no_mappings = 1 vim.g.tmux_navigator_no_mappings = 1
vim.g.tmux_navigator_disable_when_zoomed = 1 vim.g.tmux_navigator_disable_when_zoomed = 1
local map = vim.api.nvim_set_keymap local map = vim.api.nvim_set_keymap
opts = { silent = true, noremap = true } opts = {silent = true, noremap = true}
map("n", "<M-h>", ":TmuxNavigateLeft<cr>", opts) map("n", "<M-h>", ":TmuxNavigateLeft<cr>", opts)
map("n", "<M-j>", ":TmuxNavigateDown<cr>", opts) map("n", "<M-j>", ":TmuxNavigateDown<cr>", opts)
map("n", "<M-k>", ":TmuxNavigateUp<cr>", opts) map("n", "<M-k>", ":TmuxNavigateUp<cr>", opts)
@@ -335,14 +356,17 @@ require("packer").startup {function(use)
end end
} }
use {"mbbill/undotree", use {
"mbbill/undotree",
config = function() config = function()
local map = vim.api.nvim_set_keymap local map = vim.api.nvim_set_keymap
map("", "<F11>", ":UndotreeToggle<cr>:UndotreeFocus<cr>", { noremap = true }) map("", "<F11>", ":UndotreeToggle<cr>:UndotreeFocus<cr>",
{noremap = true})
end end
} }
use {"iamcco/markdown-preview.nvim", -- requires yarn use {
"iamcco/markdown-preview.nvim", -- requires yarn
run = "cd /home/hjalmarlucius/.local/share/nvim/site/pack/packer/start/markdown-preview && yarn install", run = "cd /home/hjalmarlucius/.local/share/nvim/site/pack/packer/start/markdown-preview && yarn install",
config = function() config = function()
vim.g.mkdp_auto_start = 0 -- auto start on moving into vim.g.mkdp_auto_start = 0 -- auto start on moving into
@@ -352,108 +376,109 @@ require("packer").startup {function(use)
end end
} }
use {"hoob3rt/lualine.nvim", use {
"hoob3rt/lualine.nvim",
requires = {"kyazdani42/nvim-web-devicons"}, requires = {"kyazdani42/nvim-web-devicons"},
config = function() config = function()
require("lualine").setup { require("lualine").setup {
options = { options = {theme = "auto"},
theme = "auto", extensions = {"fugitive"},
},
extensions = {
"fugitive",
},
sections = { sections = {
lualine_a = {"mode"}, lualine_a = {"mode"},
lualine_b = {"branch"}, lualine_b = {"branch"},
lualine_c = {{"filename", file_status = true, path = 1}, {"diff", colored=false}, { "diagnostics", sources = {"nvim_lsp"}}}, lualine_c = {{"filename", file_status = true, path = 1}}, -- , {"diff", colored=false}, { "diagnostics", sources = {"nvim_lsp"}}
lualine_x = {"encoding", "fileformat", "filetype"}, lualine_x = {"filetype"},
lualine_y = {"progress"}, lualine_y = {"progress"}, -- "encoding", "fileformat",
lualine_z = {"location"} lualine_z = {"location"}
}, },
inactive_sections = { inactive_sections = {
lualine_a = {}, lualine_a = {},
lualine_b = {}, lualine_b = {},
lualine_c = {{"filename", file_status = true, path = 1}}, lualine_c = {{"filename", file_status = true, path = 1}},
lualine_x = {"location"}, lualine_x = {},
lualine_y = {"progress"}, lualine_y = {"progress"},
lualine_z = {} lualine_z = {"location"}
}, }
} }
end end
} }
use {"akinsho/nvim-bufferline.lua", use {
"akinsho/nvim-bufferline.lua",
requires = {"kyazdani42/nvim-web-devicons"}, requires = {"kyazdani42/nvim-web-devicons"},
config = function() config = function()
require("bufferline").setup{ require("bufferline").setup {
options = { options = {diagnostics = "nvim_lsp"}
diagnostics = "nvim_lsp",
}
} }
local map = vim.api.nvim_set_keymap local map = vim.api.nvim_set_keymap
map("n", "<M-J>", ":BufferLineCyclePrev<cr>", { noremap = true, silent=true }) map("n", "<M-J>", ":BufferLineCyclePrev<cr>",
map("n", "<M-K>", ":BufferLineCycleNext<cr>", { noremap = true, silent=true }) {noremap = true, silent = true})
map("n", "<M-N>", ":BufferLineMovePrev<cr>", { noremap = true, silent=true }) map("n", "<M-K>", ":BufferLineCycleNext<cr>",
map("n", "<M-M>", ":BufferLineMoveNext<cr>", { noremap = true, silent=true }) {noremap = true, silent = true})
map("n", "<M-N>", ":BufferLineMovePrev<cr>",
{noremap = true, silent = true})
map("n", "<M-M>", ":BufferLineMoveNext<cr>",
{noremap = true, silent = true})
end end
} }
use {"numtostr/FTerm.nvim", use {
"numtostr/FTerm.nvim",
config = function() config = function()
require("FTerm").setup{} require("FTerm").setup {}
local map = vim.api.nvim_set_keymap local map = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true } local opts = {noremap = true, silent = true}
map("n", "<F2>", [[<cmd>lua require("FTerm").toggle()<cr>]], opts) map("n", "<F2>", [[<cmd>lua require("FTerm").toggle()<cr>]],
map("t", "<F2>", [[<C-\><C-n><cmd>lua require("FTerm").toggle()<cr>]], opts) opts)
map("t", "<F2>",
[[<C-\><C-n><cmd>lua require("FTerm").toggle()<cr>]], opts)
end end
} }
use {"psf/black", use {"psf/black", config = function() vim.g.black_fast = 1 end}
config = function()
vim.g.black_fast = 1
end
}
-- treesitter -- treesitter
use {"nvim-treesitter/nvim-treesitter", use {
"nvim-treesitter/nvim-treesitter",
run = ":TSUpdate", run = ":TSUpdate",
config = function() config = function()
require("nvim-treesitter.configs").setup { require("nvim-treesitter.configs").setup {
ensure_installed = "all", ensure_installed = "all"
} }
vim.opt.foldexpr = "nvim_treesitter#foldexpr()" vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
end end
} }
use {"nvim-telescope/telescope.nvim", use {
"nvim-telescope/telescope.nvim",
requires = {"nvim-lua/popup.nvim", "nvim-lua/plenary.nvim"}, requires = {"nvim-lua/popup.nvim", "nvim-lua/plenary.nvim"},
config = function() config = function()
-- TODO grep with regex -- TODO grep with regex
local map = vim.api.nvim_set_keymap local map = vim.api.nvim_set_keymap
local opts = { noremap = true } local opts = {noremap = true}
local actions = require("telescope.actions") local actions = require("telescope.actions")
map("n", "<M-F>", "<cmd>Telescope find_files<cr>", opts ) map("n", "<M-F>", "<cmd>Telescope find_files<cr>", opts)
map("n", "<M-f>", "<cmd>Telescope git_files<cr>", opts ) map("n", "<M-f>", "<cmd>Telescope git_files<cr>", opts)
map("n", "<M-w>", "<cmd>Telescope live_grep<cr>", opts ) map("n", "<M-w>", "<cmd>Telescope live_grep<cr>", opts)
map("n", "<M-W>", "<cmd>Telescope grep_string<cr>", opts ) map("n", "<M-W>", "<cmd>Telescope grep_string<cr>", opts)
map("n", "<M-b>", "<cmd>Telescope buffers<cr>", opts ) map("n", "<M-b>", "<cmd>Telescope buffers<cr>", opts)
map("n", "<M-y>", "<cmd>Telescope filetypes<cr>", opts ) map("n", "<M-y>", "<cmd>Telescope filetypes<cr>", opts)
map("n", "<F3>", "<cmd>Telescope colorscheme<cr>", opts ) map("n", "<F3>", "<cmd>Telescope colorscheme<cr>", opts)
map("n", "<leader>la", "<cmd>Telescope lsp_code_actions<cr>", opts ) map("n", "<leader>la", "<cmd>Telescope lsp_code_actions<cr>",
map("v", "<leader>la", "<cmd>Telescope lsp_range_code_actions<cr>", opts ) opts)
map("n", "<leader>ld", "<cmd>Telescope lsp_document_diagnostics<cr>", opts ) map("v", "<leader>la",
map("n", "<leader>lD", "<cmd>Telescope lsp_workspace_diagnostics<cr>", opts ) "<cmd>Telescope lsp_range_code_actions<cr>", opts)
map("n", "<F12>", "<cmd>Telescope<cr>", opts ) map("n", "<leader>ld",
require("telescope").setup{ "<cmd>Telescope lsp_document_diagnostics<cr>", opts)
map("n", "<leader>lD",
"<cmd>Telescope lsp_workspace_diagnostics<cr>", opts)
map("n", "<F12>", "<cmd>Telescope<cr>", opts)
require("telescope").setup {
defaults = { defaults = {
vimgrep_arguments = { vimgrep_arguments = {
"rg", "rg", "--color=never", "--no-heading",
"--color=never",
"--no-heading",
-- "--with-filename", -- "--with-filename",
"--line-number", "--line-number", "--column", "--smart-case"
"--column",
"--smart-case"
}, },
mappings = { mappings = {
i = { i = {
@@ -462,64 +487,83 @@ use {"nvim-treesitter/nvim-treesitter",
["<C-k>"] = actions.move_selection_previous, ["<C-k>"] = actions.move_selection_previous,
["<C-b>"] = actions.preview_scrolling_up, ["<C-b>"] = actions.preview_scrolling_up,
["<C-f>"] = actions.preview_scrolling_down, ["<C-f>"] = actions.preview_scrolling_down,
["<cr>"] = actions.select_default + actions.center, ["<cr>"] = actions.select_default +
actions.center,
["<C-s>"] = actions.select_horizontal, ["<C-s>"] = actions.select_horizontal,
["<C-v>"] = actions.select_vertical, ["<C-v>"] = actions.select_vertical,
["<C-t>"] = actions.select_tab, ["<C-t>"] = actions.select_tab,
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_worse, ["<S-Tab>"] = actions.toggle_selection +
["<Tab>"] = actions.toggle_selection + actions.move_selection_better, actions.move_selection_worse,
["<C-q>"] = actions.send_to_qflist + actions.open_qflist, ["<Tab>"] = actions.toggle_selection +
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist, actions.move_selection_better,
["<C-q>"] = actions.send_to_qflist +
actions.open_qflist,
["<M-q>"] = actions.send_selected_to_qflist +
actions.open_qflist,
["<C-l>"] = actions.complete_tag ["<C-l>"] = actions.complete_tag
}, }
}, },
file_ignore_patterns = {}, file_ignore_patterns = {},
set_env = { ["COLORTERM"] = "truecolor" }, set_env = {["COLORTERM"] = "truecolor"}
}, }
}
end
} }
end }
-- autocompletion -- autocompletion
use {"hrsh7th/nvim-cmp", use {
"hrsh7th/nvim-cmp",
requires = { requires = {
{ "hrsh7th/cmp-nvim-lsp", after = "nvim-cmp" }, {"hrsh7th/cmp-nvim-lsp", after = "nvim-cmp"},
{ "hrsh7th/cmp-path", after = "nvim-cmp" }, {"hrsh7th/cmp-path", after = "nvim-cmp"},
{ "hrsh7th/cmp-buffer", after = "nvim-cmp" }, {"hrsh7th/cmp-buffer", after = "nvim-cmp"},
{ "hrsh7th/cmp-calc", after = "nvim-cmp" }, {"hrsh7th/cmp-calc", after = "nvim-cmp"}
}, },
config = function() config = function()
local cmp = require("cmp") local cmp = require("cmp")
cmp.setup({ cmp.setup({
mapping = { mapping = {
['<C-n>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), ['<C-n>'] = cmp.mapping.select_next_item({
['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), behavior = cmp.SelectBehavior.Insert
['<tab>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), }),
['<S-tab>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), ['<C-p>'] = cmp.mapping.select_prev_item({
['<Down>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), behavior = cmp.SelectBehavior.Insert
['<Up>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), }),
['<tab>'] = cmp.mapping.select_next_item({
behavior = cmp.SelectBehavior.Insert
}),
['<S-tab>'] = cmp.mapping.select_prev_item({
behavior = cmp.SelectBehavior.Insert
}),
['<Down>'] = cmp.mapping.select_next_item({
behavior = cmp.SelectBehavior.Select
}),
['<Up>'] = cmp.mapping.select_prev_item({
behavior = cmp.SelectBehavior.Select
}),
['<C-d>'] = cmp.mapping.scroll_docs(-4), ['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4), ['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(), ['<C-Space>'] = cmp.mapping.complete(),
['<esc>'] = cmp.mapping.close(), ['<esc>'] = cmp.mapping.close(),
['<cr>'] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true, }) ['<cr>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true
})
}, },
sources = { sources = {
{ name = "nvim_lsp" }, {name = "nvim_lsp"}, {name = "buffer"}
{ name = "buffer" },
-- { name = "path" }, -- { name = "path" },
-- { name = "nvim_lua" }, -- { name = "nvim_lua" },
}, },
sorting = { sorting = {
comparators = { comparators = {
cmp.config.compare.exact, cmp.config.compare.exact, cmp.config.compare.offset,
cmp.config.compare.offset,
cmp.config.compare.score, cmp.config.compare.score,
cmp.config.compare.sort_text, cmp.config.compare.sort_text,
cmp.config.compare.kind, cmp.config.compare.kind, cmp.config.compare.length,
cmp.config.compare.length, cmp.config.compare.order
cmp.config.compare.order, }
} }
},
}) })
end end
} }
@@ -541,9 +585,9 @@ use {"nvim-treesitter/nvim-treesitter",
cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor
refresh = "r", -- manually refresh refresh = "r", -- manually refresh
jump = {"<cr>", "<tab>"}, -- jump to the diagnostic or open / close folds jump = {"<cr>", "<tab>"}, -- jump to the diagnostic or open / close folds
open_split = { "<c-s>" }, -- open buffer in new split open_split = {"<c-s>"}, -- open buffer in new split
open_vsplit = { "<c-v>" }, -- open buffer in new vsplit open_vsplit = {"<c-v>"}, -- open buffer in new vsplit
open_tab = { "<c-t>" }, -- open buffer in new tab open_tab = {"<c-t>"}, -- open buffer in new tab
jump_close = {"o"}, -- jump to the diagnostic and close the list jump_close = {"o"}, -- jump to the diagnostic and close the list
toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode
toggle_preview = "P", -- toggle auto_preview toggle_preview = "P", -- toggle auto_preview
@@ -559,10 +603,10 @@ use {"nvim-treesitter/nvim-treesitter",
auto_open = false, -- automatically open the list when you have diagnostics auto_open = false, -- automatically open the list when you have diagnostics
auto_close = false, -- automatically close the list when you have no diagnostics auto_close = false, -- automatically close the list when you have no diagnostics
auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
auto_fold = false, -- automatically fold a file trouble list at creation auto_fold = false -- automatically fold a file trouble list at creation
} }
local map = vim.api.nvim_set_keymap local map = vim.api.nvim_set_keymap
local opts = { noremap = true } local opts = {noremap = true}
map("n", "<C-t>", ":Trouble lsp_workspace_diagnostics<cr>", opts) map("n", "<C-t>", ":Trouble lsp_workspace_diagnostics<cr>", opts)
map("n", "<F6>", ":Trouble quickfix<cr>", opts) map("n", "<F6>", ":Trouble quickfix<cr>", opts)
map("n", "<F7>", ":Trouble loclist<cr>", opts) map("n", "<F7>", ":Trouble loclist<cr>", opts)
@@ -570,7 +614,8 @@ use {"nvim-treesitter/nvim-treesitter",
end end
} }
use {"folke/todo-comments.nvim", use {
"folke/todo-comments.nvim",
requires = {"nvim-lua/plenary.nvim"}, requires = {"nvim-lua/plenary.nvim"},
config = function() config = function()
require("todo-comments").setup { require("todo-comments").setup {
@@ -578,79 +623,105 @@ use {"nvim-treesitter/nvim-treesitter",
sign_priority = 8, -- sign priority sign_priority = 8, -- sign priority
-- keywords recognized as todo comments -- keywords recognized as todo comments
keywords = { keywords = {
ERROR = { icon = "", color = "error" }, ERROR = {icon = "", color = "error"},
WIP = { icon = "", color = "warning" }, WIP = {icon = "", color = "warning"},
TODO = { icon = "", color = "warning" }, TODO = {icon = "", color = "warning"},
PERF = { icon = "", color = "info" }, PERF = {icon = "", color = "info"},
TEST = { icon = "", color = "info" }, TEST = {icon = "", color = "info"},
MAYBE = { icon = "", color = "default" }, MAYBE = {icon = "", color = "default"},
IDEA = { icon = "", color = "hint" }, IDEA = {icon = "", color = "hint"}
}, },
merge_keywords = true, -- when true, custom keywords will be merged with the defaults merge_keywords = true, -- when true, custom keywords will be merged with the defaults
highlight = { keyword = "bg", pattern = [[<(KEYWORDS)\s*]], }, highlight = {keyword = "bg", pattern = [[<(KEYWORDS)\s*]]},
search = { pattern = [[\b(KEYWORDS)\b]], }, search = {pattern = [[\b(KEYWORDS)\b]]},
colors = { colors = {
error = { "#E15030" }, error = {"#E15030"},
warning = { "#FBBF24" }, warning = {"#FBBF24"},
info = { "#91BED0" }, info = {"#91BED0"},
hint = { "#10B981" }, hint = {"#10B981"},
default = { "#91D0C1" }, default = {"#91D0C1"}
}, }
} }
local map = vim.api.nvim_set_keymap local map = vim.api.nvim_set_keymap
local opts = { noremap = true } local opts = {noremap = true}
map("n", "<F5>", ":TodoTrouble<cr>", opts) map("n", "<F5>", ":TodoTrouble<cr>", opts)
end end
} }
use {"neovim/nvim-lspconfig", use {
"neovim/nvim-lspconfig",
run = ":TSUpdate", run = ":TSUpdate",
config = function() config = function()
-- see https://github.com/lukas-reineke/dotfiles/blob/master/vim/lua/lsp/init.lua -- see https://github.com/lukas-reineke/dotfiles/blob/master/vim/lua/lsp/init.lua
on_attach = function (client, bufnr) on_attach = function(client, bufnr)
local bmap = vim.api.nvim_buf_set_keymap local bmap = vim.api.nvim_buf_set_keymap
local opts = { noremap = true } local opts = {noremap = true}
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") vim.api.nvim_buf_set_option(bufnr, "omnifunc",
"v:lua.vim.lsp.omnifunc")
vim.lsp.set_log_level("error") vim.lsp.set_log_level("error")
-- workspaces -- workspaces
bmap(bufnr, "n", "<leader>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<cr>", opts) bmap(bufnr, "n", "<leader>wa",
bmap(bufnr, "n", "<leader>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<cr>", opts) "<cmd>lua vim.lsp.buf.add_workspace_folder()<cr>", opts)
bmap(bufnr, "n", "<leader>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<cr>", opts) bmap(bufnr, "n", "<leader>wr",
"<cmd>lua vim.lsp.buf.remove_workspace_folder()<cr>",
opts)
bmap(bufnr, "n", "<leader>wl",
"<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<cr>",
opts)
-- jump -- jump
bmap(bufnr, "n", "gl", "<cmd>lua vim.lsp.diagnostic.set_loclist({severity_limit='Warning'})<cr>", opts) bmap(bufnr, "n", "gl",
bmap(bufnr, "n", "<M-i>", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics({show_header=false})<cr>", opts) "<cmd>lua vim.lsp.diagnostic.set_loclist({severity_limit='Warning'})<cr>",
bmap(bufnr, "n", "<M-m>", "<cmd>lua vim.lsp.diagnostic.goto_next({severity_limit='Warning', popup_opts={show_header=false}})<cr>", opts) opts)
bmap(bufnr, "n", "<M-n>", "<cmd>lua vim.lsp.diagnostic.goto_prev({severity_limit='Warning', popup_opts={show_header=false}})<cr>", opts) bmap(bufnr, "n", "<M-i>",
"<cmd>lua vim.lsp.diagnostic.show_line_diagnostics({show_header=false})<cr>",
opts)
bmap(bufnr, "n", "<M-m>",
"<cmd>lua vim.lsp.diagnostic.goto_next({severity_limit='Warning', popup_opts={show_header=false}})<cr>",
opts)
bmap(bufnr, "n", "<M-n>",
"<cmd>lua vim.lsp.diagnostic.goto_prev({severity_limit='Warning', popup_opts={show_header=false}})<cr>",
opts)
-- popups -- popups
bmap(bufnr, "n", "<M-x>", "<cmd>lua vim.lsp.buf.signature_help()<cr>", opts) bmap(bufnr, "n", "<M-x>",
bmap(bufnr, "i", "<M-x>", "<cmd>lua vim.lsp.buf.signature_help()<cr>", opts) "<cmd>lua vim.lsp.buf.signature_help()<cr>", opts)
bmap(bufnr, "i", "<M-x>",
"<cmd>lua vim.lsp.buf.signature_help()<cr>", opts)
-- other -- other
if client.resolved_capabilities.goto_definition then if client.resolved_capabilities.goto_definition then
bmap(bufnr, "n", "gd", ":lua vim.lsp.buf.definition()<cr>", opts) bmap(bufnr, "n", "gd",
":lua vim.lsp.buf.definition()<cr>", opts)
end end
if client.resolved_capabilities.find_references then if client.resolved_capabilities.find_references then
bmap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<cr>", opts) bmap(bufnr, "n", "gr",
"<cmd>lua vim.lsp.buf.references()<cr>", opts)
end end
if client.resolved_capabilities.hover then if client.resolved_capabilities.hover then
bmap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<cr>", opts) bmap(bufnr, "n", "K",
"<cmd>lua vim.lsp.buf.hover()<cr>", opts)
end end
if client.resolved_capabilities.rename then if client.resolved_capabilities.rename then
bmap(bufnr, "n", "<M-r>", "<cmd>lua vim.lsp.buf.rename()<cr>", opts) bmap(bufnr, "n", "<M-r>",
"<cmd>lua vim.lsp.buf.rename()<cr>", opts)
end end
if client.resolved_capabilities.document_formatting or client.resolved_capabilities.document_range_formatting then if client.resolved_capabilities.document_formatting or
client.resolved_capabilities.document_range_formatting then
vim.api.nvim_command [[augroup Format]] vim.api.nvim_command [[augroup Format]]
vim.api.nvim_command [[autocmd! * <buffer>]] vim.api.nvim_command [[autocmd! * <buffer>]]
vim.api.nvim_command [[autocmd BufWritePost *.py lua vim.lsp.buf.formatting_seq_sync()]] vim.api
vim.api.nvim_command [[autocmd BufWritePost *.md lua vim.lsp.buf.formatting_seq_sync()]] .nvim_command [[autocmd BufWritePost *.py lua vim.lsp.buf.formatting_seq_sync()]]
vim.api.nvim_command [[autocmd BufWritePost *.yaml lua vim.lsp.buf.formatting_seq_sync()]] vim.api
.nvim_command [[autocmd BufWritePost *.lua lua vim.lsp.buf.formatting_seq_sync()]]
vim.api
.nvim_command [[autocmd BufWritePost *.md lua vim.lsp.buf.formatting_seq_sync()]]
vim.api
.nvim_command [[autocmd BufWritePost *.yaml lua vim.lsp.buf.formatting_seq_sync()]]
vim.api.nvim_command [[augroup END]] vim.api.nvim_command [[augroup END]]
end end
end end
local nvim_lsp = require("lspconfig") local nvim_lsp = require("lspconfig")
-- sudo npm install -g typescript typescript-language-server nvim_lsp.tsserver.setup {}
nvim_lsp.tsserver.setup{} nvim_lsp.yamlls.setup {
-- sudo npm install -g yaml-language-server
nvim_lsp.yamlls.setup{
on_attach = on_attach, on_attach = on_attach,
settings = { settings = {
yaml = { yaml = {
@@ -658,34 +729,28 @@ use {"nvim-treesitter/nvim-treesitter",
"!ChildContainer mapping", "!ChildContainer mapping",
"!ChildClassVar mapping", "!ChildClassVar mapping",
"!ConstantTensorClassVar mapping", "!ConstantTensorClassVar mapping",
"!ConstantClassVar mapping", "!ConstantClassVar mapping", "!Dtype scalar",
"!Dtype scalar", "!DtypeTensor scalar", "!ImportClass scalar",
"!DtypeTensor scalar",
"!ImportClass scalar",
"!SeriesTensor mapping", "!SeriesTensor mapping",
"!ReferenceContainer mapping", "!ReferenceContainer mapping",
"!ReferenceLink mapping", "!ReferenceLink mapping",
"!SeriesTensorClassVar mapping", "!SeriesTensorClassVar mapping",
"!UDFfactory scalar", "!UDFfactory scalar", "!UDFnu scalar",
"!UDFnu scalar", "!UDFvalidator scalar", "!Unit scalar",
"!UDFvalidator scalar", "!UserClass mapping", "!UserInstance mapping",
"!Unit scalar", "!getattr mapping"
"!UserClass mapping",
"!UserInstance mapping",
"!getattr mapping",
} }
} }
} }
} }
-- sudo npm install -g pyright nvim_lsp.pyright.setup {
nvim_lsp.pyright.setup{
on_attach = on_attach, on_attach = on_attach,
settings = { settings = {
python = { python = {
analysis = { analysis = {
diagnosticMode = "workspace", diagnosticMode = "workspace",
logLevel = "Warning", logLevel = "Warning",
typeCheckingMode = "basic", typeCheckingMode = "basic"
} }
} }
} }
@@ -693,13 +758,15 @@ use {"nvim-treesitter/nvim-treesitter",
local prettier = { local prettier = {
formatCommand = ([[prettier ${--config-precedence:configPrecedence} ${--tab-width:tabWidth} ${--single-quote:singleQuote} ${--trailing-comma:trailingComma}]]) formatCommand = ([[prettier ${--config-precedence:configPrecedence} ${--tab-width:tabWidth} ${--single-quote:singleQuote} ${--trailing-comma:trailingComma}]])
} }
nvim_lsp.efm.setup{ nvim_lsp.efm.setup {
on_attach = on_attach, on_attach = on_attach,
init_options = { documentFormatting = true }, init_options = {documentFormatting = true},
filetypes = { "python", "markdown", "yaml", "lua", "javascript" }, filetypes = {
"python", "markdown", "yaml", "lua", "javascript"
},
root_dir = vim.loop.cwd, root_dir = vim.loop.cwd,
settings = { settings = {
rootMarkers = { ".git/" }, rootMarkers = {".git/"},
languages = { languages = {
python = { python = {
{ {
@@ -707,20 +774,33 @@ use {"nvim-treesitter/nvim-treesitter",
lintFormats = {"%f:%l:%c: %t%n%n%n %m"}, lintFormats = {"%f:%l:%c: %t%n%n%n %m"},
lintSource = "flake8", lintSource = "flake8",
lintStdin = true, lintStdin = true,
lintIgnoreExitCode = true, lintIgnoreExitCode = true
}, }, {
{
formatCommand = "isort --stdout --profile black --force-single-line-imports -", formatCommand = "isort --stdout --profile black --force-single-line-imports -",
formatStdin = true formatStdin = true
}, -- }, {
-- lintCommand = "mypy --show-column-numbers --ignore-missing-imports",
-- lintFormats = {
-- "%f=%l:%c: %trror: %m",
-- "%f=%l:%c: %tarning: %m",
-- "%f=%l:%c: %tote: %m"
-- }
}
}, },
javascript = {prettier, eslint}, javascript = {prettier, eslint},
yaml = {prettier}, yaml = {prettier},
markdown = {prettier}, markdown = {prettier},
}, lua = {
}, {
formatCommand = "lua-format -i",
formatStdin = true
}
}
}
}
} }
end end
} }
end end
} }