most usable config
This commit is contained in:
parent
d89d00af71
commit
3e2dd9c332
6 changed files with 77 additions and 30 deletions
2
init.lua
2
init.lua
|
@ -4,7 +4,7 @@ vim.g.mapleader = ' '
|
||||||
-- Sensible defaults
|
-- Sensible defaults
|
||||||
require('settings')
|
require('settings')
|
||||||
require('plugins')
|
require('plugins')
|
||||||
require('keymappings')
|
|
||||||
require('lsp')
|
require('lsp')
|
||||||
require('filetypes')
|
require('filetypes')
|
||||||
require('theme')
|
require('theme')
|
||||||
|
require('keymappings')
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
local utils = require('utils')
|
local utils = require('utils')
|
||||||
-- Clear highlights (search + trailing whitespace)
|
|
||||||
utils.map('n', '<C-h>', '<cmd>noh<CR>')
|
-- Clear trailing whitespace
|
||||||
utils.map("n", "<C-k>", "<cmd>let _s=@/<Bar>:%s/\\s\\+$//e<Bar>:let @/=_s<Bar><CR>")
|
utils.map("n", "<C-w>", "<cmd>let _s=@/<Bar>:%s/\\s\\+$//e<Bar>:let @/=_s<Bar><CR>")
|
||||||
|
|
||||||
-- Use tab and shift+tab to cycle buffers
|
-- Use tab and shift+tab to cycle buffers
|
||||||
utils.map("n", "<tab>", "<cmd>bn<cr>")
|
utils.map("n", "<tab>", "<cmd>bn<cr>")
|
||||||
utils.map("n", "<S-tab>", "<cmd>bp<cr>")
|
utils.map("n", "<S-tab>", "<cmd>bp<cr>")
|
||||||
|
|
||||||
-- Turn spellchecker on
|
-- Turn spellchecker on and off
|
||||||
utils.map("n", "<leader>se", "<cmd>setlocal spell spelllang=en_us<cr>")
|
utils.map("n", "<leader>se", "<cmd>setlocal spell spelllang=en_us<cr>")
|
||||||
|
utils.map("n", "<leader>sq", "<cmd>setlocal nospell")
|
||||||
|
|
||||||
-- Toggle line numbers and file tree
|
|
||||||
utils.map("n", "<F3>", "<cmd>set nonumber!<CR>")
|
utils.map("n", "<F3>", "<cmd>set nonumber!<CR>")
|
||||||
utils.map("n", "<leader>fe", "<cmd>Oil<CR>")
|
utils.map("n", "<leader>fe", "<cmd>Oil<CR>")
|
||||||
|
utils.map("n", "<C-x><C-f>", "<cmd>Neotree toggle<CR>")
|
||||||
|
|
11
lua/lsp.lua
11
lua/lsp.lua
|
@ -8,10 +8,9 @@ local on_attach = function(client, bufnr)
|
||||||
utils.map("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>")
|
utils.map("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>")
|
||||||
utils.map("n", "<M-k>", "<cmd>lua vim.lsp.buf.type_definition()<CR>")
|
utils.map("n", "<M-k>", "<cmd>lua vim.lsp.buf.type_definition()<CR>")
|
||||||
utils.map("n", "<M-r>", "<cmd>lua vim.lsp.buf.rename()()<CR>")
|
utils.map("n", "<M-r>", "<cmd>lua vim.lsp.buf.rename()()<CR>")
|
||||||
|
utils.map("n", "[d", "<cmd>lua vim.diagnostic.goto_prev()<CR>")
|
||||||
|
utils.map("n", "]d", "<cmd>lua vim.diagnostic.goto_next()<CR>")
|
||||||
utils.map("n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>")
|
utils.map("n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>")
|
||||||
|
|
||||||
-- list/add/remove workspace folders, not that I use them often
|
|
||||||
utils.map("n", "<leader>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>")
|
utils.map("n", "<leader>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>")
|
||||||
utils.map("n", "<leader>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>")
|
utils.map("n", "<leader>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>")
|
||||||
utils.map("n", "<leader>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>")
|
utils.map("n", "<leader>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>")
|
||||||
|
@ -76,9 +75,9 @@ nvim_lsp.rust_analyzer.setup({
|
||||||
enable = true,
|
enable = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
procMacro = {
|
--procMacro = {
|
||||||
enable = true
|
-- enable = true
|
||||||
},
|
--},
|
||||||
checkOnSave = {
|
checkOnSave = {
|
||||||
command = "clippy",
|
command = "clippy",
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,12 +2,53 @@
|
||||||
|
|
||||||
local utils = require('utils')
|
local utils = require('utils')
|
||||||
|
|
||||||
--vim.cmd [[set shortmess+=c]]
|
vim.cmd [[set shortmess+=c]]
|
||||||
--utils.opt('o', 'completeopt', 'menuone,noselect')
|
utils.opt('o', 'completeopt', 'menuone,noselect')
|
||||||
|
|
||||||
local cmp = require('cmp')
|
local cmp = require('cmp')
|
||||||
|
local cmp_kinds = {
|
||||||
|
Text = ' ',
|
||||||
|
Method = ' ',
|
||||||
|
Function = ' ',
|
||||||
|
Constructor = ' ',
|
||||||
|
Field = ' ',
|
||||||
|
Variable = ' ',
|
||||||
|
Class = ' ',
|
||||||
|
Interface = ' ',
|
||||||
|
Module = ' ',
|
||||||
|
Property = ' ',
|
||||||
|
Unit = ' ',
|
||||||
|
Value = ' ',
|
||||||
|
Enum = ' ',
|
||||||
|
Keyword = ' ',
|
||||||
|
Snippet = ' ',
|
||||||
|
Color = ' ',
|
||||||
|
File = ' ',
|
||||||
|
Reference = ' ',
|
||||||
|
Folder = ' ',
|
||||||
|
EnumMember = ' ',
|
||||||
|
Constant = ' ',
|
||||||
|
Struct = ' ',
|
||||||
|
Event = ' ',
|
||||||
|
Operator = ' ',
|
||||||
|
TypeParameter = ' ',
|
||||||
|
}
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
|
formatting = {
|
||||||
|
format = function(entry, vim_item)
|
||||||
|
-- Kind icons
|
||||||
|
vim_item.kind = string.format('%s %s', cmp_kinds[vim_item.kind], vim_item.kind)
|
||||||
|
vim_item.menu = ({
|
||||||
|
buffer = "[Buffer]",
|
||||||
|
nvim_lsp = "[LSP]",
|
||||||
|
luasnip = "[LuaSnip]",
|
||||||
|
nvim_lua = "[Lua]",
|
||||||
|
latex_symbols = "[LaTeX]",
|
||||||
|
})[entry.source.name]
|
||||||
|
return vim_item
|
||||||
|
end
|
||||||
|
},
|
||||||
snippet = {
|
snippet = {
|
||||||
-- REQUIRED - you must specify a snippet engine
|
-- REQUIRED - you must specify a snippet engine
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
|
@ -27,7 +68,6 @@ cmp.setup({
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
['<C-n>'] = cmp.mapping.complete(),
|
|
||||||
['<C-x><C-o>'] = cmp.mapping.complete(),
|
['<C-x><C-o>'] = cmp.mapping.complete(),
|
||||||
['<C-e>'] = cmp.mapping.abort(),
|
['<C-e>'] = cmp.mapping.abort(),
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||||
|
@ -44,13 +84,13 @@ cmp.setup({
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Set configuration for specific filetype.
|
-- Set configuration for specific filetype.
|
||||||
cmp.setup.filetype('gitcommit', {
|
--cmp.setup.filetype('gitcommit', {
|
||||||
sources = cmp.config.sources({
|
-- sources = cmp.config.sources({
|
||||||
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
|
-- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
|
||||||
}, {
|
-- }, {
|
||||||
{ name = 'buffer' },
|
-- { name = 'buffer' },
|
||||||
})
|
-- })
|
||||||
})
|
--})
|
||||||
|
|
||||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||||
cmp.setup.cmdline({ '/', '?' }, {
|
cmp.setup.cmdline({ '/', '?' }, {
|
||||||
|
|
|
@ -5,6 +5,16 @@ require('packer').startup(function()
|
||||||
-- Packer can manage itself as an optional plugin
|
-- Packer can manage itself as an optional plugin
|
||||||
use {'wbthomason/packer.nvim', opt = true }
|
use {'wbthomason/packer.nvim', opt = true }
|
||||||
|
|
||||||
|
use {
|
||||||
|
"nvim-neo-tree/neo-tree.nvim",
|
||||||
|
branch = "v3.x",
|
||||||
|
requires = {
|
||||||
|
"nvim-lua/plenary.nvim",
|
||||||
|
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
|
||||||
|
"MunifTanjim/nui.nvim",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-- Fuzzy finder
|
-- Fuzzy finder
|
||||||
use {
|
use {
|
||||||
'nvim-telescope/telescope.nvim',
|
'nvim-telescope/telescope.nvim',
|
||||||
|
@ -53,7 +63,7 @@ require('packer').startup(function()
|
||||||
}
|
}
|
||||||
use { "lewis6991/gitsigns.nvim" }
|
use { "lewis6991/gitsigns.nvim" }
|
||||||
|
|
||||||
-- Filesystem in a nvim buffer
|
-- Filesystem browser
|
||||||
use { 'stevearc/oil.nvim' }
|
use { 'stevearc/oil.nvim' }
|
||||||
|
|
||||||
-- Misc
|
-- Misc
|
||||||
|
|
|
@ -8,16 +8,13 @@ require('nvim-treesitter.configs').setup {
|
||||||
ident = {
|
ident = {
|
||||||
enable = true,
|
enable = true,
|
||||||
},
|
},
|
||||||
incremental_selection = {
|
rainbow = {
|
||||||
enable = true,
|
enable = true,
|
||||||
keymaps = {
|
extended_mode = false,
|
||||||
init_selection = "gnn", -- set to `false` to disable one of the mappings
|
max_file_lines = nil,
|
||||||
node_incremental = "grn",
|
|
||||||
scope_incremental = "grc",
|
|
||||||
node_decremental = "grm",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vim.api.nvim_set_hl(0, "@variable", { })
|
vim.api.nvim_set_hl(0, "@variable", { })
|
||||||
vim.api.nvim_set_hl(0, "@parameter", { })
|
vim.api.nvim_set_hl(0, "@parameter", { })
|
||||||
|
vim.api.nvim_set_hl(0, "@field", { })
|
||||||
|
|
Loading…
Reference in a new issue