diff options
Diffstat (limited to '.config/nvim/lua')
-rw-r--r-- | .config/nvim/lua/user/\ | 13 | ||||
-rw-r--r-- | .config/nvim/lua/user/lsp/cxx.lua | 12 | ||||
-rw-r--r-- | .config/nvim/lua/user/lsp/rust.lua | 22 | ||||
-rw-r--r-- | .config/nvim/lua/user/options.lua | 4 | ||||
-rw-r--r-- | .config/nvim/lua/user/remaps.lua | 44 | ||||
-rw-r--r-- | .config/nvim/lua/user/treesitter.lua | 8 |
6 files changed, 79 insertions, 24 deletions
diff --git a/.config/nvim/lua/user/\ b/.config/nvim/lua/user/\ new file mode 100644 index 0000000..2baf779 --- /dev/null +++ b/.config/nvim/lua/user/\ @@ -0,0 +1,13 @@ +lsp = require 'lspconfig' + +lsp.clangd.setup { + cmd = {"clangd", "--background-index", "--suggest-missing-includes", "--clang-tidy"}, + filetypes = {"c", "cpp", "cxx", "h", "hpp", "hxx", "inc", "objc", "objcpp"}, + root_dir = lspconfig.utill.root_pattern("CMakeLists.txt", "Makefile", "qmake.pro", ".git"), + init_options = { + clangdFileStatus = true, + usePlaceholders = true, + completeUnimported = true, + semanticHighlighting = true, + }, +} diff --git a/.config/nvim/lua/user/lsp/cxx.lua b/.config/nvim/lua/user/lsp/cxx.lua index 5cd4a2e..afc98b4 100644 --- a/.config/nvim/lua/user/lsp/cxx.lua +++ b/.config/nvim/lua/user/lsp/cxx.lua @@ -1 +1,13 @@ lsp = require 'lspconfig' + +lsp.clangd.setup { + cmd = {"clangd", "--background-index", "--suggest-missing-includes", "--clang-tidy"}, + filetypes = {"c", "cpp", "cxx", "h", "hpp", "hxx", "inc", "objc", "objcpp"}, + root_dir = lsp.util.root_pattern("compile_commands.json", "CMakeLists.txt", "Makefile", "qmake.pro", ".git"), + init_options = { + clangdFileStatus = true, + usePlaceholders = true, + completeUnimported = true, + semanticHighlighting = true, + }, +} diff --git a/.config/nvim/lua/user/lsp/rust.lua b/.config/nvim/lua/user/lsp/rust.lua index 41cb03c..83c1f2c 100644 --- a/.config/nvim/lua/user/lsp/rust.lua +++ b/.config/nvim/lua/user/lsp/rust.lua @@ -1,28 +1,6 @@ local lsp = require 'lspconfig' local rust = require 'rust-tools' --- vim.cmd [[ --- autocmd FileType rust highlight link rustLifetime SpecialComment --- ]] - --- vim.cmd [[ --- autocmd FileType rust setlocal inccommand=nosplit --- ]] - --- lsp.rust_analyzer.setup{ --- cmd = {"rust-analyzer"}, --- filetypes = {"rust", "rs"}, --- root_dir = lsp.util.root_pattern("Cargo.toml"), --- -- fucking magic --- capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), --- settings = { --- ["rust-analyzer"] = { --- disgnostics = { enable = true }, --- inlayHints = { typeHints = true }, --- }, --- }, --- } - rust.setup{ server = { on_attach = function(_, bufnr) diff --git a/.config/nvim/lua/user/options.lua b/.config/nvim/lua/user/options.lua index 44c3599..098277d 100644 --- a/.config/nvim/lua/user/options.lua +++ b/.config/nvim/lua/user/options.lua @@ -28,7 +28,9 @@ local options = { splitbelow = true, splitright = true, -- autocompletion - completeopt = { 'menuone', 'noselect', 'noinsert' } + completeopt = { 'menuone', 'noselect', 'noinsert' }, + -- treesitter + foldlevel = 3, } for key, val in pairs(options) do diff --git a/.config/nvim/lua/user/remaps.lua b/.config/nvim/lua/user/remaps.lua index e5a465c..6400957 100644 --- a/.config/nvim/lua/user/remaps.lua +++ b/.config/nvim/lua/user/remaps.lua @@ -3,6 +3,7 @@ local opt = { noremap = true, silent = true } local map = vim.api.nvim_set_keymap +local lmap = vim.keymap.set map("", "\\", "<Nop>", opt) vim.g.mapleader = "\\" @@ -57,6 +58,10 @@ map("v", ">", ">gv", opt) map("n", "<A-j>", ":m .-2<CR>==", opt) -- SWITCHED K AND J map("n", "<A-k>", ":m .+1<CR>==", opt) -- SWITCHED K AND J +-- moving buffer +map("n", "<A-Down>", "<C-e>", opt) +map("n", "<A-Up>", "<C-y>", opt) + -- duplicating lines map("n", "<C-A-Up>", ":.,.t.-1<CR>==", opt) map("n", "<C-A-Down>", ":.,.t.<CR>==", opt) @@ -74,3 +79,42 @@ map("c", "w!!", "w !sudo tee % > /dev/null", opt) map("n", "G", "G$", opt) map("n", "gg", "gg0", opt) +-- treesitter remaps +map("n", "<leader>h", "zC", opt) +map("n", "<leader>l", "zO", opt) +map("n", "<leader>H", "zM", opt) +map("n", "<leader>L", "zR", opt) +map("n", "<leader>f", "za", opt) + +-- disgnostic remaps +lmap("n", "<leader>d", vim.diagnostic.open_float) +lmap("n", "d[", vim.diagnostic.goto_prev) +lmap("n", "d]", vim.diagnostic.goto_next) + +-- language server remaps +-- enable only after attaching language server to buffer +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(event) + -- i don't know whether i should enable this + -- vim.bo[event.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' + local opts = { buffer = event.buf } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) + vim.keymap.set('n', '<leader><C-k>', vim.lsp.buf.signature_help, opts) + vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set('n', '<leader>wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, opts) + vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, opts) + vim.keymap.set({ 'n', 'v' }, '<leader>a', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', '<leader>F', function() + vim.lsp.buf.format { async = true } + end, opts) + end, +}) diff --git a/.config/nvim/lua/user/treesitter.lua b/.config/nvim/lua/user/treesitter.lua index b98311f..74b8f56 100644 --- a/.config/nvim/lua/user/treesitter.lua +++ b/.config/nvim/lua/user/treesitter.lua @@ -4,8 +4,11 @@ local ts = require 'nvim-treesitter' local tsc = require 'nvim-treesitter.configs' +vim.wo.foldmethod = 'expr' +vim.wo.foldexpr = 'nvim_treesitter#foldexpr()' + tsc.setup{ - ensure_installed = { "rust" }, + ensure_installed = { "rust", "cpp", "python" }, auto_install = true, highlight = { enable = true, @@ -17,4 +20,7 @@ tsc.setup{ extended_mode = true, max_file_lines = 1024, }, + fold = { + enable = true, + } } |