most usable config

This commit is contained in:
Vladan Popovic 2024-01-04 00:45:21 +01:00
parent d89d00af71
commit 3e2dd9c332
6 changed files with 77 additions and 30 deletions

View file

@ -4,7 +4,7 @@ vim.g.mapleader = ' '
-- Sensible defaults
require('settings')
require('plugins')
require('keymappings')
require('lsp')
require('filetypes')
require('theme')
require('keymappings')

View file

@ -1,15 +1,16 @@
local utils = require('utils')
-- Clear highlights (search + trailing whitespace)
utils.map('n', '<C-h>', '<cmd>noh<CR>')
utils.map("n", "<C-k>", "<cmd>let _s=@/<Bar>:%s/\\s\\+$//e<Bar>:let @/=_s<Bar><CR>")
-- Clear trailing whitespace
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
utils.map("n", "<tab>", "<cmd>bn<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>sq", "<cmd>setlocal nospell")
-- Toggle line numbers and file tree
utils.map("n", "<F3>", "<cmd>set nonumber!<CR>")
utils.map("n", "<leader>fe", "<cmd>Oil<CR>")
utils.map("n", "<C-x><C-f>", "<cmd>Neotree toggle<CR>")

View file

@ -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", "<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", "[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>")
-- 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>wa", "<cmd>lua vim.lsp.buf.add_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,
},
},
procMacro = {
enable = true
},
--procMacro = {
-- enable = true
--},
checkOnSave = {
command = "clippy",
},

View file

@ -2,12 +2,53 @@
local utils = require('utils')
--vim.cmd [[set shortmess+=c]]
--utils.opt('o', 'completeopt', 'menuone,noselect')
vim.cmd [[set shortmess+=c]]
utils.opt('o', 'completeopt', 'menuone,noselect')
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({
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 = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
@ -27,7 +68,6 @@ cmp.setup({
mapping = cmp.mapping.preset.insert({
['<C-b>'] = 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-e>'] = cmp.mapping.abort(),
['<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.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
}, {
{ name = 'buffer' },
})
})
--cmp.setup.filetype('gitcommit', {
-- sources = cmp.config.sources({
-- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
-- }, {
-- { name = 'buffer' },
-- })
--})
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ '/', '?' }, {

View file

@ -5,6 +5,16 @@ require('packer').startup(function()
-- Packer can manage itself as an optional plugin
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
use {
'nvim-telescope/telescope.nvim',
@ -53,7 +63,7 @@ require('packer').startup(function()
}
use { "lewis6991/gitsigns.nvim" }
-- Filesystem in a nvim buffer
-- Filesystem browser
use { 'stevearc/oil.nvim' }
-- Misc

View file

@ -8,16 +8,13 @@ require('nvim-treesitter.configs').setup {
ident = {
enable = true,
},
incremental_selection = {
rainbow = {
enable = true,
keymaps = {
init_selection = "gnn", -- set to `false` to disable one of the mappings
node_incremental = "grn",
scope_incremental = "grc",
node_decremental = "grm",
},
extended_mode = false,
max_file_lines = nil,
}
}
vim.api.nvim_set_hl(0, "@variable", { })
vim.api.nvim_set_hl(0, "@parameter", { })
vim.api.nvim_set_hl(0, "@field", { })