diff options
-rw-r--r-- | after/plugin/telescope.lua | 11 | ||||
-rw-r--r-- | init.lua | 70 | ||||
-rw-r--r-- | lua/config/autocmds.lua | 83 | ||||
-rw-r--r-- | lua/config/lazy.lua (renamed from lua/user/lazy.lua) | 7 | ||||
-rw-r--r-- | lua/config/lsp.lua (renamed from lua/user/lsp.lua) | 22 | ||||
-rw-r--r-- | lua/config/map.lua (renamed from lua/user/map.lua) | 0 | ||||
-rw-r--r-- | lua/config/set.lua (renamed from lua/user/set.lua) | 13 | ||||
-rw-r--r-- | todo.md | 12 |
8 files changed, 138 insertions, 80 deletions
diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua index c0005ee..c2d32a3 100644 --- a/after/plugin/telescope.lua +++ b/after/plugin/telescope.lua @@ -24,12 +24,11 @@ require("telescope").setup({ }) local builtin = require("telescope.builtin") -map("n", " ff", builtin.find_files) -map("n", " ", builtin.buffers) -map("n", " fg", builtin.git_files) -map("n", " fw", builtin.live_grep) -map("n", "<C-p>", "<cmd>Telescope git_files<cr>", { desc = "Find git files" }) -map("n", " vh", builtin.help_tags, { desc = "Find help tags" }) +map("n", " tf", builtin.find_files) +map("n", " tb", builtin.buffers) +map("n", "<C-p>", builtin.git_files) +map("n", " tw", builtin.live_grep) +map("n", " th", builtin.help_tags, { desc = "Find help tags" }) -- symbols map("n", " tse", "<cmd>lua require'telescope.builtin'.symbols{ sources = {'emoji', 'gitmoji'} }<CR>") @@ -1,65 +1,5 @@ -require("user.lazy") -require("user.set") -require("user.map") -require("user.lsp") - -local autocmd = vim.api.nvim_create_autocmd - -local function augroup(name) - return vim.api.nvim_create_augroup("user_" .. name, { clear = true }) -end - --- [[ Highlight on yank ]] -autocmd("TextYankPost", { - group = augroup("highlight_yank"), - callback = function() - vim.highlight.on_yank() - end, -}) - --- [[ Auto create parent directory if it doesn't exist ]] -autocmd("BufWritePre", { - group = augroup("auto_create_dir"), - callback = function(event) - if event.match:match("^%w%w+://") then - return - end - local file = vim.loop.fs_realpath(event.match) or event.match - vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") - end, -}) - --- Run gofmt + goimports on save -local format_sync_grp = vim.api.nvim_create_augroup("goimports", {}) -autocmd("BufWritePre", { - pattern = "*.go", - callback = function() - require("go.format").goimports() - end, - group = format_sync_grp, -}) - -autocmd("TermOpen", { - callback = function() - local o = vim.opt_local - o.signcolumn = "no" - o.number = false - o.relativenumber = false - vim.cmd("startinsert") - vim.keymap.set("t", "<Esc>", "<C-\\><C-n>", { noremap = true }) - end, -}) --- -- close automatically when shell process exits --- -- TODO: does not work --- autocmd("TermClose", { --- callback = function() --- vim.cmd("bdelete") --- end, --- }) -vim.keymap.set("n", "!", "<cmd>sp<CR><cmd>term<CR>", { desc = "Open terminal" }) - --- [[ preserve last position ]] -autocmd("BufReadPost", { - pattern = "*", - command = 'silent! normal! g`"zv', -}) +require("config.lazy") +require("config.set") +require("config.map") +require("config.lsp") +require("config.autocmds") diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua new file mode 100644 index 0000000..247f152 --- /dev/null +++ b/lua/config/autocmds.lua @@ -0,0 +1,83 @@ +local autocmd = vim.api.nvim_create_autocmd +local function augroup(name) + return vim.api.nvim_create_augroup("user_" .. name, { clear = true }) +end + +-- [[ Highlight on yank ]] +autocmd("TextYankPost", { + group = augroup("highlight_yank"), + callback = function() + vim.highlight.on_yank() + end, +}) + +-- [[ Auto create parent directory if it doesn't exist ]] +autocmd("BufWritePre", { + group = augroup("auto_create_dir"), + callback = function(event) + if event.match:match("^%w%w+://") then + return + end + local file = vim.loop.fs_realpath(event.match) or event.match + vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") + end, +}) + +-- Run gofmt + goimports on save +local format_sync_grp = vim.api.nvim_create_augroup("goimports", {}) +autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + require("go.format").goimports() + end, + group = format_sync_grp, +}) + +autocmd("TermOpen", { + callback = function() + local o = vim.opt_local + o.signcolumn = "no" + o.number = false + o.relativenumber = false + vim.cmd("startinsert") + vim.keymap.set("t", "<Esc>", "<C-\\><C-n>", { noremap = true }) + end, +}) +-- -- close automatically when shell process exits +-- -- TODO: does not work +-- autocmd("TermClose", { +-- callback = function() +-- vim.cmd("bdelete") +-- end, +-- }) +vim.keymap.set("n", "!", "<cmd>sp<CR><cmd>term<CR>", { desc = "Open terminal" }) + +-- [[ preserve last position ]] +autocmd("BufReadPost", { + pattern = "*", + command = 'silent! normal! g`"zv', +}) + +-- [[ no cursorline in insert mode ]] +local cursorGrp = augroup("CursorLine") +autocmd({ "InsertLeave", "WinEnter" }, { + pattern = "*", + command = "set cursorline", + group = cursorGrp, + desc = "show cursor line only in active window", +}) +autocmd({ "InsertEnter", "WinLeave" }, { pattern = "*", command = "set nocursorline", group = cursorGrp }) + +-- [[ spellchecker activated in txt files ]] +autocmd( + { "BufRead", "BufNewFile" }, + -- { pattern = { "*.txt", "*.md", "*.tex" }, command = [[setlocal spell<cr> setlocal spelllang=en,de<cr>]] } + { + pattern = { "*.txt" }, + callback = function() + vim.opt.spell = true + vim.opt.spelllang = "en" + end, + desc = "Enable spell checking for certain file types", + } +) diff --git a/lua/user/lazy.lua b/lua/config/lazy.lua index 31780ec..1bdad47 100644 --- a/lua/user/lazy.lua +++ b/lua/config/lazy.lua @@ -54,6 +54,7 @@ require("lazy").setup({ "lewis6991/gitsigns.nvim", -- better ntrw "tpope/vim-vinegar", + "tpope/vim-eunuch", -- integration with tmux keybinds { "christoomey/vim-tmux-navigator", @@ -138,6 +139,7 @@ require("lazy").setup({ dependencies = { "nvim-lua/plenary.nvim", "nvim-telescope/telescope-ui-select.nvim", + "nvim-telescope/telescope-symbols.nvim", { "nvim-telescope/telescope-fzf-native.nvim", build = "make", @@ -175,6 +177,11 @@ require("lazy").setup({ }, install = { colorscheme = { "nord" }, + missing = false, + }, + change_detection = { + enabled = false, + notify = false, }, checker = { enabled = false }, -- defaults = {lazy = true}, diff --git a/lua/user/lsp.lua b/lua/config/lsp.lua index 1443887..715d0f9 100644 --- a/lua/user/lsp.lua +++ b/lua/config/lsp.lua @@ -1,14 +1,15 @@ -- [[ Keybinds ]] local map = vim.keymap.set -map("n", " a", vim.lsp.buf.code_action) +map("n", " la", vim.lsp.buf.code_action) map("n", "gd", vim.lsp.buf.definition) -map("n", " r", vim.lsp.buf.rename) -map("n", " i", vim.lsp.buf.implementation) -map("n", " sh", vim.lsp.buf.signature_help) -map("n", " t", vim.lsp.buf.typehierarchy) -map("n", " r", vim.lsp.buf.references) -map("n", " sl", vim.lsp.buf.document_symbol) -map("n", " td", vim.lsp.buf.type_definition) +map("n", " lr", vim.lsp.buf.rename) +map("n", " li", vim.lsp.buf.implementation) +map("n", " lh", vim.lsp.buf.signature_help) +map("n", " lt", vim.lsp.buf.typehierarchy) +map("n", " lr", vim.lsp.buf.references) +map("n", " ls", vim.lsp.buf.document_symbol) +map("n", " ld", vim.lsp.buf.type_definition) +map("n", " lq", vim.diagnostic.setqflist) -- [[ LSP Setups ]] local lspconfig = require("lspconfig") @@ -51,10 +52,13 @@ require("lspconfig").lua_ls.setup({ }) -- [[ nvim cmp ]] -local capabilities = require("cmp_nvim_lsp").default_capabilities() +require("cmp_nvim_lsp").default_capabilities() local cmp = require("cmp") local lspkind = require("lspkind") cmp.setup({ + completion = { + autocomplete = false, + }, snippet = { expand = function(args) require("snippy").expand_snippet(args.body) diff --git a/lua/user/map.lua b/lua/config/map.lua index 230588f..230588f 100644 --- a/lua/user/map.lua +++ b/lua/config/map.lua diff --git a/lua/user/set.lua b/lua/config/set.lua index 6040c72..9f328b0 100644 --- a/lua/user/set.lua +++ b/lua/config/set.lua @@ -37,6 +37,7 @@ opt.ignorecase = true opt.smartcase = true -- Keep signcolumn on by default +print(vim.fs.find(".git", {})) opt.signcolumn = "yes" -- Decrease update time @@ -100,3 +101,15 @@ else end opt.title = true + +-- rounded border around floating windows +local _border = "rounded" +vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = _border, +}) +vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = _border, +}) +vim.diagnostic.config({ + float = { border = _border }, +}) @@ -0,0 +1,12 @@ +# To-Do's +- [x] completion keybind +- [x] go to definition +- [ ] luasnip snippets + +## cmp +- [x] completion from only 4 characters +- [ ] when searching have [horizontal menu](https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance) + - using words from the buffer only +- [ ] do not propose snippets in completion menu + - change lsp settings for this? +- [ ] look at the configuration options |